babylon.module.d.ts 5.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066
  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. _waitingTransformNodeId: Nullable<string>;
  8065. /** @hidden */
  8066. /** @hidden */
  8067. _matrix: Matrix;
  8068. /**
  8069. * Create a new bone
  8070. * @param name defines the bone name
  8071. * @param skeleton defines the parent skeleton
  8072. * @param parentBone defines the parent (can be null if the bone is the root)
  8073. * @param localMatrix defines the local matrix
  8074. * @param restPose defines the rest pose matrix
  8075. * @param baseMatrix defines the base matrix
  8076. * @param index defines index of the bone in the hiearchy
  8077. */
  8078. constructor(
  8079. /**
  8080. * defines the bone name
  8081. */
  8082. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8083. /**
  8084. * Gets the current object class name.
  8085. * @return the class name
  8086. */
  8087. getClassName(): string;
  8088. /**
  8089. * Gets the parent skeleton
  8090. * @returns a skeleton
  8091. */
  8092. getSkeleton(): Skeleton;
  8093. /**
  8094. * Gets parent bone
  8095. * @returns a bone or null if the bone is the root of the bone hierarchy
  8096. */
  8097. getParent(): Nullable<Bone>;
  8098. /**
  8099. * Returns an array containing the root bones
  8100. * @returns an array containing the root bones
  8101. */
  8102. getChildren(): Array<Bone>;
  8103. /**
  8104. * Sets the parent bone
  8105. * @param parent defines the parent (can be null if the bone is the root)
  8106. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8107. */
  8108. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8109. /**
  8110. * Gets the local matrix
  8111. * @returns a matrix
  8112. */
  8113. getLocalMatrix(): Matrix;
  8114. /**
  8115. * Gets the base matrix (initial matrix which remains unchanged)
  8116. * @returns a matrix
  8117. */
  8118. getBaseMatrix(): Matrix;
  8119. /**
  8120. * Gets the rest pose matrix
  8121. * @returns a matrix
  8122. */
  8123. getRestPose(): Matrix;
  8124. /**
  8125. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8126. */
  8127. getWorldMatrix(): Matrix;
  8128. /**
  8129. * Sets the local matrix to rest pose matrix
  8130. */
  8131. returnToRest(): void;
  8132. /**
  8133. * Gets the inverse of the absolute transform matrix.
  8134. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8135. * @returns a matrix
  8136. */
  8137. getInvertedAbsoluteTransform(): Matrix;
  8138. /**
  8139. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8140. * @returns a matrix
  8141. */
  8142. getAbsoluteTransform(): Matrix;
  8143. /**
  8144. * Links with the given transform node.
  8145. * The local matrix of this bone is copied from the transform node every frame.
  8146. * @param transformNode defines the transform node to link to
  8147. */
  8148. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8149. /** Gets or sets current position (in local space) */
  8150. position: Vector3;
  8151. /** Gets or sets current rotation (in local space) */
  8152. rotation: Vector3;
  8153. /** Gets or sets current rotation quaternion (in local space) */
  8154. rotationQuaternion: Quaternion;
  8155. /** Gets or sets current scaling (in local space) */
  8156. scaling: Vector3;
  8157. /**
  8158. * Gets the animation properties override
  8159. */
  8160. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8161. private _decompose;
  8162. private _compose;
  8163. /**
  8164. * Update the base and local matrices
  8165. * @param matrix defines the new base or local matrix
  8166. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8167. * @param updateLocalMatrix defines if the local matrix should be updated
  8168. */
  8169. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8170. /** @hidden */
  8171. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8172. /**
  8173. * Flag the bone as dirty (Forcing it to update everything)
  8174. */
  8175. markAsDirty(): void;
  8176. private _markAsDirtyAndCompose;
  8177. private _markAsDirtyAndDecompose;
  8178. /**
  8179. * Translate the bone in local or world space
  8180. * @param vec The amount to translate the bone
  8181. * @param space The space that the translation is in
  8182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8183. */
  8184. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8185. /**
  8186. * Set the postion of the bone in local or world space
  8187. * @param position The position to set the bone
  8188. * @param space The space that the position is in
  8189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8190. */
  8191. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8192. /**
  8193. * Set the absolute position of the bone (world space)
  8194. * @param position The position to set the bone
  8195. * @param mesh The mesh that this bone is attached to
  8196. */
  8197. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8198. /**
  8199. * Scale the bone on the x, y and z axes (in local space)
  8200. * @param x The amount to scale the bone on the x axis
  8201. * @param y The amount to scale the bone on the y axis
  8202. * @param z The amount to scale the bone on the z axis
  8203. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8204. */
  8205. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8206. /**
  8207. * Set the bone scaling in local space
  8208. * @param scale defines the scaling vector
  8209. */
  8210. setScale(scale: Vector3): void;
  8211. /**
  8212. * Gets the current scaling in local space
  8213. * @returns the current scaling vector
  8214. */
  8215. getScale(): Vector3;
  8216. /**
  8217. * Gets the current scaling in local space and stores it in a target vector
  8218. * @param result defines the target vector
  8219. */
  8220. getScaleToRef(result: Vector3): void;
  8221. /**
  8222. * Set the yaw, pitch, and roll of the bone in local or world space
  8223. * @param yaw The rotation of the bone on the y axis
  8224. * @param pitch The rotation of the bone on the x axis
  8225. * @param roll The rotation of the bone on the z axis
  8226. * @param space The space that the axes of rotation are in
  8227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8228. */
  8229. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8230. /**
  8231. * Add a rotation to the bone on an axis in local or world space
  8232. * @param axis The axis to rotate the bone on
  8233. * @param amount The amount to rotate the bone
  8234. * @param space The space that the axis is in
  8235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8236. */
  8237. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8238. /**
  8239. * Set the rotation of the bone to a particular axis angle in local or world space
  8240. * @param axis The axis to rotate the bone on
  8241. * @param angle The angle that the bone should be rotated to
  8242. * @param space The space that the axis is in
  8243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8244. */
  8245. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8246. /**
  8247. * Set the euler rotation of the bone in local of world space
  8248. * @param rotation The euler rotation that the bone should be set to
  8249. * @param space The space that the rotation is in
  8250. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8251. */
  8252. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8253. /**
  8254. * Set the quaternion rotation of the bone in local of world space
  8255. * @param quat The quaternion rotation that the bone should be set to
  8256. * @param space The space that the rotation is in
  8257. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8258. */
  8259. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8260. /**
  8261. * Set the rotation matrix of the bone in local of world space
  8262. * @param rotMat The rotation matrix that the bone should be set to
  8263. * @param space The space that the rotation is in
  8264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8265. */
  8266. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8267. private _rotateWithMatrix;
  8268. private _getNegativeRotationToRef;
  8269. /**
  8270. * Get the position of the bone in local or world space
  8271. * @param space The space that the returned position is in
  8272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8273. * @returns The position of the bone
  8274. */
  8275. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8276. /**
  8277. * Copy the position of the bone to a vector3 in local or world space
  8278. * @param space The space that the returned position is in
  8279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8280. * @param result The vector3 to copy the position to
  8281. */
  8282. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8283. /**
  8284. * Get the absolute position of the bone (world space)
  8285. * @param mesh The mesh that this bone is attached to
  8286. * @returns The absolute position of the bone
  8287. */
  8288. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8289. /**
  8290. * Copy the absolute position of the bone (world space) to the result param
  8291. * @param mesh The mesh that this bone is attached to
  8292. * @param result The vector3 to copy the absolute position to
  8293. */
  8294. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8295. /**
  8296. * Compute the absolute transforms of this bone and its children
  8297. */
  8298. computeAbsoluteTransforms(): void;
  8299. /**
  8300. * Get the world direction from an axis that is in the local space of the bone
  8301. * @param localAxis The local direction that is used to compute the world direction
  8302. * @param mesh The mesh that this bone is attached to
  8303. * @returns The world direction
  8304. */
  8305. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8306. /**
  8307. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8308. * @param localAxis The local direction that is used to compute the world direction
  8309. * @param mesh The mesh that this bone is attached to
  8310. * @param result The vector3 that the world direction will be copied to
  8311. */
  8312. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8313. /**
  8314. * Get the euler rotation of the bone in local or world space
  8315. * @param space The space that the rotation should be in
  8316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8317. * @returns The euler rotation
  8318. */
  8319. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8320. /**
  8321. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8322. * @param space The space that the rotation should be in
  8323. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8324. * @param result The vector3 that the rotation should be copied to
  8325. */
  8326. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8327. /**
  8328. * Get the quaternion rotation of the bone in either local or world space
  8329. * @param space The space that the rotation should be in
  8330. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8331. * @returns The quaternion rotation
  8332. */
  8333. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8334. /**
  8335. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8336. * @param space The space that the rotation should be in
  8337. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8338. * @param result The quaternion that the rotation should be copied to
  8339. */
  8340. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8341. /**
  8342. * Get the rotation matrix of the bone in local or world space
  8343. * @param space The space that the rotation should be in
  8344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8345. * @returns The rotation matrix
  8346. */
  8347. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8348. /**
  8349. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8350. * @param space The space that the rotation should be in
  8351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8352. * @param result The quaternion that the rotation should be copied to
  8353. */
  8354. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8355. /**
  8356. * Get the world position of a point that is in the local space of the bone
  8357. * @param position The local position
  8358. * @param mesh The mesh that this bone is attached to
  8359. * @returns The world position
  8360. */
  8361. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8362. /**
  8363. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8364. * @param position The local position
  8365. * @param mesh The mesh that this bone is attached to
  8366. * @param result The vector3 that the world position should be copied to
  8367. */
  8368. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8369. /**
  8370. * Get the local position of a point that is in world space
  8371. * @param position The world position
  8372. * @param mesh The mesh that this bone is attached to
  8373. * @returns The local position
  8374. */
  8375. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8376. /**
  8377. * Get the local position of a point that is in world space and copy it to the result param
  8378. * @param position The world position
  8379. * @param mesh The mesh that this bone is attached to
  8380. * @param result The vector3 that the local position should be copied to
  8381. */
  8382. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8383. }
  8384. }
  8385. declare module "babylonjs/Misc/iInspectable" {
  8386. /**
  8387. * Enum that determines the text-wrapping mode to use.
  8388. */
  8389. export enum InspectableType {
  8390. /**
  8391. * Checkbox for booleans
  8392. */
  8393. Checkbox = 0,
  8394. /**
  8395. * Sliders for numbers
  8396. */
  8397. Slider = 1,
  8398. /**
  8399. * Vector3
  8400. */
  8401. Vector3 = 2,
  8402. /**
  8403. * Quaternions
  8404. */
  8405. Quaternion = 3,
  8406. /**
  8407. * Color3
  8408. */
  8409. Color3 = 4
  8410. }
  8411. /**
  8412. * Interface used to define custom inspectable properties.
  8413. * This interface is used by the inspector to display custom property grids
  8414. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8415. */
  8416. export interface IInspectable {
  8417. /**
  8418. * Gets the label to display
  8419. */
  8420. label: string;
  8421. /**
  8422. * Gets the name of the property to edit
  8423. */
  8424. propertyName: string;
  8425. /**
  8426. * Gets the type of the editor to use
  8427. */
  8428. type: InspectableType;
  8429. /**
  8430. * Gets the minimum value of the property when using in "slider" mode
  8431. */
  8432. min?: number;
  8433. /**
  8434. * Gets the maximum value of the property when using in "slider" mode
  8435. */
  8436. max?: number;
  8437. /**
  8438. * Gets the setp to use when using in "slider" mode
  8439. */
  8440. step?: number;
  8441. }
  8442. }
  8443. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8444. import { Nullable } from "babylonjs/types";
  8445. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8446. /**
  8447. * This represents the required contract to create a new type of texture loader.
  8448. */
  8449. export interface IInternalTextureLoader {
  8450. /**
  8451. * Defines wether the loader supports cascade loading the different faces.
  8452. */
  8453. supportCascades: boolean;
  8454. /**
  8455. * This returns if the loader support the current file information.
  8456. * @param extension defines the file extension of the file being loaded
  8457. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8458. * @param fallback defines the fallback internal texture if any
  8459. * @param isBase64 defines whether the texture is encoded as a base64
  8460. * @param isBuffer defines whether the texture data are stored as a buffer
  8461. * @returns true if the loader can load the specified file
  8462. */
  8463. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8464. /**
  8465. * Transform the url before loading if required.
  8466. * @param rootUrl the url of the texture
  8467. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8468. * @returns the transformed texture
  8469. */
  8470. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8471. /**
  8472. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8473. * @param rootUrl the url of the texture
  8474. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8475. * @returns the fallback texture
  8476. */
  8477. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8478. /**
  8479. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8480. * @param data contains the texture data
  8481. * @param texture defines the BabylonJS internal texture
  8482. * @param createPolynomials will be true if polynomials have been requested
  8483. * @param onLoad defines the callback to trigger once the texture is ready
  8484. * @param onError defines the callback to trigger in case of error
  8485. */
  8486. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8487. /**
  8488. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8489. * @param data contains the texture data
  8490. * @param texture defines the BabylonJS internal texture
  8491. * @param callback defines the method to call once ready to upload
  8492. */
  8493. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8494. }
  8495. }
  8496. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8497. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8498. import { Nullable } from "babylonjs/types";
  8499. import { Scene } from "babylonjs/scene";
  8500. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8501. module "babylonjs/Engines/engine" {
  8502. interface Engine {
  8503. /**
  8504. * Creates a depth stencil cube texture.
  8505. * This is only available in WebGL 2.
  8506. * @param size The size of face edge in the cube texture.
  8507. * @param options The options defining the cube texture.
  8508. * @returns The cube texture
  8509. */
  8510. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8511. /**
  8512. * Creates a cube texture
  8513. * @param rootUrl defines the url where the files to load is located
  8514. * @param scene defines the current scene
  8515. * @param files defines the list of files to load (1 per face)
  8516. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8517. * @param onLoad defines an optional callback raised when the texture is loaded
  8518. * @param onError defines an optional callback raised if there is an issue to load the texture
  8519. * @param format defines the format of the data
  8520. * @param forcedExtension defines the extension to use to pick the right loader
  8521. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8522. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8523. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8524. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8525. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8526. * @returns the cube texture as an InternalTexture
  8527. */
  8528. 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;
  8529. /**
  8530. * Creates a cube texture
  8531. * @param rootUrl defines the url where the files to load is located
  8532. * @param scene defines the current scene
  8533. * @param files defines the list of files to load (1 per face)
  8534. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8535. * @param onLoad defines an optional callback raised when the texture is loaded
  8536. * @param onError defines an optional callback raised if there is an issue to load the texture
  8537. * @param format defines the format of the data
  8538. * @param forcedExtension defines the extension to use to pick the right loader
  8539. * @returns the cube texture as an InternalTexture
  8540. */
  8541. 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;
  8542. /**
  8543. * Creates a cube texture
  8544. * @param rootUrl defines the url where the files to load is located
  8545. * @param scene defines the current scene
  8546. * @param files defines the list of files to load (1 per face)
  8547. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8548. * @param onLoad defines an optional callback raised when the texture is loaded
  8549. * @param onError defines an optional callback raised if there is an issue to load the texture
  8550. * @param format defines the format of the data
  8551. * @param forcedExtension defines the extension to use to pick the right loader
  8552. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8553. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8554. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8555. * @returns the cube texture as an InternalTexture
  8556. */
  8557. 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;
  8558. /** @hidden */
  8559. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8560. /** @hidden */
  8561. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8562. /** @hidden */
  8563. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8564. /** @hidden */
  8565. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8566. }
  8567. }
  8568. }
  8569. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8570. import { Nullable } from "babylonjs/types";
  8571. import { Scene } from "babylonjs/scene";
  8572. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8574. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8575. /**
  8576. * Class for creating a cube texture
  8577. */
  8578. export class CubeTexture extends BaseTexture {
  8579. private _delayedOnLoad;
  8580. /**
  8581. * The url of the texture
  8582. */
  8583. url: string;
  8584. /**
  8585. * Gets or sets the center of the bounding box associated with the cube texture.
  8586. * It must define where the camera used to render the texture was set
  8587. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8588. */
  8589. boundingBoxPosition: Vector3;
  8590. private _boundingBoxSize;
  8591. /**
  8592. * Gets or sets the size of the bounding box associated with the cube texture
  8593. * When defined, the cubemap will switch to local mode
  8594. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8595. * @example https://www.babylonjs-playground.com/#RNASML
  8596. */
  8597. /**
  8598. * Returns the bounding box size
  8599. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8600. */
  8601. boundingBoxSize: Vector3;
  8602. protected _rotationY: number;
  8603. /**
  8604. * Sets texture matrix rotation angle around Y axis in radians.
  8605. */
  8606. /**
  8607. * Gets texture matrix rotation angle around Y axis radians.
  8608. */
  8609. rotationY: number;
  8610. /**
  8611. * Are mip maps generated for this texture or not.
  8612. */
  8613. readonly noMipmap: boolean;
  8614. private _noMipmap;
  8615. private _files;
  8616. private _extensions;
  8617. private _textureMatrix;
  8618. private _format;
  8619. private _createPolynomials;
  8620. /** @hidden */
  8621. _prefiltered: boolean;
  8622. /**
  8623. * Creates a cube texture from an array of image urls
  8624. * @param files defines an array of image urls
  8625. * @param scene defines the hosting scene
  8626. * @param noMipmap specifies if mip maps are not used
  8627. * @returns a cube texture
  8628. */
  8629. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8630. /**
  8631. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8632. * @param url defines the url of the prefiltered texture
  8633. * @param scene defines the scene the texture is attached to
  8634. * @param forcedExtension defines the extension of the file if different from the url
  8635. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8636. * @return the prefiltered texture
  8637. */
  8638. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8639. /**
  8640. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8641. * as prefiltered data.
  8642. * @param rootUrl defines the url of the texture or the root name of the six images
  8643. * @param scene defines the scene the texture is attached to
  8644. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8645. * @param noMipmap defines if mipmaps should be created or not
  8646. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8647. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8648. * @param onError defines a callback triggered in case of error during load
  8649. * @param format defines the internal format to use for the texture once loaded
  8650. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8651. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8652. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8653. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8654. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8655. * @return the cube texture
  8656. */
  8657. 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);
  8658. /**
  8659. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8660. */
  8661. readonly isPrefiltered: boolean;
  8662. /**
  8663. * Get the current class name of the texture useful for serialization or dynamic coding.
  8664. * @returns "CubeTexture"
  8665. */
  8666. getClassName(): string;
  8667. /**
  8668. * Update the url (and optional buffer) of this texture if url was null during construction.
  8669. * @param url the url of the texture
  8670. * @param forcedExtension defines the extension to use
  8671. * @param onLoad callback called when the texture is loaded (defaults to null)
  8672. */
  8673. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8674. /**
  8675. * Delays loading of the cube texture
  8676. * @param forcedExtension defines the extension to use
  8677. */
  8678. delayLoad(forcedExtension?: string): void;
  8679. /**
  8680. * Returns the reflection texture matrix
  8681. * @returns the reflection texture matrix
  8682. */
  8683. getReflectionTextureMatrix(): Matrix;
  8684. /**
  8685. * Sets the reflection texture matrix
  8686. * @param value Reflection texture matrix
  8687. */
  8688. setReflectionTextureMatrix(value: Matrix): void;
  8689. /**
  8690. * Parses text to create a cube texture
  8691. * @param parsedTexture define the serialized text to read from
  8692. * @param scene defines the hosting scene
  8693. * @param rootUrl defines the root url of the cube texture
  8694. * @returns a cube texture
  8695. */
  8696. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8697. /**
  8698. * Makes a clone, or deep copy, of the cube texture
  8699. * @returns a new cube texture
  8700. */
  8701. clone(): CubeTexture;
  8702. }
  8703. }
  8704. declare module "babylonjs/Shaders/postprocess.vertex" {
  8705. /** @hidden */
  8706. export var postprocessVertexShader: {
  8707. name: string;
  8708. shader: string;
  8709. };
  8710. }
  8711. declare module "babylonjs/Cameras/targetCamera" {
  8712. import { Nullable } from "babylonjs/types";
  8713. import { Camera } from "babylonjs/Cameras/camera";
  8714. import { Scene } from "babylonjs/scene";
  8715. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8716. /**
  8717. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8718. * This is the base of the follow, arc rotate cameras and Free camera
  8719. * @see http://doc.babylonjs.com/features/cameras
  8720. */
  8721. export class TargetCamera extends Camera {
  8722. private static _RigCamTransformMatrix;
  8723. private static _TargetTransformMatrix;
  8724. private static _TargetFocalPoint;
  8725. /**
  8726. * Define the current direction the camera is moving to
  8727. */
  8728. cameraDirection: Vector3;
  8729. /**
  8730. * Define the current rotation the camera is rotating to
  8731. */
  8732. cameraRotation: Vector2;
  8733. /**
  8734. * When set, the up vector of the camera will be updated by the rotation of the camera
  8735. */
  8736. updateUpVectorFromRotation: boolean;
  8737. private _tmpQuaternion;
  8738. /**
  8739. * Define the current rotation of the camera
  8740. */
  8741. rotation: Vector3;
  8742. /**
  8743. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8744. */
  8745. rotationQuaternion: Quaternion;
  8746. /**
  8747. * Define the current speed of the camera
  8748. */
  8749. speed: number;
  8750. /**
  8751. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8752. * around all axis.
  8753. */
  8754. noRotationConstraint: boolean;
  8755. /**
  8756. * Define the current target of the camera as an object or a position.
  8757. */
  8758. lockedTarget: any;
  8759. /** @hidden */
  8760. _currentTarget: Vector3;
  8761. /** @hidden */
  8762. _initialFocalDistance: number;
  8763. /** @hidden */
  8764. _viewMatrix: Matrix;
  8765. /** @hidden */
  8766. _camMatrix: Matrix;
  8767. /** @hidden */
  8768. _cameraTransformMatrix: Matrix;
  8769. /** @hidden */
  8770. _cameraRotationMatrix: Matrix;
  8771. /** @hidden */
  8772. _referencePoint: Vector3;
  8773. /** @hidden */
  8774. _transformedReferencePoint: Vector3;
  8775. protected _globalCurrentTarget: Vector3;
  8776. protected _globalCurrentUpVector: Vector3;
  8777. /** @hidden */
  8778. _reset: () => void;
  8779. private _defaultUp;
  8780. /**
  8781. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8782. * This is the base of the follow, arc rotate cameras and Free camera
  8783. * @see http://doc.babylonjs.com/features/cameras
  8784. * @param name Defines the name of the camera in the scene
  8785. * @param position Defines the start position of the camera in the scene
  8786. * @param scene Defines the scene the camera belongs to
  8787. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8788. */
  8789. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8790. /**
  8791. * Gets the position in front of the camera at a given distance.
  8792. * @param distance The distance from the camera we want the position to be
  8793. * @returns the position
  8794. */
  8795. getFrontPosition(distance: number): Vector3;
  8796. /** @hidden */
  8797. _getLockedTargetPosition(): Nullable<Vector3>;
  8798. private _storedPosition;
  8799. private _storedRotation;
  8800. private _storedRotationQuaternion;
  8801. /**
  8802. * Store current camera state of the camera (fov, position, rotation, etc..)
  8803. * @returns the camera
  8804. */
  8805. storeState(): Camera;
  8806. /**
  8807. * Restored camera state. You must call storeState() first
  8808. * @returns whether it was successful or not
  8809. * @hidden
  8810. */
  8811. _restoreStateValues(): boolean;
  8812. /** @hidden */
  8813. _initCache(): void;
  8814. /** @hidden */
  8815. _updateCache(ignoreParentClass?: boolean): void;
  8816. /** @hidden */
  8817. _isSynchronizedViewMatrix(): boolean;
  8818. /** @hidden */
  8819. _computeLocalCameraSpeed(): number;
  8820. /**
  8821. * Defines the target the camera should look at.
  8822. * This will automatically adapt alpha beta and radius to fit within the new target.
  8823. * @param target Defines the new target as a Vector or a mesh
  8824. */
  8825. setTarget(target: Vector3): void;
  8826. /**
  8827. * Return the current target position of the camera. This value is expressed in local space.
  8828. * @returns the target position
  8829. */
  8830. getTarget(): Vector3;
  8831. /** @hidden */
  8832. _decideIfNeedsToMove(): boolean;
  8833. /** @hidden */
  8834. _updatePosition(): void;
  8835. /** @hidden */
  8836. _checkInputs(): void;
  8837. protected _updateCameraRotationMatrix(): void;
  8838. /**
  8839. * 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)
  8840. * @returns the current camera
  8841. */
  8842. private _rotateUpVectorWithCameraRotationMatrix;
  8843. private _cachedRotationZ;
  8844. private _cachedQuaternionRotationZ;
  8845. /** @hidden */
  8846. _getViewMatrix(): Matrix;
  8847. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8848. /**
  8849. * @hidden
  8850. */
  8851. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8852. /**
  8853. * @hidden
  8854. */
  8855. _updateRigCameras(): void;
  8856. private _getRigCamPositionAndTarget;
  8857. /**
  8858. * Gets the current object class name.
  8859. * @return the class name
  8860. */
  8861. getClassName(): string;
  8862. }
  8863. }
  8864. declare module "babylonjs/Cameras/cameraInputsManager" {
  8865. import { Nullable } from "babylonjs/types";
  8866. import { Camera } from "babylonjs/Cameras/camera";
  8867. /**
  8868. * @ignore
  8869. * This is a list of all the different input types that are available in the application.
  8870. * Fo instance: ArcRotateCameraGamepadInput...
  8871. */
  8872. export var CameraInputTypes: {};
  8873. /**
  8874. * This is the contract to implement in order to create a new input class.
  8875. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8876. */
  8877. export interface ICameraInput<TCamera extends Camera> {
  8878. /**
  8879. * Defines the camera the input is attached to.
  8880. */
  8881. camera: Nullable<TCamera>;
  8882. /**
  8883. * Gets the class name of the current intput.
  8884. * @returns the class name
  8885. */
  8886. getClassName(): string;
  8887. /**
  8888. * Get the friendly name associated with the input class.
  8889. * @returns the input friendly name
  8890. */
  8891. getSimpleName(): string;
  8892. /**
  8893. * Attach the input controls to a specific dom element to get the input from.
  8894. * @param element Defines the element the controls should be listened from
  8895. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8896. */
  8897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8898. /**
  8899. * Detach the current controls from the specified dom element.
  8900. * @param element Defines the element to stop listening the inputs from
  8901. */
  8902. detachControl(element: Nullable<HTMLElement>): void;
  8903. /**
  8904. * Update the current camera state depending on the inputs that have been used this frame.
  8905. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8906. */
  8907. checkInputs?: () => void;
  8908. }
  8909. /**
  8910. * Represents a map of input types to input instance or input index to input instance.
  8911. */
  8912. export interface CameraInputsMap<TCamera extends Camera> {
  8913. /**
  8914. * Accessor to the input by input type.
  8915. */
  8916. [name: string]: ICameraInput<TCamera>;
  8917. /**
  8918. * Accessor to the input by input index.
  8919. */
  8920. [idx: number]: ICameraInput<TCamera>;
  8921. }
  8922. /**
  8923. * This represents the input manager used within a camera.
  8924. * It helps dealing with all the different kind of input attached to a camera.
  8925. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8926. */
  8927. export class CameraInputsManager<TCamera extends Camera> {
  8928. /**
  8929. * Defines the list of inputs attahed to the camera.
  8930. */
  8931. attached: CameraInputsMap<TCamera>;
  8932. /**
  8933. * Defines the dom element the camera is collecting inputs from.
  8934. * This is null if the controls have not been attached.
  8935. */
  8936. attachedElement: Nullable<HTMLElement>;
  8937. /**
  8938. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8939. */
  8940. noPreventDefault: boolean;
  8941. /**
  8942. * Defined the camera the input manager belongs to.
  8943. */
  8944. camera: TCamera;
  8945. /**
  8946. * Update the current camera state depending on the inputs that have been used this frame.
  8947. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8948. */
  8949. checkInputs: () => void;
  8950. /**
  8951. * Instantiate a new Camera Input Manager.
  8952. * @param camera Defines the camera the input manager blongs to
  8953. */
  8954. constructor(camera: TCamera);
  8955. /**
  8956. * Add an input method to a camera
  8957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8958. * @param input camera input method
  8959. */
  8960. add(input: ICameraInput<TCamera>): void;
  8961. /**
  8962. * Remove a specific input method from a camera
  8963. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8964. * @param inputToRemove camera input method
  8965. */
  8966. remove(inputToRemove: ICameraInput<TCamera>): void;
  8967. /**
  8968. * Remove a specific input type from a camera
  8969. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8970. * @param inputType the type of the input to remove
  8971. */
  8972. removeByType(inputType: string): void;
  8973. private _addCheckInputs;
  8974. /**
  8975. * Attach the input controls to the currently attached dom element to listen the events from.
  8976. * @param input Defines the input to attach
  8977. */
  8978. attachInput(input: ICameraInput<TCamera>): void;
  8979. /**
  8980. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8981. * @param element Defines the dom element to collect the events from
  8982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8983. */
  8984. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8985. /**
  8986. * Detach the current manager inputs controls from a specific dom element.
  8987. * @param element Defines the dom element to collect the events from
  8988. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8989. */
  8990. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8991. /**
  8992. * Rebuild the dynamic inputCheck function from the current list of
  8993. * defined inputs in the manager.
  8994. */
  8995. rebuildInputCheck(): void;
  8996. /**
  8997. * Remove all attached input methods from a camera
  8998. */
  8999. clear(): void;
  9000. /**
  9001. * Serialize the current input manager attached to a camera.
  9002. * This ensures than once parsed,
  9003. * the input associated to the camera will be identical to the current ones
  9004. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9005. */
  9006. serialize(serializedCamera: any): void;
  9007. /**
  9008. * Parses an input manager serialized JSON to restore the previous list of inputs
  9009. * and states associated to a camera.
  9010. * @param parsedCamera Defines the JSON to parse
  9011. */
  9012. parse(parsedCamera: any): void;
  9013. }
  9014. }
  9015. declare module "babylonjs/Events/keyboardEvents" {
  9016. /**
  9017. * Gather the list of keyboard event types as constants.
  9018. */
  9019. export class KeyboardEventTypes {
  9020. /**
  9021. * The keydown event is fired when a key becomes active (pressed).
  9022. */
  9023. static readonly KEYDOWN: number;
  9024. /**
  9025. * The keyup event is fired when a key has been released.
  9026. */
  9027. static readonly KEYUP: number;
  9028. }
  9029. /**
  9030. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9031. */
  9032. export class KeyboardInfo {
  9033. /**
  9034. * Defines the type of event (KeyboardEventTypes)
  9035. */
  9036. type: number;
  9037. /**
  9038. * Defines the related dom event
  9039. */
  9040. event: KeyboardEvent;
  9041. /**
  9042. * Instantiates a new keyboard info.
  9043. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9044. * @param type Defines the type of event (KeyboardEventTypes)
  9045. * @param event Defines the related dom event
  9046. */
  9047. constructor(
  9048. /**
  9049. * Defines the type of event (KeyboardEventTypes)
  9050. */
  9051. type: number,
  9052. /**
  9053. * Defines the related dom event
  9054. */
  9055. event: KeyboardEvent);
  9056. }
  9057. /**
  9058. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9059. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9060. */
  9061. export class KeyboardInfoPre extends KeyboardInfo {
  9062. /**
  9063. * Defines the type of event (KeyboardEventTypes)
  9064. */
  9065. type: number;
  9066. /**
  9067. * Defines the related dom event
  9068. */
  9069. event: KeyboardEvent;
  9070. /**
  9071. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9072. */
  9073. skipOnPointerObservable: boolean;
  9074. /**
  9075. * Instantiates a new keyboard pre info.
  9076. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9077. * @param type Defines the type of event (KeyboardEventTypes)
  9078. * @param event Defines the related dom event
  9079. */
  9080. constructor(
  9081. /**
  9082. * Defines the type of event (KeyboardEventTypes)
  9083. */
  9084. type: number,
  9085. /**
  9086. * Defines the related dom event
  9087. */
  9088. event: KeyboardEvent);
  9089. }
  9090. }
  9091. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9092. import { Nullable } from "babylonjs/types";
  9093. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9094. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9095. /**
  9096. * Manage the keyboard inputs to control the movement of a free camera.
  9097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9098. */
  9099. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9100. /**
  9101. * Defines the camera the input is attached to.
  9102. */
  9103. camera: FreeCamera;
  9104. /**
  9105. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9106. */
  9107. keysUp: number[];
  9108. /**
  9109. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9110. */
  9111. keysDown: number[];
  9112. /**
  9113. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9114. */
  9115. keysLeft: number[];
  9116. /**
  9117. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9118. */
  9119. keysRight: number[];
  9120. private _keys;
  9121. private _onCanvasBlurObserver;
  9122. private _onKeyboardObserver;
  9123. private _engine;
  9124. private _scene;
  9125. /**
  9126. * Attach the input controls to a specific dom element to get the input from.
  9127. * @param element Defines the element the controls should be listened from
  9128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9129. */
  9130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9131. /**
  9132. * Detach the current controls from the specified dom element.
  9133. * @param element Defines the element to stop listening the inputs from
  9134. */
  9135. detachControl(element: Nullable<HTMLElement>): void;
  9136. /**
  9137. * Update the current camera state depending on the inputs that have been used this frame.
  9138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9139. */
  9140. checkInputs(): void;
  9141. /**
  9142. * Gets the class name of the current intput.
  9143. * @returns the class name
  9144. */
  9145. getClassName(): string;
  9146. /** @hidden */
  9147. _onLostFocus(): void;
  9148. /**
  9149. * Get the friendly name associated with the input class.
  9150. * @returns the input friendly name
  9151. */
  9152. getSimpleName(): string;
  9153. }
  9154. }
  9155. declare module "babylonjs/Lights/shadowLight" {
  9156. import { Camera } from "babylonjs/Cameras/camera";
  9157. import { Scene } from "babylonjs/scene";
  9158. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9160. import { Light } from "babylonjs/Lights/light";
  9161. /**
  9162. * Interface describing all the common properties and methods a shadow light needs to implement.
  9163. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9164. * as well as binding the different shadow properties to the effects.
  9165. */
  9166. export interface IShadowLight extends Light {
  9167. /**
  9168. * The light id in the scene (used in scene.findLighById for instance)
  9169. */
  9170. id: string;
  9171. /**
  9172. * The position the shdow will be casted from.
  9173. */
  9174. position: Vector3;
  9175. /**
  9176. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9177. */
  9178. direction: Vector3;
  9179. /**
  9180. * The transformed position. Position of the light in world space taking parenting in account.
  9181. */
  9182. transformedPosition: Vector3;
  9183. /**
  9184. * The transformed direction. Direction of the light in world space taking parenting in account.
  9185. */
  9186. transformedDirection: Vector3;
  9187. /**
  9188. * The friendly name of the light in the scene.
  9189. */
  9190. name: string;
  9191. /**
  9192. * Defines the shadow projection clipping minimum z value.
  9193. */
  9194. shadowMinZ: number;
  9195. /**
  9196. * Defines the shadow projection clipping maximum z value.
  9197. */
  9198. shadowMaxZ: number;
  9199. /**
  9200. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9201. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9202. */
  9203. computeTransformedInformation(): boolean;
  9204. /**
  9205. * Gets the scene the light belongs to.
  9206. * @returns The scene
  9207. */
  9208. getScene(): Scene;
  9209. /**
  9210. * Callback defining a custom Projection Matrix Builder.
  9211. * This can be used to override the default projection matrix computation.
  9212. */
  9213. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9214. /**
  9215. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9216. * @param matrix The materix to updated with the projection information
  9217. * @param viewMatrix The transform matrix of the light
  9218. * @param renderList The list of mesh to render in the map
  9219. * @returns The current light
  9220. */
  9221. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9222. /**
  9223. * Gets the current depth scale used in ESM.
  9224. * @returns The scale
  9225. */
  9226. getDepthScale(): number;
  9227. /**
  9228. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9229. * @returns true if a cube texture needs to be use
  9230. */
  9231. needCube(): boolean;
  9232. /**
  9233. * Detects if the projection matrix requires to be recomputed this frame.
  9234. * @returns true if it requires to be recomputed otherwise, false.
  9235. */
  9236. needProjectionMatrixCompute(): boolean;
  9237. /**
  9238. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9239. */
  9240. forceProjectionMatrixCompute(): void;
  9241. /**
  9242. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9243. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9244. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9245. */
  9246. getShadowDirection(faceIndex?: number): Vector3;
  9247. /**
  9248. * Gets the minZ used for shadow according to both the scene and the light.
  9249. * @param activeCamera The camera we are returning the min for
  9250. * @returns the depth min z
  9251. */
  9252. getDepthMinZ(activeCamera: Camera): number;
  9253. /**
  9254. * Gets the maxZ used for shadow according to both the scene and the light.
  9255. * @param activeCamera The camera we are returning the max for
  9256. * @returns the depth max z
  9257. */
  9258. getDepthMaxZ(activeCamera: Camera): number;
  9259. }
  9260. /**
  9261. * Base implementation IShadowLight
  9262. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9263. */
  9264. export abstract class ShadowLight extends Light implements IShadowLight {
  9265. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9266. protected _position: Vector3;
  9267. protected _setPosition(value: Vector3): void;
  9268. /**
  9269. * Sets the position the shadow will be casted from. Also use as the light position for both
  9270. * point and spot lights.
  9271. */
  9272. /**
  9273. * Sets the position the shadow will be casted from. Also use as the light position for both
  9274. * point and spot lights.
  9275. */
  9276. position: Vector3;
  9277. protected _direction: Vector3;
  9278. protected _setDirection(value: Vector3): void;
  9279. /**
  9280. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9281. * Also use as the light direction on spot and directional lights.
  9282. */
  9283. /**
  9284. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9285. * Also use as the light direction on spot and directional lights.
  9286. */
  9287. direction: Vector3;
  9288. private _shadowMinZ;
  9289. /**
  9290. * Gets the shadow projection clipping minimum z value.
  9291. */
  9292. /**
  9293. * Sets the shadow projection clipping minimum z value.
  9294. */
  9295. shadowMinZ: number;
  9296. private _shadowMaxZ;
  9297. /**
  9298. * Sets the shadow projection clipping maximum z value.
  9299. */
  9300. /**
  9301. * Gets the shadow projection clipping maximum z value.
  9302. */
  9303. shadowMaxZ: number;
  9304. /**
  9305. * Callback defining a custom Projection Matrix Builder.
  9306. * This can be used to override the default projection matrix computation.
  9307. */
  9308. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9309. /**
  9310. * The transformed position. Position of the light in world space taking parenting in account.
  9311. */
  9312. transformedPosition: Vector3;
  9313. /**
  9314. * The transformed direction. Direction of the light in world space taking parenting in account.
  9315. */
  9316. transformedDirection: Vector3;
  9317. private _needProjectionMatrixCompute;
  9318. /**
  9319. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9320. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9321. */
  9322. computeTransformedInformation(): boolean;
  9323. /**
  9324. * Return the depth scale used for the shadow map.
  9325. * @returns the depth scale.
  9326. */
  9327. getDepthScale(): number;
  9328. /**
  9329. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9330. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9331. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9332. */
  9333. getShadowDirection(faceIndex?: number): Vector3;
  9334. /**
  9335. * Returns the ShadowLight absolute position in the World.
  9336. * @returns the position vector in world space
  9337. */
  9338. getAbsolutePosition(): Vector3;
  9339. /**
  9340. * Sets the ShadowLight direction toward the passed target.
  9341. * @param target The point to target in local space
  9342. * @returns the updated ShadowLight direction
  9343. */
  9344. setDirectionToTarget(target: Vector3): Vector3;
  9345. /**
  9346. * Returns the light rotation in euler definition.
  9347. * @returns the x y z rotation in local space.
  9348. */
  9349. getRotation(): Vector3;
  9350. /**
  9351. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9352. * @returns true if a cube texture needs to be use
  9353. */
  9354. needCube(): boolean;
  9355. /**
  9356. * Detects if the projection matrix requires to be recomputed this frame.
  9357. * @returns true if it requires to be recomputed otherwise, false.
  9358. */
  9359. needProjectionMatrixCompute(): boolean;
  9360. /**
  9361. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9362. */
  9363. forceProjectionMatrixCompute(): void;
  9364. /** @hidden */
  9365. _initCache(): void;
  9366. /** @hidden */
  9367. _isSynchronized(): boolean;
  9368. /**
  9369. * Computes the world matrix of the node
  9370. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9371. * @returns the world matrix
  9372. */
  9373. computeWorldMatrix(force?: boolean): Matrix;
  9374. /**
  9375. * Gets the minZ used for shadow according to both the scene and the light.
  9376. * @param activeCamera The camera we are returning the min for
  9377. * @returns the depth min z
  9378. */
  9379. getDepthMinZ(activeCamera: Camera): number;
  9380. /**
  9381. * Gets the maxZ used for shadow according to both the scene and the light.
  9382. * @param activeCamera The camera we are returning the max for
  9383. * @returns the depth max z
  9384. */
  9385. getDepthMaxZ(activeCamera: Camera): number;
  9386. /**
  9387. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9388. * @param matrix The materix to updated with the projection information
  9389. * @param viewMatrix The transform matrix of the light
  9390. * @param renderList The list of mesh to render in the map
  9391. * @returns The current light
  9392. */
  9393. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9394. }
  9395. }
  9396. declare module "babylonjs/Materials/materialHelper" {
  9397. import { Nullable } from "babylonjs/types";
  9398. import { Scene } from "babylonjs/scene";
  9399. import { Engine } from "babylonjs/Engines/engine";
  9400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9401. import { Light } from "babylonjs/Lights/light";
  9402. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9403. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9405. /**
  9406. * "Static Class" containing the most commonly used helper while dealing with material for
  9407. * rendering purpose.
  9408. *
  9409. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9410. *
  9411. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9412. */
  9413. export class MaterialHelper {
  9414. /**
  9415. * Bind the current view position to an effect.
  9416. * @param effect The effect to be bound
  9417. * @param scene The scene the eyes position is used from
  9418. */
  9419. static BindEyePosition(effect: Effect, scene: Scene): void;
  9420. /**
  9421. * Helps preparing the defines values about the UVs in used in the effect.
  9422. * UVs are shared as much as we can accross channels in the shaders.
  9423. * @param texture The texture we are preparing the UVs for
  9424. * @param defines The defines to update
  9425. * @param key The channel key "diffuse", "specular"... used in the shader
  9426. */
  9427. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9428. /**
  9429. * Binds a texture matrix value to its corrsponding uniform
  9430. * @param texture The texture to bind the matrix for
  9431. * @param uniformBuffer The uniform buffer receivin the data
  9432. * @param key The channel key "diffuse", "specular"... used in the shader
  9433. */
  9434. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9435. /**
  9436. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9437. * @param mesh defines the current mesh
  9438. * @param scene defines the current scene
  9439. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9440. * @param pointsCloud defines if point cloud rendering has to be turned on
  9441. * @param fogEnabled defines if fog has to be turned on
  9442. * @param alphaTest defines if alpha testing has to be turned on
  9443. * @param defines defines the current list of defines
  9444. */
  9445. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9446. /**
  9447. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9448. * @param scene defines the current scene
  9449. * @param engine defines the current engine
  9450. * @param defines specifies the list of active defines
  9451. * @param useInstances defines if instances have to be turned on
  9452. * @param useClipPlane defines if clip plane have to be turned on
  9453. */
  9454. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9455. /**
  9456. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9457. * @param mesh The mesh containing the geometry data we will draw
  9458. * @param defines The defines to update
  9459. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9460. * @param useBones Precise whether bones should be used or not (override mesh info)
  9461. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9462. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9463. * @returns false if defines are considered not dirty and have not been checked
  9464. */
  9465. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9466. /**
  9467. * Prepares the defines related to multiview
  9468. * @param scene The scene we are intending to draw
  9469. * @param defines The defines to update
  9470. */
  9471. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9472. /**
  9473. * Prepares the defines related to the light information passed in parameter
  9474. * @param scene The scene we are intending to draw
  9475. * @param mesh The mesh the effect is compiling for
  9476. * @param defines The defines to update
  9477. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9478. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9479. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9480. * @returns true if normals will be required for the rest of the effect
  9481. */
  9482. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9483. /**
  9484. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9485. * that won t be acctive due to defines being turned off.
  9486. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9487. * @param samplersList The samplers list
  9488. * @param defines The defines helping in the list generation
  9489. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9490. */
  9491. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9492. /**
  9493. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9494. * @param defines The defines to update while falling back
  9495. * @param fallbacks The authorized effect fallbacks
  9496. * @param maxSimultaneousLights The maximum number of lights allowed
  9497. * @param rank the current rank of the Effect
  9498. * @returns The newly affected rank
  9499. */
  9500. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9501. /**
  9502. * Prepares the list of attributes required for morph targets according to the effect defines.
  9503. * @param attribs The current list of supported attribs
  9504. * @param mesh The mesh to prepare the morph targets attributes for
  9505. * @param defines The current Defines of the effect
  9506. */
  9507. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9508. /**
  9509. * Prepares the list of attributes required for bones according to the effect defines.
  9510. * @param attribs The current list of supported attribs
  9511. * @param mesh The mesh to prepare the bones attributes for
  9512. * @param defines The current Defines of the effect
  9513. * @param fallbacks The current efffect fallback strategy
  9514. */
  9515. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9516. /**
  9517. * Prepares the list of attributes required for instances according to the effect defines.
  9518. * @param attribs The current list of supported attribs
  9519. * @param defines The current Defines of the effect
  9520. */
  9521. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9522. /**
  9523. * Binds the light shadow information to the effect for the given mesh.
  9524. * @param light The light containing the generator
  9525. * @param scene The scene the lights belongs to
  9526. * @param mesh The mesh we are binding the information to render
  9527. * @param lightIndex The light index in the effect used to render the mesh
  9528. * @param effect The effect we are binding the data to
  9529. */
  9530. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9531. /**
  9532. * Binds the light information to the effect.
  9533. * @param light The light containing the generator
  9534. * @param effect The effect we are binding the data to
  9535. * @param lightIndex The light index in the effect used to render
  9536. */
  9537. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9538. /**
  9539. * Binds the lights information from the scene to the effect for the given mesh.
  9540. * @param scene The scene the lights belongs to
  9541. * @param mesh The mesh we are binding the information to render
  9542. * @param effect The effect we are binding the data to
  9543. * @param defines The generated defines for the effect
  9544. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9545. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9546. */
  9547. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9548. private static _tempFogColor;
  9549. /**
  9550. * Binds the fog information from the scene to the effect for the given mesh.
  9551. * @param scene The scene the lights belongs to
  9552. * @param mesh The mesh we are binding the information to render
  9553. * @param effect The effect we are binding the data to
  9554. * @param linearSpace Defines if the fog effect is applied in linear space
  9555. */
  9556. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9557. /**
  9558. * Binds the bones information from the mesh to the effect.
  9559. * @param mesh The mesh we are binding the information to render
  9560. * @param effect The effect we are binding the data to
  9561. */
  9562. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9563. /**
  9564. * Binds the morph targets information from the mesh to the effect.
  9565. * @param abstractMesh The mesh we are binding the information to render
  9566. * @param effect The effect we are binding the data to
  9567. */
  9568. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9569. /**
  9570. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9571. * @param defines The generated defines used in the effect
  9572. * @param effect The effect we are binding the data to
  9573. * @param scene The scene we are willing to render with logarithmic scale for
  9574. */
  9575. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9576. /**
  9577. * Binds the clip plane information from the scene to the effect.
  9578. * @param scene The scene the clip plane information are extracted from
  9579. * @param effect The effect we are binding the data to
  9580. */
  9581. static BindClipPlane(effect: Effect, scene: Scene): void;
  9582. }
  9583. }
  9584. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9585. /** @hidden */
  9586. export var kernelBlurVaryingDeclaration: {
  9587. name: string;
  9588. shader: string;
  9589. };
  9590. }
  9591. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9592. /** @hidden */
  9593. export var kernelBlurFragment: {
  9594. name: string;
  9595. shader: string;
  9596. };
  9597. }
  9598. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9599. /** @hidden */
  9600. export var kernelBlurFragment2: {
  9601. name: string;
  9602. shader: string;
  9603. };
  9604. }
  9605. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9606. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9607. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9608. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9609. /** @hidden */
  9610. export var kernelBlurPixelShader: {
  9611. name: string;
  9612. shader: string;
  9613. };
  9614. }
  9615. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9616. /** @hidden */
  9617. export var kernelBlurVertex: {
  9618. name: string;
  9619. shader: string;
  9620. };
  9621. }
  9622. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9623. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9624. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9625. /** @hidden */
  9626. export var kernelBlurVertexShader: {
  9627. name: string;
  9628. shader: string;
  9629. };
  9630. }
  9631. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9632. import { Vector2 } from "babylonjs/Maths/math";
  9633. import { Nullable } from "babylonjs/types";
  9634. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9635. import { Camera } from "babylonjs/Cameras/camera";
  9636. import { Effect } from "babylonjs/Materials/effect";
  9637. import { Engine } from "babylonjs/Engines/engine";
  9638. import "babylonjs/Shaders/kernelBlur.fragment";
  9639. import "babylonjs/Shaders/kernelBlur.vertex";
  9640. /**
  9641. * The Blur Post Process which blurs an image based on a kernel and direction.
  9642. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9643. */
  9644. export class BlurPostProcess extends PostProcess {
  9645. /** The direction in which to blur the image. */
  9646. direction: Vector2;
  9647. private blockCompilation;
  9648. protected _kernel: number;
  9649. protected _idealKernel: number;
  9650. protected _packedFloat: boolean;
  9651. private _staticDefines;
  9652. /**
  9653. * Sets the length in pixels of the blur sample region
  9654. */
  9655. /**
  9656. * Gets the length in pixels of the blur sample region
  9657. */
  9658. kernel: number;
  9659. /**
  9660. * Sets wether or not the blur needs to unpack/repack floats
  9661. */
  9662. /**
  9663. * Gets wether or not the blur is unpacking/repacking floats
  9664. */
  9665. packedFloat: boolean;
  9666. /**
  9667. * Creates a new instance BlurPostProcess
  9668. * @param name The name of the effect.
  9669. * @param direction The direction in which to blur the image.
  9670. * @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.
  9671. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9672. * @param camera The camera to apply the render pass to.
  9673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9674. * @param engine The engine which the post process will be applied. (default: current engine)
  9675. * @param reusable If the post process can be reused on the same frame. (default: false)
  9676. * @param textureType Type of textures used when performing the post process. (default: 0)
  9677. * @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)
  9678. */
  9679. constructor(name: string,
  9680. /** The direction in which to blur the image. */
  9681. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9682. /**
  9683. * Updates the effect with the current post process compile time values and recompiles the shader.
  9684. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9685. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9686. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9687. * @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
  9688. * @param onCompiled Called when the shader has been compiled.
  9689. * @param onError Called if there is an error when compiling a shader.
  9690. */
  9691. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9692. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9693. /**
  9694. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9695. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9696. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9697. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9698. * The gaps between physical kernels are compensated for in the weighting of the samples
  9699. * @param idealKernel Ideal blur kernel.
  9700. * @return Nearest best kernel.
  9701. */
  9702. protected _nearestBestKernel(idealKernel: number): number;
  9703. /**
  9704. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9705. * @param x The point on the Gaussian distribution to sample.
  9706. * @return the value of the Gaussian function at x.
  9707. */
  9708. protected _gaussianWeight(x: number): number;
  9709. /**
  9710. * Generates a string that can be used as a floating point number in GLSL.
  9711. * @param x Value to print.
  9712. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9713. * @return GLSL float string.
  9714. */
  9715. protected _glslFloat(x: number, decimalFigures?: number): string;
  9716. }
  9717. }
  9718. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9719. /** @hidden */
  9720. export var shadowMapPixelShader: {
  9721. name: string;
  9722. shader: string;
  9723. };
  9724. }
  9725. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9726. /** @hidden */
  9727. export var bonesDeclaration: {
  9728. name: string;
  9729. shader: string;
  9730. };
  9731. }
  9732. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9733. /** @hidden */
  9734. export var morphTargetsVertexGlobalDeclaration: {
  9735. name: string;
  9736. shader: string;
  9737. };
  9738. }
  9739. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9740. /** @hidden */
  9741. export var morphTargetsVertexDeclaration: {
  9742. name: string;
  9743. shader: string;
  9744. };
  9745. }
  9746. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9747. /** @hidden */
  9748. export var instancesDeclaration: {
  9749. name: string;
  9750. shader: string;
  9751. };
  9752. }
  9753. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9754. /** @hidden */
  9755. export var helperFunctions: {
  9756. name: string;
  9757. shader: string;
  9758. };
  9759. }
  9760. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9761. /** @hidden */
  9762. export var morphTargetsVertex: {
  9763. name: string;
  9764. shader: string;
  9765. };
  9766. }
  9767. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9768. /** @hidden */
  9769. export var instancesVertex: {
  9770. name: string;
  9771. shader: string;
  9772. };
  9773. }
  9774. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9775. /** @hidden */
  9776. export var bonesVertex: {
  9777. name: string;
  9778. shader: string;
  9779. };
  9780. }
  9781. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9782. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9783. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9784. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9785. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9786. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9787. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9788. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9789. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9790. /** @hidden */
  9791. export var shadowMapVertexShader: {
  9792. name: string;
  9793. shader: string;
  9794. };
  9795. }
  9796. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9797. /** @hidden */
  9798. export var depthBoxBlurPixelShader: {
  9799. name: string;
  9800. shader: string;
  9801. };
  9802. }
  9803. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9804. import { Nullable } from "babylonjs/types";
  9805. import { Scene } from "babylonjs/scene";
  9806. import { Matrix } from "babylonjs/Maths/math";
  9807. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9809. import { Mesh } from "babylonjs/Meshes/mesh";
  9810. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9811. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9812. import { Effect } from "babylonjs/Materials/effect";
  9813. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9814. import "babylonjs/Shaders/shadowMap.fragment";
  9815. import "babylonjs/Shaders/shadowMap.vertex";
  9816. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9817. import { Observable } from "babylonjs/Misc/observable";
  9818. /**
  9819. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9820. */
  9821. export interface ICustomShaderOptions {
  9822. /**
  9823. * Gets or sets the custom shader name to use
  9824. */
  9825. shaderName: string;
  9826. /**
  9827. * The list of attribute names used in the shader
  9828. */
  9829. attributes?: string[];
  9830. /**
  9831. * The list of unifrom names used in the shader
  9832. */
  9833. uniforms?: string[];
  9834. /**
  9835. * The list of sampler names used in the shader
  9836. */
  9837. samplers?: string[];
  9838. /**
  9839. * The list of defines used in the shader
  9840. */
  9841. defines?: string[];
  9842. }
  9843. /**
  9844. * Interface to implement to create a shadow generator compatible with BJS.
  9845. */
  9846. export interface IShadowGenerator {
  9847. /**
  9848. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9849. * @returns The render target texture if present otherwise, null
  9850. */
  9851. getShadowMap(): Nullable<RenderTargetTexture>;
  9852. /**
  9853. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9854. * @returns The render target texture if the shadow map is present otherwise, null
  9855. */
  9856. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9857. /**
  9858. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9859. * @param subMesh The submesh we want to render in the shadow map
  9860. * @param useInstances Defines wether will draw in the map using instances
  9861. * @returns true if ready otherwise, false
  9862. */
  9863. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9864. /**
  9865. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9866. * @param defines Defines of the material we want to update
  9867. * @param lightIndex Index of the light in the enabled light list of the material
  9868. */
  9869. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9870. /**
  9871. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9872. * defined in the generator but impacting the effect).
  9873. * It implies the unifroms available on the materials are the standard BJS ones.
  9874. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9875. * @param effect The effect we are binfing the information for
  9876. */
  9877. bindShadowLight(lightIndex: string, effect: Effect): void;
  9878. /**
  9879. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9880. * (eq to shadow prjection matrix * light transform matrix)
  9881. * @returns The transform matrix used to create the shadow map
  9882. */
  9883. getTransformMatrix(): Matrix;
  9884. /**
  9885. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9886. * Cube and 2D textures for instance.
  9887. */
  9888. recreateShadowMap(): void;
  9889. /**
  9890. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9891. * @param onCompiled Callback triggered at the and of the effects compilation
  9892. * @param options Sets of optional options forcing the compilation with different modes
  9893. */
  9894. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9895. useInstances: boolean;
  9896. }>): void;
  9897. /**
  9898. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9899. * @param options Sets of optional options forcing the compilation with different modes
  9900. * @returns A promise that resolves when the compilation completes
  9901. */
  9902. forceCompilationAsync(options?: Partial<{
  9903. useInstances: boolean;
  9904. }>): Promise<void>;
  9905. /**
  9906. * Serializes the shadow generator setup to a json object.
  9907. * @returns The serialized JSON object
  9908. */
  9909. serialize(): any;
  9910. /**
  9911. * Disposes the Shadow map and related Textures and effects.
  9912. */
  9913. dispose(): void;
  9914. }
  9915. /**
  9916. * Default implementation IShadowGenerator.
  9917. * This is the main object responsible of generating shadows in the framework.
  9918. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9919. */
  9920. export class ShadowGenerator implements IShadowGenerator {
  9921. /**
  9922. * Shadow generator mode None: no filtering applied.
  9923. */
  9924. static readonly FILTER_NONE: number;
  9925. /**
  9926. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9927. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9928. */
  9929. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9930. /**
  9931. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9932. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9933. */
  9934. static readonly FILTER_POISSONSAMPLING: number;
  9935. /**
  9936. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9937. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9938. */
  9939. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9940. /**
  9941. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9942. * edge artifacts on steep falloff.
  9943. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9944. */
  9945. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9946. /**
  9947. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9948. * edge artifacts on steep falloff.
  9949. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9950. */
  9951. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9952. /**
  9953. * Shadow generator mode PCF: Percentage Closer Filtering
  9954. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9955. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9956. */
  9957. static readonly FILTER_PCF: number;
  9958. /**
  9959. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9960. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9961. * Contact Hardening
  9962. */
  9963. static readonly FILTER_PCSS: number;
  9964. /**
  9965. * Reserved for PCF and PCSS
  9966. * Highest Quality.
  9967. *
  9968. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9969. *
  9970. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9971. */
  9972. static readonly QUALITY_HIGH: number;
  9973. /**
  9974. * Reserved for PCF and PCSS
  9975. * Good tradeoff for quality/perf cross devices
  9976. *
  9977. * Execute PCF on a 3*3 kernel.
  9978. *
  9979. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9980. */
  9981. static readonly QUALITY_MEDIUM: number;
  9982. /**
  9983. * Reserved for PCF and PCSS
  9984. * The lowest quality but the fastest.
  9985. *
  9986. * Execute PCF on a 1*1 kernel.
  9987. *
  9988. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9989. */
  9990. static readonly QUALITY_LOW: number;
  9991. /** Gets or sets the custom shader name to use */
  9992. customShaderOptions: ICustomShaderOptions;
  9993. /**
  9994. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9995. */
  9996. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9997. /**
  9998. * Observable triggered before a mesh is rendered in the shadow map.
  9999. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  10000. */
  10001. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10002. private _bias;
  10003. /**
  10004. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10005. */
  10006. /**
  10007. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10008. */
  10009. bias: number;
  10010. private _normalBias;
  10011. /**
  10012. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10013. */
  10014. /**
  10015. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10016. */
  10017. normalBias: number;
  10018. private _blurBoxOffset;
  10019. /**
  10020. * Gets the blur box offset: offset applied during the blur pass.
  10021. * Only useful if useKernelBlur = false
  10022. */
  10023. /**
  10024. * Sets the blur box offset: offset applied during the blur pass.
  10025. * Only useful if useKernelBlur = false
  10026. */
  10027. blurBoxOffset: number;
  10028. private _blurScale;
  10029. /**
  10030. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10031. * 2 means half of the size.
  10032. */
  10033. /**
  10034. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10035. * 2 means half of the size.
  10036. */
  10037. blurScale: number;
  10038. private _blurKernel;
  10039. /**
  10040. * Gets the blur kernel: kernel size of the blur pass.
  10041. * Only useful if useKernelBlur = true
  10042. */
  10043. /**
  10044. * Sets the blur kernel: kernel size of the blur pass.
  10045. * Only useful if useKernelBlur = true
  10046. */
  10047. blurKernel: number;
  10048. private _useKernelBlur;
  10049. /**
  10050. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10051. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10052. */
  10053. /**
  10054. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10055. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10056. */
  10057. useKernelBlur: boolean;
  10058. private _depthScale;
  10059. /**
  10060. * Gets the depth scale used in ESM mode.
  10061. */
  10062. /**
  10063. * Sets the depth scale used in ESM mode.
  10064. * This can override the scale stored on the light.
  10065. */
  10066. depthScale: number;
  10067. private _filter;
  10068. /**
  10069. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10070. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10071. */
  10072. /**
  10073. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10074. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10075. */
  10076. filter: number;
  10077. /**
  10078. * Gets if the current filter is set to Poisson Sampling.
  10079. */
  10080. /**
  10081. * Sets the current filter to Poisson Sampling.
  10082. */
  10083. usePoissonSampling: boolean;
  10084. /**
  10085. * Gets if the current filter is set to ESM.
  10086. */
  10087. /**
  10088. * Sets the current filter is to ESM.
  10089. */
  10090. useExponentialShadowMap: boolean;
  10091. /**
  10092. * Gets if the current filter is set to filtered ESM.
  10093. */
  10094. /**
  10095. * Gets if the current filter is set to filtered ESM.
  10096. */
  10097. useBlurExponentialShadowMap: boolean;
  10098. /**
  10099. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10100. * exponential to prevent steep falloff artifacts).
  10101. */
  10102. /**
  10103. * Sets the current filter to "close ESM" (using the inverse of the
  10104. * exponential to prevent steep falloff artifacts).
  10105. */
  10106. useCloseExponentialShadowMap: boolean;
  10107. /**
  10108. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10109. * exponential to prevent steep falloff artifacts).
  10110. */
  10111. /**
  10112. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10113. * exponential to prevent steep falloff artifacts).
  10114. */
  10115. useBlurCloseExponentialShadowMap: boolean;
  10116. /**
  10117. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10118. */
  10119. /**
  10120. * Sets the current filter to "PCF" (percentage closer filtering).
  10121. */
  10122. usePercentageCloserFiltering: boolean;
  10123. private _filteringQuality;
  10124. /**
  10125. * Gets the PCF or PCSS Quality.
  10126. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10127. */
  10128. /**
  10129. * Sets the PCF or PCSS Quality.
  10130. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10131. */
  10132. filteringQuality: number;
  10133. /**
  10134. * Gets if the current filter is set to "PCSS" (contact hardening).
  10135. */
  10136. /**
  10137. * Sets the current filter to "PCSS" (contact hardening).
  10138. */
  10139. useContactHardeningShadow: boolean;
  10140. private _contactHardeningLightSizeUVRatio;
  10141. /**
  10142. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10143. * Using a ratio helps keeping shape stability independently of the map size.
  10144. *
  10145. * It does not account for the light projection as it was having too much
  10146. * instability during the light setup or during light position changes.
  10147. *
  10148. * Only valid if useContactHardeningShadow is true.
  10149. */
  10150. /**
  10151. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10152. * Using a ratio helps keeping shape stability independently of the map size.
  10153. *
  10154. * It does not account for the light projection as it was having too much
  10155. * instability during the light setup or during light position changes.
  10156. *
  10157. * Only valid if useContactHardeningShadow is true.
  10158. */
  10159. contactHardeningLightSizeUVRatio: number;
  10160. private _darkness;
  10161. /**
  10162. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10163. * 0 means strongest and 1 would means no shadow.
  10164. * @returns the darkness.
  10165. */
  10166. getDarkness(): number;
  10167. /**
  10168. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10169. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10170. * @returns the shadow generator allowing fluent coding.
  10171. */
  10172. setDarkness(darkness: number): ShadowGenerator;
  10173. private _transparencyShadow;
  10174. /**
  10175. * Sets the ability to have transparent shadow (boolean).
  10176. * @param transparent True if transparent else False
  10177. * @returns the shadow generator allowing fluent coding
  10178. */
  10179. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10180. private _shadowMap;
  10181. private _shadowMap2;
  10182. /**
  10183. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10184. * @returns The render target texture if present otherwise, null
  10185. */
  10186. getShadowMap(): Nullable<RenderTargetTexture>;
  10187. /**
  10188. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10189. * @returns The render target texture if the shadow map is present otherwise, null
  10190. */
  10191. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10192. /**
  10193. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10194. * @param mesh Mesh to add
  10195. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10196. * @returns the Shadow Generator itself
  10197. */
  10198. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10199. /**
  10200. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10201. * @param mesh Mesh to remove
  10202. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10203. * @returns the Shadow Generator itself
  10204. */
  10205. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10206. /**
  10207. * Controls the extent to which the shadows fade out at the edge of the frustum
  10208. * Used only by directionals and spots
  10209. */
  10210. frustumEdgeFalloff: number;
  10211. private _light;
  10212. /**
  10213. * Returns the associated light object.
  10214. * @returns the light generating the shadow
  10215. */
  10216. getLight(): IShadowLight;
  10217. /**
  10218. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10219. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10220. * It might on the other hand introduce peter panning.
  10221. */
  10222. forceBackFacesOnly: boolean;
  10223. private _scene;
  10224. private _lightDirection;
  10225. private _effect;
  10226. private _viewMatrix;
  10227. private _projectionMatrix;
  10228. private _transformMatrix;
  10229. private _cachedPosition;
  10230. private _cachedDirection;
  10231. private _cachedDefines;
  10232. private _currentRenderID;
  10233. private _boxBlurPostprocess;
  10234. private _kernelBlurXPostprocess;
  10235. private _kernelBlurYPostprocess;
  10236. private _blurPostProcesses;
  10237. private _mapSize;
  10238. private _currentFaceIndex;
  10239. private _currentFaceIndexCache;
  10240. private _textureType;
  10241. private _defaultTextureMatrix;
  10242. /** @hidden */
  10243. static _SceneComponentInitialization: (scene: Scene) => void;
  10244. /**
  10245. * Creates a ShadowGenerator object.
  10246. * A ShadowGenerator is the required tool to use the shadows.
  10247. * Each light casting shadows needs to use its own ShadowGenerator.
  10248. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10249. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10250. * @param light The light object generating the shadows.
  10251. * @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.
  10252. */
  10253. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10254. private _initializeGenerator;
  10255. private _initializeShadowMap;
  10256. private _initializeBlurRTTAndPostProcesses;
  10257. private _renderForShadowMap;
  10258. private _renderSubMeshForShadowMap;
  10259. private _applyFilterValues;
  10260. /**
  10261. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10262. * @param onCompiled Callback triggered at the and of the effects compilation
  10263. * @param options Sets of optional options forcing the compilation with different modes
  10264. */
  10265. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10266. useInstances: boolean;
  10267. }>): void;
  10268. /**
  10269. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10270. * @param options Sets of optional options forcing the compilation with different modes
  10271. * @returns A promise that resolves when the compilation completes
  10272. */
  10273. forceCompilationAsync(options?: Partial<{
  10274. useInstances: boolean;
  10275. }>): Promise<void>;
  10276. /**
  10277. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10278. * @param subMesh The submesh we want to render in the shadow map
  10279. * @param useInstances Defines wether will draw in the map using instances
  10280. * @returns true if ready otherwise, false
  10281. */
  10282. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10283. /**
  10284. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10285. * @param defines Defines of the material we want to update
  10286. * @param lightIndex Index of the light in the enabled light list of the material
  10287. */
  10288. prepareDefines(defines: any, lightIndex: number): void;
  10289. /**
  10290. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10291. * defined in the generator but impacting the effect).
  10292. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10293. * @param effect The effect we are binfing the information for
  10294. */
  10295. bindShadowLight(lightIndex: string, effect: Effect): void;
  10296. /**
  10297. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10298. * (eq to shadow prjection matrix * light transform matrix)
  10299. * @returns The transform matrix used to create the shadow map
  10300. */
  10301. getTransformMatrix(): Matrix;
  10302. /**
  10303. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10304. * Cube and 2D textures for instance.
  10305. */
  10306. recreateShadowMap(): void;
  10307. private _disposeBlurPostProcesses;
  10308. private _disposeRTTandPostProcesses;
  10309. /**
  10310. * Disposes the ShadowGenerator.
  10311. * Returns nothing.
  10312. */
  10313. dispose(): void;
  10314. /**
  10315. * Serializes the shadow generator setup to a json object.
  10316. * @returns The serialized JSON object
  10317. */
  10318. serialize(): any;
  10319. /**
  10320. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10321. * @param parsedShadowGenerator The JSON object to parse
  10322. * @param scene The scene to create the shadow map for
  10323. * @returns The parsed shadow generator
  10324. */
  10325. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10326. }
  10327. }
  10328. declare module "babylonjs/Lights/light" {
  10329. import { Nullable } from "babylonjs/types";
  10330. import { Scene } from "babylonjs/scene";
  10331. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10332. import { Node } from "babylonjs/node";
  10333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10334. import { Effect } from "babylonjs/Materials/effect";
  10335. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10336. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10337. /**
  10338. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10339. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10340. * 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.
  10341. */
  10342. export abstract class Light extends Node {
  10343. /**
  10344. * Falloff Default: light is falling off following the material specification:
  10345. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10346. */
  10347. static readonly FALLOFF_DEFAULT: number;
  10348. /**
  10349. * Falloff Physical: light is falling off following the inverse squared distance law.
  10350. */
  10351. static readonly FALLOFF_PHYSICAL: number;
  10352. /**
  10353. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10354. * to enhance interoperability with other engines.
  10355. */
  10356. static readonly FALLOFF_GLTF: number;
  10357. /**
  10358. * Falloff Standard: light is falling off like in the standard material
  10359. * to enhance interoperability with other materials.
  10360. */
  10361. static readonly FALLOFF_STANDARD: number;
  10362. /**
  10363. * If every light affecting the material is in this lightmapMode,
  10364. * material.lightmapTexture adds or multiplies
  10365. * (depends on material.useLightmapAsShadowmap)
  10366. * after every other light calculations.
  10367. */
  10368. static readonly LIGHTMAP_DEFAULT: number;
  10369. /**
  10370. * material.lightmapTexture as only diffuse lighting from this light
  10371. * adds only specular lighting from this light
  10372. * adds dynamic shadows
  10373. */
  10374. static readonly LIGHTMAP_SPECULAR: number;
  10375. /**
  10376. * material.lightmapTexture as only lighting
  10377. * no light calculation from this light
  10378. * only adds dynamic shadows from this light
  10379. */
  10380. static readonly LIGHTMAP_SHADOWSONLY: number;
  10381. /**
  10382. * Each light type uses the default quantity according to its type:
  10383. * point/spot lights use luminous intensity
  10384. * directional lights use illuminance
  10385. */
  10386. static readonly INTENSITYMODE_AUTOMATIC: number;
  10387. /**
  10388. * lumen (lm)
  10389. */
  10390. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10391. /**
  10392. * candela (lm/sr)
  10393. */
  10394. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10395. /**
  10396. * lux (lm/m^2)
  10397. */
  10398. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10399. /**
  10400. * nit (cd/m^2)
  10401. */
  10402. static readonly INTENSITYMODE_LUMINANCE: number;
  10403. /**
  10404. * Light type const id of the point light.
  10405. */
  10406. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10407. /**
  10408. * Light type const id of the directional light.
  10409. */
  10410. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10411. /**
  10412. * Light type const id of the spot light.
  10413. */
  10414. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10415. /**
  10416. * Light type const id of the hemispheric light.
  10417. */
  10418. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10419. /**
  10420. * Diffuse gives the basic color to an object.
  10421. */
  10422. diffuse: Color3;
  10423. /**
  10424. * Specular produces a highlight color on an object.
  10425. * Note: This is note affecting PBR materials.
  10426. */
  10427. specular: Color3;
  10428. /**
  10429. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10430. * falling off base on range or angle.
  10431. * This can be set to any values in Light.FALLOFF_x.
  10432. *
  10433. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10434. * other types of materials.
  10435. */
  10436. falloffType: number;
  10437. /**
  10438. * Strength of the light.
  10439. * Note: By default it is define in the framework own unit.
  10440. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10441. */
  10442. intensity: number;
  10443. private _range;
  10444. protected _inverseSquaredRange: number;
  10445. /**
  10446. * Defines how far from the source the light is impacting in scene units.
  10447. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10448. */
  10449. /**
  10450. * Defines how far from the source the light is impacting in scene units.
  10451. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10452. */
  10453. range: number;
  10454. /**
  10455. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10456. * of light.
  10457. */
  10458. private _photometricScale;
  10459. private _intensityMode;
  10460. /**
  10461. * Gets the photometric scale used to interpret the intensity.
  10462. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10463. */
  10464. /**
  10465. * Sets the photometric scale used to interpret the intensity.
  10466. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10467. */
  10468. intensityMode: number;
  10469. private _radius;
  10470. /**
  10471. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10472. */
  10473. /**
  10474. * sets the light radius used by PBR Materials to simulate soft area lights.
  10475. */
  10476. radius: number;
  10477. private _renderPriority;
  10478. /**
  10479. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10480. * exceeding the number allowed of the materials.
  10481. */
  10482. renderPriority: number;
  10483. private _shadowEnabled;
  10484. /**
  10485. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10486. * the current shadow generator.
  10487. */
  10488. /**
  10489. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10490. * the current shadow generator.
  10491. */
  10492. shadowEnabled: boolean;
  10493. private _includedOnlyMeshes;
  10494. /**
  10495. * Gets the only meshes impacted by this light.
  10496. */
  10497. /**
  10498. * Sets the only meshes impacted by this light.
  10499. */
  10500. includedOnlyMeshes: AbstractMesh[];
  10501. private _excludedMeshes;
  10502. /**
  10503. * Gets the meshes not impacted by this light.
  10504. */
  10505. /**
  10506. * Sets the meshes not impacted by this light.
  10507. */
  10508. excludedMeshes: AbstractMesh[];
  10509. private _excludeWithLayerMask;
  10510. /**
  10511. * Gets the layer id use to find what meshes are not impacted by the light.
  10512. * Inactive if 0
  10513. */
  10514. /**
  10515. * Sets the layer id use to find what meshes are not impacted by the light.
  10516. * Inactive if 0
  10517. */
  10518. excludeWithLayerMask: number;
  10519. private _includeOnlyWithLayerMask;
  10520. /**
  10521. * Gets the layer id use to find what meshes are impacted by the light.
  10522. * Inactive if 0
  10523. */
  10524. /**
  10525. * Sets the layer id use to find what meshes are impacted by the light.
  10526. * Inactive if 0
  10527. */
  10528. includeOnlyWithLayerMask: number;
  10529. private _lightmapMode;
  10530. /**
  10531. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10532. */
  10533. /**
  10534. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10535. */
  10536. lightmapMode: number;
  10537. /**
  10538. * Shadow generator associted to the light.
  10539. * @hidden Internal use only.
  10540. */
  10541. _shadowGenerator: Nullable<IShadowGenerator>;
  10542. /**
  10543. * @hidden Internal use only.
  10544. */
  10545. _excludedMeshesIds: string[];
  10546. /**
  10547. * @hidden Internal use only.
  10548. */
  10549. _includedOnlyMeshesIds: string[];
  10550. /**
  10551. * The current light unifom buffer.
  10552. * @hidden Internal use only.
  10553. */
  10554. _uniformBuffer: UniformBuffer;
  10555. /**
  10556. * Creates a Light object in the scene.
  10557. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10558. * @param name The firendly name of the light
  10559. * @param scene The scene the light belongs too
  10560. */
  10561. constructor(name: string, scene: Scene);
  10562. protected abstract _buildUniformLayout(): void;
  10563. /**
  10564. * Sets the passed Effect "effect" with the Light information.
  10565. * @param effect The effect to update
  10566. * @param lightIndex The index of the light in the effect to update
  10567. * @returns The light
  10568. */
  10569. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10570. /**
  10571. * Returns the string "Light".
  10572. * @returns the class name
  10573. */
  10574. getClassName(): string;
  10575. /** @hidden */
  10576. readonly _isLight: boolean;
  10577. /**
  10578. * Converts the light information to a readable string for debug purpose.
  10579. * @param fullDetails Supports for multiple levels of logging within scene loading
  10580. * @returns the human readable light info
  10581. */
  10582. toString(fullDetails?: boolean): string;
  10583. /** @hidden */
  10584. protected _syncParentEnabledState(): void;
  10585. /**
  10586. * Set the enabled state of this node.
  10587. * @param value - the new enabled state
  10588. */
  10589. setEnabled(value: boolean): void;
  10590. /**
  10591. * Returns the Light associated shadow generator if any.
  10592. * @return the associated shadow generator.
  10593. */
  10594. getShadowGenerator(): Nullable<IShadowGenerator>;
  10595. /**
  10596. * Returns a Vector3, the absolute light position in the World.
  10597. * @returns the world space position of the light
  10598. */
  10599. getAbsolutePosition(): Vector3;
  10600. /**
  10601. * Specifies if the light will affect the passed mesh.
  10602. * @param mesh The mesh to test against the light
  10603. * @return true the mesh is affected otherwise, false.
  10604. */
  10605. canAffectMesh(mesh: AbstractMesh): boolean;
  10606. /**
  10607. * Sort function to order lights for rendering.
  10608. * @param a First Light object to compare to second.
  10609. * @param b Second Light object to compare first.
  10610. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10611. */
  10612. static CompareLightsPriority(a: Light, b: Light): number;
  10613. /**
  10614. * Releases resources associated with this node.
  10615. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10616. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10617. */
  10618. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10619. /**
  10620. * Returns the light type ID (integer).
  10621. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10622. */
  10623. getTypeID(): number;
  10624. /**
  10625. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10626. * @returns the scaled intensity in intensity mode unit
  10627. */
  10628. getScaledIntensity(): number;
  10629. /**
  10630. * Returns a new Light object, named "name", from the current one.
  10631. * @param name The name of the cloned light
  10632. * @returns the new created light
  10633. */
  10634. clone(name: string): Nullable<Light>;
  10635. /**
  10636. * Serializes the current light into a Serialization object.
  10637. * @returns the serialized object.
  10638. */
  10639. serialize(): any;
  10640. /**
  10641. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10642. * This new light is named "name" and added to the passed scene.
  10643. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10644. * @param name The friendly name of the light
  10645. * @param scene The scene the new light will belong to
  10646. * @returns the constructor function
  10647. */
  10648. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10649. /**
  10650. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10651. * @param parsedLight The JSON representation of the light
  10652. * @param scene The scene to create the parsed light in
  10653. * @returns the created light after parsing
  10654. */
  10655. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10656. private _hookArrayForExcluded;
  10657. private _hookArrayForIncludedOnly;
  10658. private _resyncMeshes;
  10659. /**
  10660. * Forces the meshes to update their light related information in their rendering used effects
  10661. * @hidden Internal Use Only
  10662. */
  10663. _markMeshesAsLightDirty(): void;
  10664. /**
  10665. * Recomputes the cached photometric scale if needed.
  10666. */
  10667. private _computePhotometricScale;
  10668. /**
  10669. * Returns the Photometric Scale according to the light type and intensity mode.
  10670. */
  10671. private _getPhotometricScale;
  10672. /**
  10673. * Reorder the light in the scene according to their defined priority.
  10674. * @hidden Internal Use Only
  10675. */
  10676. _reorderLightsInScene(): void;
  10677. /**
  10678. * Prepares the list of defines specific to the light type.
  10679. * @param defines the list of defines
  10680. * @param lightIndex defines the index of the light for the effect
  10681. */
  10682. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10683. }
  10684. }
  10685. declare module "babylonjs/Actions/action" {
  10686. import { Observable } from "babylonjs/Misc/observable";
  10687. import { Condition } from "babylonjs/Actions/condition";
  10688. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10689. import { ActionManager } from "babylonjs/Actions/actionManager";
  10690. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10691. /**
  10692. * Interface used to define Action
  10693. */
  10694. export interface IAction {
  10695. /**
  10696. * Trigger for the action
  10697. */
  10698. trigger: number;
  10699. /** Options of the trigger */
  10700. triggerOptions: any;
  10701. /**
  10702. * Gets the trigger parameters
  10703. * @returns the trigger parameters
  10704. */
  10705. getTriggerParameter(): any;
  10706. /**
  10707. * Internal only - executes current action event
  10708. * @hidden
  10709. */
  10710. _executeCurrent(evt?: ActionEvent): void;
  10711. /**
  10712. * Serialize placeholder for child classes
  10713. * @param parent of child
  10714. * @returns the serialized object
  10715. */
  10716. serialize(parent: any): any;
  10717. /**
  10718. * Internal only
  10719. * @hidden
  10720. */
  10721. _prepare(): void;
  10722. /**
  10723. * Internal only - manager for action
  10724. * @hidden
  10725. */
  10726. _actionManager: AbstractActionManager;
  10727. }
  10728. /**
  10729. * The action to be carried out following a trigger
  10730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10731. */
  10732. export class Action implements IAction {
  10733. /** the trigger, with or without parameters, for the action */
  10734. triggerOptions: any;
  10735. /**
  10736. * Trigger for the action
  10737. */
  10738. trigger: number;
  10739. /**
  10740. * Internal only - manager for action
  10741. * @hidden
  10742. */
  10743. _actionManager: ActionManager;
  10744. private _nextActiveAction;
  10745. private _child;
  10746. private _condition?;
  10747. private _triggerParameter;
  10748. /**
  10749. * An event triggered prior to action being executed.
  10750. */
  10751. onBeforeExecuteObservable: Observable<Action>;
  10752. /**
  10753. * Creates a new Action
  10754. * @param triggerOptions the trigger, with or without parameters, for the action
  10755. * @param condition an optional determinant of action
  10756. */
  10757. constructor(
  10758. /** the trigger, with or without parameters, for the action */
  10759. triggerOptions: any, condition?: Condition);
  10760. /**
  10761. * Internal only
  10762. * @hidden
  10763. */
  10764. _prepare(): void;
  10765. /**
  10766. * Gets the trigger parameters
  10767. * @returns the trigger parameters
  10768. */
  10769. getTriggerParameter(): any;
  10770. /**
  10771. * Internal only - executes current action event
  10772. * @hidden
  10773. */
  10774. _executeCurrent(evt?: ActionEvent): void;
  10775. /**
  10776. * Execute placeholder for child classes
  10777. * @param evt optional action event
  10778. */
  10779. execute(evt?: ActionEvent): void;
  10780. /**
  10781. * Skips to next active action
  10782. */
  10783. skipToNextActiveAction(): void;
  10784. /**
  10785. * Adds action to chain of actions, may be a DoNothingAction
  10786. * @param action defines the next action to execute
  10787. * @returns The action passed in
  10788. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10789. */
  10790. then(action: Action): Action;
  10791. /**
  10792. * Internal only
  10793. * @hidden
  10794. */
  10795. _getProperty(propertyPath: string): string;
  10796. /**
  10797. * Internal only
  10798. * @hidden
  10799. */
  10800. _getEffectiveTarget(target: any, propertyPath: string): any;
  10801. /**
  10802. * Serialize placeholder for child classes
  10803. * @param parent of child
  10804. * @returns the serialized object
  10805. */
  10806. serialize(parent: any): any;
  10807. /**
  10808. * Internal only called by serialize
  10809. * @hidden
  10810. */
  10811. protected _serialize(serializedAction: any, parent?: any): any;
  10812. /**
  10813. * Internal only
  10814. * @hidden
  10815. */
  10816. static _SerializeValueAsString: (value: any) => string;
  10817. /**
  10818. * Internal only
  10819. * @hidden
  10820. */
  10821. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10822. name: string;
  10823. targetType: string;
  10824. value: string;
  10825. };
  10826. }
  10827. }
  10828. declare module "babylonjs/Actions/condition" {
  10829. import { ActionManager } from "babylonjs/Actions/actionManager";
  10830. /**
  10831. * A Condition applied to an Action
  10832. */
  10833. export class Condition {
  10834. /**
  10835. * Internal only - manager for action
  10836. * @hidden
  10837. */
  10838. _actionManager: ActionManager;
  10839. /**
  10840. * Internal only
  10841. * @hidden
  10842. */
  10843. _evaluationId: number;
  10844. /**
  10845. * Internal only
  10846. * @hidden
  10847. */
  10848. _currentResult: boolean;
  10849. /**
  10850. * Creates a new Condition
  10851. * @param actionManager the manager of the action the condition is applied to
  10852. */
  10853. constructor(actionManager: ActionManager);
  10854. /**
  10855. * Check if the current condition is valid
  10856. * @returns a boolean
  10857. */
  10858. isValid(): boolean;
  10859. /**
  10860. * Internal only
  10861. * @hidden
  10862. */
  10863. _getProperty(propertyPath: string): string;
  10864. /**
  10865. * Internal only
  10866. * @hidden
  10867. */
  10868. _getEffectiveTarget(target: any, propertyPath: string): any;
  10869. /**
  10870. * Serialize placeholder for child classes
  10871. * @returns the serialized object
  10872. */
  10873. serialize(): any;
  10874. /**
  10875. * Internal only
  10876. * @hidden
  10877. */
  10878. protected _serialize(serializedCondition: any): any;
  10879. }
  10880. /**
  10881. * Defines specific conditional operators as extensions of Condition
  10882. */
  10883. export class ValueCondition extends Condition {
  10884. /** path to specify the property of the target the conditional operator uses */
  10885. propertyPath: string;
  10886. /** the value compared by the conditional operator against the current value of the property */
  10887. value: any;
  10888. /** the conditional operator, default ValueCondition.IsEqual */
  10889. operator: number;
  10890. /**
  10891. * Internal only
  10892. * @hidden
  10893. */
  10894. private static _IsEqual;
  10895. /**
  10896. * Internal only
  10897. * @hidden
  10898. */
  10899. private static _IsDifferent;
  10900. /**
  10901. * Internal only
  10902. * @hidden
  10903. */
  10904. private static _IsGreater;
  10905. /**
  10906. * Internal only
  10907. * @hidden
  10908. */
  10909. private static _IsLesser;
  10910. /**
  10911. * returns the number for IsEqual
  10912. */
  10913. static readonly IsEqual: number;
  10914. /**
  10915. * Returns the number for IsDifferent
  10916. */
  10917. static readonly IsDifferent: number;
  10918. /**
  10919. * Returns the number for IsGreater
  10920. */
  10921. static readonly IsGreater: number;
  10922. /**
  10923. * Returns the number for IsLesser
  10924. */
  10925. static readonly IsLesser: number;
  10926. /**
  10927. * Internal only The action manager for the condition
  10928. * @hidden
  10929. */
  10930. _actionManager: ActionManager;
  10931. /**
  10932. * Internal only
  10933. * @hidden
  10934. */
  10935. private _target;
  10936. /**
  10937. * Internal only
  10938. * @hidden
  10939. */
  10940. private _effectiveTarget;
  10941. /**
  10942. * Internal only
  10943. * @hidden
  10944. */
  10945. private _property;
  10946. /**
  10947. * Creates a new ValueCondition
  10948. * @param actionManager manager for the action the condition applies to
  10949. * @param target for the action
  10950. * @param propertyPath path to specify the property of the target the conditional operator uses
  10951. * @param value the value compared by the conditional operator against the current value of the property
  10952. * @param operator the conditional operator, default ValueCondition.IsEqual
  10953. */
  10954. constructor(actionManager: ActionManager, target: any,
  10955. /** path to specify the property of the target the conditional operator uses */
  10956. propertyPath: string,
  10957. /** the value compared by the conditional operator against the current value of the property */
  10958. value: any,
  10959. /** the conditional operator, default ValueCondition.IsEqual */
  10960. operator?: number);
  10961. /**
  10962. * Compares the given value with the property value for the specified conditional operator
  10963. * @returns the result of the comparison
  10964. */
  10965. isValid(): boolean;
  10966. /**
  10967. * Serialize the ValueCondition into a JSON compatible object
  10968. * @returns serialization object
  10969. */
  10970. serialize(): any;
  10971. /**
  10972. * Gets the name of the conditional operator for the ValueCondition
  10973. * @param operator the conditional operator
  10974. * @returns the name
  10975. */
  10976. static GetOperatorName(operator: number): string;
  10977. }
  10978. /**
  10979. * Defines a predicate condition as an extension of Condition
  10980. */
  10981. export class PredicateCondition extends Condition {
  10982. /** defines the predicate function used to validate the condition */
  10983. predicate: () => boolean;
  10984. /**
  10985. * Internal only - manager for action
  10986. * @hidden
  10987. */
  10988. _actionManager: ActionManager;
  10989. /**
  10990. * Creates a new PredicateCondition
  10991. * @param actionManager manager for the action the condition applies to
  10992. * @param predicate defines the predicate function used to validate the condition
  10993. */
  10994. constructor(actionManager: ActionManager,
  10995. /** defines the predicate function used to validate the condition */
  10996. predicate: () => boolean);
  10997. /**
  10998. * @returns the validity of the predicate condition
  10999. */
  11000. isValid(): boolean;
  11001. }
  11002. /**
  11003. * Defines a state condition as an extension of Condition
  11004. */
  11005. export class StateCondition extends Condition {
  11006. /** Value to compare with target state */
  11007. value: string;
  11008. /**
  11009. * Internal only - manager for action
  11010. * @hidden
  11011. */
  11012. _actionManager: ActionManager;
  11013. /**
  11014. * Internal only
  11015. * @hidden
  11016. */
  11017. private _target;
  11018. /**
  11019. * Creates a new StateCondition
  11020. * @param actionManager manager for the action the condition applies to
  11021. * @param target of the condition
  11022. * @param value to compare with target state
  11023. */
  11024. constructor(actionManager: ActionManager, target: any,
  11025. /** Value to compare with target state */
  11026. value: string);
  11027. /**
  11028. * Gets a boolean indicating if the current condition is met
  11029. * @returns the validity of the state
  11030. */
  11031. isValid(): boolean;
  11032. /**
  11033. * Serialize the StateCondition into a JSON compatible object
  11034. * @returns serialization object
  11035. */
  11036. serialize(): any;
  11037. }
  11038. }
  11039. declare module "babylonjs/Actions/directActions" {
  11040. import { Action } from "babylonjs/Actions/action";
  11041. import { Condition } from "babylonjs/Actions/condition";
  11042. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11043. /**
  11044. * This defines an action responsible to toggle a boolean once triggered.
  11045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11046. */
  11047. export class SwitchBooleanAction extends Action {
  11048. /**
  11049. * The path to the boolean property in the target object
  11050. */
  11051. propertyPath: string;
  11052. private _target;
  11053. private _effectiveTarget;
  11054. private _property;
  11055. /**
  11056. * Instantiate the action
  11057. * @param triggerOptions defines the trigger options
  11058. * @param target defines the object containing the boolean
  11059. * @param propertyPath defines the path to the boolean property in the target object
  11060. * @param condition defines the trigger related conditions
  11061. */
  11062. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11063. /** @hidden */
  11064. _prepare(): void;
  11065. /**
  11066. * Execute the action toggle the boolean value.
  11067. */
  11068. execute(): void;
  11069. /**
  11070. * Serializes the actions and its related information.
  11071. * @param parent defines the object to serialize in
  11072. * @returns the serialized object
  11073. */
  11074. serialize(parent: any): any;
  11075. }
  11076. /**
  11077. * This defines an action responsible to set a the state field of the target
  11078. * to a desired value once triggered.
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11080. */
  11081. export class SetStateAction extends Action {
  11082. /**
  11083. * The value to store in the state field.
  11084. */
  11085. value: string;
  11086. private _target;
  11087. /**
  11088. * Instantiate the action
  11089. * @param triggerOptions defines the trigger options
  11090. * @param target defines the object containing the state property
  11091. * @param value defines the value to store in the state field
  11092. * @param condition defines the trigger related conditions
  11093. */
  11094. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11095. /**
  11096. * Execute the action and store the value on the target state property.
  11097. */
  11098. execute(): void;
  11099. /**
  11100. * Serializes the actions and its related information.
  11101. * @param parent defines the object to serialize in
  11102. * @returns the serialized object
  11103. */
  11104. serialize(parent: any): any;
  11105. }
  11106. /**
  11107. * This defines an action responsible to set a property of the target
  11108. * to a desired value once triggered.
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11110. */
  11111. export class SetValueAction extends Action {
  11112. /**
  11113. * The path of the property to set in the target.
  11114. */
  11115. propertyPath: string;
  11116. /**
  11117. * The value to set in the property
  11118. */
  11119. value: any;
  11120. private _target;
  11121. private _effectiveTarget;
  11122. private _property;
  11123. /**
  11124. * Instantiate the action
  11125. * @param triggerOptions defines the trigger options
  11126. * @param target defines the object containing the property
  11127. * @param propertyPath defines the path of the property to set in the target
  11128. * @param value defines the value to set in the property
  11129. * @param condition defines the trigger related conditions
  11130. */
  11131. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11132. /** @hidden */
  11133. _prepare(): void;
  11134. /**
  11135. * Execute the action and set the targetted property to the desired value.
  11136. */
  11137. execute(): void;
  11138. /**
  11139. * Serializes the actions and its related information.
  11140. * @param parent defines the object to serialize in
  11141. * @returns the serialized object
  11142. */
  11143. serialize(parent: any): any;
  11144. }
  11145. /**
  11146. * This defines an action responsible to increment the target value
  11147. * to a desired value once triggered.
  11148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11149. */
  11150. export class IncrementValueAction extends Action {
  11151. /**
  11152. * The path of the property to increment in the target.
  11153. */
  11154. propertyPath: string;
  11155. /**
  11156. * The value we should increment the property by.
  11157. */
  11158. value: any;
  11159. private _target;
  11160. private _effectiveTarget;
  11161. private _property;
  11162. /**
  11163. * Instantiate the action
  11164. * @param triggerOptions defines the trigger options
  11165. * @param target defines the object containing the property
  11166. * @param propertyPath defines the path of the property to increment in the target
  11167. * @param value defines the value value we should increment the property by
  11168. * @param condition defines the trigger related conditions
  11169. */
  11170. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11171. /** @hidden */
  11172. _prepare(): void;
  11173. /**
  11174. * Execute the action and increment the target of the value amount.
  11175. */
  11176. execute(): void;
  11177. /**
  11178. * Serializes the actions and its related information.
  11179. * @param parent defines the object to serialize in
  11180. * @returns the serialized object
  11181. */
  11182. serialize(parent: any): any;
  11183. }
  11184. /**
  11185. * This defines an action responsible to start an animation once triggered.
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11187. */
  11188. export class PlayAnimationAction extends Action {
  11189. /**
  11190. * Where the animation should start (animation frame)
  11191. */
  11192. from: number;
  11193. /**
  11194. * Where the animation should stop (animation frame)
  11195. */
  11196. to: number;
  11197. /**
  11198. * Define if the animation should loop or stop after the first play.
  11199. */
  11200. loop?: boolean;
  11201. private _target;
  11202. /**
  11203. * Instantiate the action
  11204. * @param triggerOptions defines the trigger options
  11205. * @param target defines the target animation or animation name
  11206. * @param from defines from where the animation should start (animation frame)
  11207. * @param end defines where the animation should stop (animation frame)
  11208. * @param loop defines if the animation should loop or stop after the first play
  11209. * @param condition defines the trigger related conditions
  11210. */
  11211. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11212. /** @hidden */
  11213. _prepare(): void;
  11214. /**
  11215. * Execute the action and play the animation.
  11216. */
  11217. execute(): void;
  11218. /**
  11219. * Serializes the actions and its related information.
  11220. * @param parent defines the object to serialize in
  11221. * @returns the serialized object
  11222. */
  11223. serialize(parent: any): any;
  11224. }
  11225. /**
  11226. * This defines an action responsible to stop an animation once triggered.
  11227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11228. */
  11229. export class StopAnimationAction extends Action {
  11230. private _target;
  11231. /**
  11232. * Instantiate the action
  11233. * @param triggerOptions defines the trigger options
  11234. * @param target defines the target animation or animation name
  11235. * @param condition defines the trigger related conditions
  11236. */
  11237. constructor(triggerOptions: any, target: any, condition?: Condition);
  11238. /** @hidden */
  11239. _prepare(): void;
  11240. /**
  11241. * Execute the action and stop the animation.
  11242. */
  11243. execute(): void;
  11244. /**
  11245. * Serializes the actions and its related information.
  11246. * @param parent defines the object to serialize in
  11247. * @returns the serialized object
  11248. */
  11249. serialize(parent: any): any;
  11250. }
  11251. /**
  11252. * This defines an action responsible that does nothing once triggered.
  11253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11254. */
  11255. export class DoNothingAction extends Action {
  11256. /**
  11257. * Instantiate the action
  11258. * @param triggerOptions defines the trigger options
  11259. * @param condition defines the trigger related conditions
  11260. */
  11261. constructor(triggerOptions?: any, condition?: Condition);
  11262. /**
  11263. * Execute the action and do nothing.
  11264. */
  11265. execute(): void;
  11266. /**
  11267. * Serializes the actions and its related information.
  11268. * @param parent defines the object to serialize in
  11269. * @returns the serialized object
  11270. */
  11271. serialize(parent: any): any;
  11272. }
  11273. /**
  11274. * This defines an action responsible to trigger several actions once triggered.
  11275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11276. */
  11277. export class CombineAction extends Action {
  11278. /**
  11279. * The list of aggregated animations to run.
  11280. */
  11281. children: Action[];
  11282. /**
  11283. * Instantiate the action
  11284. * @param triggerOptions defines the trigger options
  11285. * @param children defines the list of aggregated animations to run
  11286. * @param condition defines the trigger related conditions
  11287. */
  11288. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11289. /** @hidden */
  11290. _prepare(): void;
  11291. /**
  11292. * Execute the action and executes all the aggregated actions.
  11293. */
  11294. execute(evt: ActionEvent): void;
  11295. /**
  11296. * Serializes the actions and its related information.
  11297. * @param parent defines the object to serialize in
  11298. * @returns the serialized object
  11299. */
  11300. serialize(parent: any): any;
  11301. }
  11302. /**
  11303. * This defines an action responsible to run code (external event) once triggered.
  11304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11305. */
  11306. export class ExecuteCodeAction extends Action {
  11307. /**
  11308. * The callback function to run.
  11309. */
  11310. func: (evt: ActionEvent) => void;
  11311. /**
  11312. * Instantiate the action
  11313. * @param triggerOptions defines the trigger options
  11314. * @param func defines the callback function to run
  11315. * @param condition defines the trigger related conditions
  11316. */
  11317. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11318. /**
  11319. * Execute the action and run the attached code.
  11320. */
  11321. execute(evt: ActionEvent): void;
  11322. }
  11323. /**
  11324. * This defines an action responsible to set the parent property of the target once triggered.
  11325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11326. */
  11327. export class SetParentAction extends Action {
  11328. private _parent;
  11329. private _target;
  11330. /**
  11331. * Instantiate the action
  11332. * @param triggerOptions defines the trigger options
  11333. * @param target defines the target containing the parent property
  11334. * @param parent defines from where the animation should start (animation frame)
  11335. * @param condition defines the trigger related conditions
  11336. */
  11337. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11338. /** @hidden */
  11339. _prepare(): void;
  11340. /**
  11341. * Execute the action and set the parent property.
  11342. */
  11343. execute(): void;
  11344. /**
  11345. * Serializes the actions and its related information.
  11346. * @param parent defines the object to serialize in
  11347. * @returns the serialized object
  11348. */
  11349. serialize(parent: any): any;
  11350. }
  11351. }
  11352. declare module "babylonjs/Actions/actionManager" {
  11353. import { Nullable } from "babylonjs/types";
  11354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11355. import { Scene } from "babylonjs/scene";
  11356. import { IAction } from "babylonjs/Actions/action";
  11357. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11358. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11359. /**
  11360. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11361. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11363. */
  11364. export class ActionManager extends AbstractActionManager {
  11365. /**
  11366. * Nothing
  11367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11368. */
  11369. static readonly NothingTrigger: number;
  11370. /**
  11371. * On pick
  11372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11373. */
  11374. static readonly OnPickTrigger: number;
  11375. /**
  11376. * On left pick
  11377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11378. */
  11379. static readonly OnLeftPickTrigger: number;
  11380. /**
  11381. * On right pick
  11382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11383. */
  11384. static readonly OnRightPickTrigger: number;
  11385. /**
  11386. * On center pick
  11387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11388. */
  11389. static readonly OnCenterPickTrigger: number;
  11390. /**
  11391. * On pick down
  11392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11393. */
  11394. static readonly OnPickDownTrigger: number;
  11395. /**
  11396. * On double pick
  11397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11398. */
  11399. static readonly OnDoublePickTrigger: number;
  11400. /**
  11401. * On pick up
  11402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11403. */
  11404. static readonly OnPickUpTrigger: number;
  11405. /**
  11406. * On pick out.
  11407. * This trigger will only be raised if you also declared a OnPickDown
  11408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11409. */
  11410. static readonly OnPickOutTrigger: number;
  11411. /**
  11412. * On long press
  11413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11414. */
  11415. static readonly OnLongPressTrigger: number;
  11416. /**
  11417. * On pointer over
  11418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11419. */
  11420. static readonly OnPointerOverTrigger: number;
  11421. /**
  11422. * On pointer out
  11423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11424. */
  11425. static readonly OnPointerOutTrigger: number;
  11426. /**
  11427. * On every frame
  11428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11429. */
  11430. static readonly OnEveryFrameTrigger: number;
  11431. /**
  11432. * On intersection enter
  11433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11434. */
  11435. static readonly OnIntersectionEnterTrigger: number;
  11436. /**
  11437. * On intersection exit
  11438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11439. */
  11440. static readonly OnIntersectionExitTrigger: number;
  11441. /**
  11442. * On key down
  11443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11444. */
  11445. static readonly OnKeyDownTrigger: number;
  11446. /**
  11447. * On key up
  11448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11449. */
  11450. static readonly OnKeyUpTrigger: number;
  11451. private _scene;
  11452. /**
  11453. * Creates a new action manager
  11454. * @param scene defines the hosting scene
  11455. */
  11456. constructor(scene: Scene);
  11457. /**
  11458. * Releases all associated resources
  11459. */
  11460. dispose(): void;
  11461. /**
  11462. * Gets hosting scene
  11463. * @returns the hosting scene
  11464. */
  11465. getScene(): Scene;
  11466. /**
  11467. * Does this action manager handles actions of any of the given triggers
  11468. * @param triggers defines the triggers to be tested
  11469. * @return a boolean indicating whether one (or more) of the triggers is handled
  11470. */
  11471. hasSpecificTriggers(triggers: number[]): boolean;
  11472. /**
  11473. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11474. * speed.
  11475. * @param triggerA defines the trigger to be tested
  11476. * @param triggerB defines the trigger to be tested
  11477. * @return a boolean indicating whether one (or more) of the triggers is handled
  11478. */
  11479. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11480. /**
  11481. * Does this action manager handles actions of a given trigger
  11482. * @param trigger defines the trigger to be tested
  11483. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11484. * @return whether the trigger is handled
  11485. */
  11486. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11487. /**
  11488. * Does this action manager has pointer triggers
  11489. */
  11490. readonly hasPointerTriggers: boolean;
  11491. /**
  11492. * Does this action manager has pick triggers
  11493. */
  11494. readonly hasPickTriggers: boolean;
  11495. /**
  11496. * Registers an action to this action manager
  11497. * @param action defines the action to be registered
  11498. * @return the action amended (prepared) after registration
  11499. */
  11500. registerAction(action: IAction): Nullable<IAction>;
  11501. /**
  11502. * Unregisters an action to this action manager
  11503. * @param action defines the action to be unregistered
  11504. * @return a boolean indicating whether the action has been unregistered
  11505. */
  11506. unregisterAction(action: IAction): Boolean;
  11507. /**
  11508. * Process a specific trigger
  11509. * @param trigger defines the trigger to process
  11510. * @param evt defines the event details to be processed
  11511. */
  11512. processTrigger(trigger: number, evt?: IActionEvent): void;
  11513. /** @hidden */
  11514. _getEffectiveTarget(target: any, propertyPath: string): any;
  11515. /** @hidden */
  11516. _getProperty(propertyPath: string): string;
  11517. /**
  11518. * Serialize this manager to a JSON object
  11519. * @param name defines the property name to store this manager
  11520. * @returns a JSON representation of this manager
  11521. */
  11522. serialize(name: string): any;
  11523. /**
  11524. * Creates a new ActionManager from a JSON data
  11525. * @param parsedActions defines the JSON data to read from
  11526. * @param object defines the hosting mesh
  11527. * @param scene defines the hosting scene
  11528. */
  11529. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11530. /**
  11531. * Get a trigger name by index
  11532. * @param trigger defines the trigger index
  11533. * @returns a trigger name
  11534. */
  11535. static GetTriggerName(trigger: number): string;
  11536. }
  11537. }
  11538. declare module "babylonjs/Culling/ray" {
  11539. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11540. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11542. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11543. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11544. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11545. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11546. /**
  11547. * Class representing a ray with position and direction
  11548. */
  11549. export class Ray {
  11550. /** origin point */
  11551. origin: Vector3;
  11552. /** direction */
  11553. direction: Vector3;
  11554. /** length of the ray */
  11555. length: number;
  11556. private static readonly TmpVector3;
  11557. private _tmpRay;
  11558. /**
  11559. * Creates a new ray
  11560. * @param origin origin point
  11561. * @param direction direction
  11562. * @param length length of the ray
  11563. */
  11564. constructor(
  11565. /** origin point */
  11566. origin: Vector3,
  11567. /** direction */
  11568. direction: Vector3,
  11569. /** length of the ray */
  11570. length?: number);
  11571. /**
  11572. * Checks if the ray intersects a box
  11573. * @param minimum bound of the box
  11574. * @param maximum bound of the box
  11575. * @param intersectionTreshold extra extend to be added to the box in all direction
  11576. * @returns if the box was hit
  11577. */
  11578. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11579. /**
  11580. * Checks if the ray intersects a box
  11581. * @param box the bounding box to check
  11582. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11583. * @returns if the box was hit
  11584. */
  11585. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11586. /**
  11587. * If the ray hits a sphere
  11588. * @param sphere the bounding sphere to check
  11589. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11590. * @returns true if it hits the sphere
  11591. */
  11592. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11593. /**
  11594. * If the ray hits a triange
  11595. * @param vertex0 triangle vertex
  11596. * @param vertex1 triangle vertex
  11597. * @param vertex2 triangle vertex
  11598. * @returns intersection information if hit
  11599. */
  11600. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11601. /**
  11602. * Checks if ray intersects a plane
  11603. * @param plane the plane to check
  11604. * @returns the distance away it was hit
  11605. */
  11606. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11607. /**
  11608. * Checks if ray intersects a mesh
  11609. * @param mesh the mesh to check
  11610. * @param fastCheck if only the bounding box should checked
  11611. * @returns picking info of the intersecton
  11612. */
  11613. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11614. /**
  11615. * Checks if ray intersects a mesh
  11616. * @param meshes the meshes to check
  11617. * @param fastCheck if only the bounding box should checked
  11618. * @param results array to store result in
  11619. * @returns Array of picking infos
  11620. */
  11621. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11622. private _comparePickingInfo;
  11623. private static smallnum;
  11624. private static rayl;
  11625. /**
  11626. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11627. * @param sega the first point of the segment to test the intersection against
  11628. * @param segb the second point of the segment to test the intersection against
  11629. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11630. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11631. */
  11632. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11633. /**
  11634. * Update the ray from viewport position
  11635. * @param x position
  11636. * @param y y position
  11637. * @param viewportWidth viewport width
  11638. * @param viewportHeight viewport height
  11639. * @param world world matrix
  11640. * @param view view matrix
  11641. * @param projection projection matrix
  11642. * @returns this ray updated
  11643. */
  11644. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11645. /**
  11646. * Creates a ray with origin and direction of 0,0,0
  11647. * @returns the new ray
  11648. */
  11649. static Zero(): Ray;
  11650. /**
  11651. * Creates a new ray from screen space and viewport
  11652. * @param x position
  11653. * @param y y position
  11654. * @param viewportWidth viewport width
  11655. * @param viewportHeight viewport height
  11656. * @param world world matrix
  11657. * @param view view matrix
  11658. * @param projection projection matrix
  11659. * @returns new ray
  11660. */
  11661. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11662. /**
  11663. * 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
  11664. * transformed to the given world matrix.
  11665. * @param origin The origin point
  11666. * @param end The end point
  11667. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11668. * @returns the new ray
  11669. */
  11670. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11671. /**
  11672. * Transforms a ray by a matrix
  11673. * @param ray ray to transform
  11674. * @param matrix matrix to apply
  11675. * @returns the resulting new ray
  11676. */
  11677. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11678. /**
  11679. * Transforms a ray by a matrix
  11680. * @param ray ray to transform
  11681. * @param matrix matrix to apply
  11682. * @param result ray to store result in
  11683. */
  11684. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11685. /**
  11686. * Unproject a ray from screen space to object space
  11687. * @param sourceX defines the screen space x coordinate to use
  11688. * @param sourceY defines the screen space y coordinate to use
  11689. * @param viewportWidth defines the current width of the viewport
  11690. * @param viewportHeight defines the current height of the viewport
  11691. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11692. * @param view defines the view matrix to use
  11693. * @param projection defines the projection matrix to use
  11694. */
  11695. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11696. }
  11697. /**
  11698. * Type used to define predicate used to select faces when a mesh intersection is detected
  11699. */
  11700. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11701. module "babylonjs/scene" {
  11702. interface Scene {
  11703. /** @hidden */
  11704. _tempPickingRay: Nullable<Ray>;
  11705. /** @hidden */
  11706. _cachedRayForTransform: Ray;
  11707. /** @hidden */
  11708. _pickWithRayInverseMatrix: Matrix;
  11709. /** @hidden */
  11710. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11711. /** @hidden */
  11712. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11713. }
  11714. }
  11715. }
  11716. declare module "babylonjs/sceneComponent" {
  11717. import { Scene } from "babylonjs/scene";
  11718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11719. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11720. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11721. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11722. import { Nullable } from "babylonjs/types";
  11723. import { Camera } from "babylonjs/Cameras/camera";
  11724. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11725. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11726. import { AbstractScene } from "babylonjs/abstractScene";
  11727. /**
  11728. * Groups all the scene component constants in one place to ease maintenance.
  11729. * @hidden
  11730. */
  11731. export class SceneComponentConstants {
  11732. static readonly NAME_EFFECTLAYER: string;
  11733. static readonly NAME_LAYER: string;
  11734. static readonly NAME_LENSFLARESYSTEM: string;
  11735. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11736. static readonly NAME_PARTICLESYSTEM: string;
  11737. static readonly NAME_GAMEPAD: string;
  11738. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11739. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11740. static readonly NAME_DEPTHRENDERER: string;
  11741. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11742. static readonly NAME_SPRITE: string;
  11743. static readonly NAME_OUTLINERENDERER: string;
  11744. static readonly NAME_PROCEDURALTEXTURE: string;
  11745. static readonly NAME_SHADOWGENERATOR: string;
  11746. static readonly NAME_OCTREE: string;
  11747. static readonly NAME_PHYSICSENGINE: string;
  11748. static readonly NAME_AUDIO: string;
  11749. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11750. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11751. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11752. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11753. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11754. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11755. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11756. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11757. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11758. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11759. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11760. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11761. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11762. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11763. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11764. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11765. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11766. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11767. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11768. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11769. static readonly STEP_AFTERRENDER_AUDIO: number;
  11770. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11771. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11772. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11773. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11774. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11775. static readonly STEP_POINTERMOVE_SPRITE: number;
  11776. static readonly STEP_POINTERDOWN_SPRITE: number;
  11777. static readonly STEP_POINTERUP_SPRITE: number;
  11778. }
  11779. /**
  11780. * This represents a scene component.
  11781. *
  11782. * This is used to decouple the dependency the scene is having on the different workloads like
  11783. * layers, post processes...
  11784. */
  11785. export interface ISceneComponent {
  11786. /**
  11787. * The name of the component. Each component must have a unique name.
  11788. */
  11789. name: string;
  11790. /**
  11791. * The scene the component belongs to.
  11792. */
  11793. scene: Scene;
  11794. /**
  11795. * Register the component to one instance of a scene.
  11796. */
  11797. register(): void;
  11798. /**
  11799. * Rebuilds the elements related to this component in case of
  11800. * context lost for instance.
  11801. */
  11802. rebuild(): void;
  11803. /**
  11804. * Disposes the component and the associated ressources.
  11805. */
  11806. dispose(): void;
  11807. }
  11808. /**
  11809. * This represents a SERIALIZABLE scene component.
  11810. *
  11811. * This extends Scene Component to add Serialization methods on top.
  11812. */
  11813. export interface ISceneSerializableComponent extends ISceneComponent {
  11814. /**
  11815. * Adds all the element from the container to the scene
  11816. * @param container the container holding the elements
  11817. */
  11818. addFromContainer(container: AbstractScene): void;
  11819. /**
  11820. * Removes all the elements in the container from the scene
  11821. * @param container contains the elements to remove
  11822. * @param dispose if the removed element should be disposed (default: false)
  11823. */
  11824. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11825. /**
  11826. * Serializes the component data to the specified json object
  11827. * @param serializationObject The object to serialize to
  11828. */
  11829. serialize(serializationObject: any): void;
  11830. }
  11831. /**
  11832. * Strong typing of a Mesh related stage step action
  11833. */
  11834. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11835. /**
  11836. * Strong typing of a Evaluate Sub Mesh related stage step action
  11837. */
  11838. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11839. /**
  11840. * Strong typing of a Active Mesh related stage step action
  11841. */
  11842. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11843. /**
  11844. * Strong typing of a Camera related stage step action
  11845. */
  11846. export type CameraStageAction = (camera: Camera) => void;
  11847. /**
  11848. * Strong typing of a Camera Frame buffer related stage step action
  11849. */
  11850. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11851. /**
  11852. * Strong typing of a Render Target related stage step action
  11853. */
  11854. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11855. /**
  11856. * Strong typing of a RenderingGroup related stage step action
  11857. */
  11858. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11859. /**
  11860. * Strong typing of a Mesh Render related stage step action
  11861. */
  11862. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11863. /**
  11864. * Strong typing of a simple stage step action
  11865. */
  11866. export type SimpleStageAction = () => void;
  11867. /**
  11868. * Strong typing of a render target action.
  11869. */
  11870. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11871. /**
  11872. * Strong typing of a pointer move action.
  11873. */
  11874. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11875. /**
  11876. * Strong typing of a pointer up/down action.
  11877. */
  11878. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11879. /**
  11880. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11881. * @hidden
  11882. */
  11883. export class Stage<T extends Function> extends Array<{
  11884. index: number;
  11885. component: ISceneComponent;
  11886. action: T;
  11887. }> {
  11888. /**
  11889. * Hide ctor from the rest of the world.
  11890. * @param items The items to add.
  11891. */
  11892. private constructor();
  11893. /**
  11894. * Creates a new Stage.
  11895. * @returns A new instance of a Stage
  11896. */
  11897. static Create<T extends Function>(): Stage<T>;
  11898. /**
  11899. * Registers a step in an ordered way in the targeted stage.
  11900. * @param index Defines the position to register the step in
  11901. * @param component Defines the component attached to the step
  11902. * @param action Defines the action to launch during the step
  11903. */
  11904. registerStep(index: number, component: ISceneComponent, action: T): void;
  11905. /**
  11906. * Clears all the steps from the stage.
  11907. */
  11908. clear(): void;
  11909. }
  11910. }
  11911. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11912. import { Nullable } from "babylonjs/types";
  11913. import { Observable } from "babylonjs/Misc/observable";
  11914. import { Scene } from "babylonjs/scene";
  11915. import { Sprite } from "babylonjs/Sprites/sprite";
  11916. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11917. import { Ray } from "babylonjs/Culling/ray";
  11918. import { Camera } from "babylonjs/Cameras/camera";
  11919. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11920. import { ISceneComponent } from "babylonjs/sceneComponent";
  11921. module "babylonjs/scene" {
  11922. interface Scene {
  11923. /** @hidden */
  11924. _pointerOverSprite: Nullable<Sprite>;
  11925. /** @hidden */
  11926. _pickedDownSprite: Nullable<Sprite>;
  11927. /** @hidden */
  11928. _tempSpritePickingRay: Nullable<Ray>;
  11929. /**
  11930. * All of the sprite managers added to this scene
  11931. * @see http://doc.babylonjs.com/babylon101/sprites
  11932. */
  11933. spriteManagers: Array<ISpriteManager>;
  11934. /**
  11935. * An event triggered when sprites rendering is about to start
  11936. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11937. */
  11938. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11939. /**
  11940. * An event triggered when sprites rendering is done
  11941. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11942. */
  11943. onAfterSpritesRenderingObservable: Observable<Scene>;
  11944. /** @hidden */
  11945. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11946. /** Launch a ray to try to pick a sprite in the scene
  11947. * @param x position on screen
  11948. * @param y position on screen
  11949. * @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
  11950. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11951. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11952. * @returns a PickingInfo
  11953. */
  11954. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11955. /** Use the given ray to pick a sprite in the scene
  11956. * @param ray The ray (in world space) to use to pick meshes
  11957. * @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
  11958. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11959. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11960. * @returns a PickingInfo
  11961. */
  11962. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11963. /**
  11964. * Force the sprite under the pointer
  11965. * @param sprite defines the sprite to use
  11966. */
  11967. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11968. /**
  11969. * Gets the sprite under the pointer
  11970. * @returns a Sprite or null if no sprite is under the pointer
  11971. */
  11972. getPointerOverSprite(): Nullable<Sprite>;
  11973. }
  11974. }
  11975. /**
  11976. * Defines the sprite scene component responsible to manage sprites
  11977. * in a given scene.
  11978. */
  11979. export class SpriteSceneComponent implements ISceneComponent {
  11980. /**
  11981. * The component name helpfull to identify the component in the list of scene components.
  11982. */
  11983. readonly name: string;
  11984. /**
  11985. * The scene the component belongs to.
  11986. */
  11987. scene: Scene;
  11988. /** @hidden */
  11989. private _spritePredicate;
  11990. /**
  11991. * Creates a new instance of the component for the given scene
  11992. * @param scene Defines the scene to register the component in
  11993. */
  11994. constructor(scene: Scene);
  11995. /**
  11996. * Registers the component in a given scene
  11997. */
  11998. register(): void;
  11999. /**
  12000. * Rebuilds the elements related to this component in case of
  12001. * context lost for instance.
  12002. */
  12003. rebuild(): void;
  12004. /**
  12005. * Disposes the component and the associated ressources.
  12006. */
  12007. dispose(): void;
  12008. private _pickSpriteButKeepRay;
  12009. private _pointerMove;
  12010. private _pointerDown;
  12011. private _pointerUp;
  12012. }
  12013. }
  12014. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12015. /** @hidden */
  12016. export var fogFragmentDeclaration: {
  12017. name: string;
  12018. shader: string;
  12019. };
  12020. }
  12021. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12022. /** @hidden */
  12023. export var fogFragment: {
  12024. name: string;
  12025. shader: string;
  12026. };
  12027. }
  12028. declare module "babylonjs/Shaders/sprites.fragment" {
  12029. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12030. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12031. /** @hidden */
  12032. export var spritesPixelShader: {
  12033. name: string;
  12034. shader: string;
  12035. };
  12036. }
  12037. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12038. /** @hidden */
  12039. export var fogVertexDeclaration: {
  12040. name: string;
  12041. shader: string;
  12042. };
  12043. }
  12044. declare module "babylonjs/Shaders/sprites.vertex" {
  12045. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12046. /** @hidden */
  12047. export var spritesVertexShader: {
  12048. name: string;
  12049. shader: string;
  12050. };
  12051. }
  12052. declare module "babylonjs/Sprites/spriteManager" {
  12053. import { IDisposable, Scene } from "babylonjs/scene";
  12054. import { Nullable } from "babylonjs/types";
  12055. import { Observable } from "babylonjs/Misc/observable";
  12056. import { Sprite } from "babylonjs/Sprites/sprite";
  12057. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12058. import { Camera } from "babylonjs/Cameras/camera";
  12059. import { Texture } from "babylonjs/Materials/Textures/texture";
  12060. import "babylonjs/Shaders/sprites.fragment";
  12061. import "babylonjs/Shaders/sprites.vertex";
  12062. import { Ray } from "babylonjs/Culling/ray";
  12063. /**
  12064. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12065. */
  12066. export interface ISpriteManager extends IDisposable {
  12067. /**
  12068. * Restricts the camera to viewing objects with the same layerMask.
  12069. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12070. */
  12071. layerMask: number;
  12072. /**
  12073. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12074. */
  12075. isPickable: boolean;
  12076. /**
  12077. * Specifies the rendering group id for this mesh (0 by default)
  12078. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12079. */
  12080. renderingGroupId: number;
  12081. /**
  12082. * Defines the list of sprites managed by the manager.
  12083. */
  12084. sprites: Array<Sprite>;
  12085. /**
  12086. * Tests the intersection of a sprite with a specific ray.
  12087. * @param ray The ray we are sending to test the collision
  12088. * @param camera The camera space we are sending rays in
  12089. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12090. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12091. * @returns picking info or null.
  12092. */
  12093. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12094. /**
  12095. * Renders the list of sprites on screen.
  12096. */
  12097. render(): void;
  12098. }
  12099. /**
  12100. * Class used to manage multiple sprites on the same spritesheet
  12101. * @see http://doc.babylonjs.com/babylon101/sprites
  12102. */
  12103. export class SpriteManager implements ISpriteManager {
  12104. /** defines the manager's name */
  12105. name: string;
  12106. /** Gets the list of sprites */
  12107. sprites: Sprite[];
  12108. /** Gets or sets the rendering group id (0 by default) */
  12109. renderingGroupId: number;
  12110. /** Gets or sets camera layer mask */
  12111. layerMask: number;
  12112. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12113. fogEnabled: boolean;
  12114. /** Gets or sets a boolean indicating if the sprites are pickable */
  12115. isPickable: boolean;
  12116. /** Defines the default width of a cell in the spritesheet */
  12117. cellWidth: number;
  12118. /** Defines the default height of a cell in the spritesheet */
  12119. cellHeight: number;
  12120. /**
  12121. * An event triggered when the manager is disposed.
  12122. */
  12123. onDisposeObservable: Observable<SpriteManager>;
  12124. private _onDisposeObserver;
  12125. /**
  12126. * Callback called when the manager is disposed
  12127. */
  12128. onDispose: () => void;
  12129. private _capacity;
  12130. private _spriteTexture;
  12131. private _epsilon;
  12132. private _scene;
  12133. private _vertexData;
  12134. private _buffer;
  12135. private _vertexBuffers;
  12136. private _indexBuffer;
  12137. private _effectBase;
  12138. private _effectFog;
  12139. /**
  12140. * Gets or sets the spritesheet texture
  12141. */
  12142. texture: Texture;
  12143. /**
  12144. * Creates a new sprite manager
  12145. * @param name defines the manager's name
  12146. * @param imgUrl defines the sprite sheet url
  12147. * @param capacity defines the maximum allowed number of sprites
  12148. * @param cellSize defines the size of a sprite cell
  12149. * @param scene defines the hosting scene
  12150. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12151. * @param samplingMode defines the smapling mode to use with spritesheet
  12152. */
  12153. constructor(
  12154. /** defines the manager's name */
  12155. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12156. private _appendSpriteVertex;
  12157. /**
  12158. * Intersects the sprites with a ray
  12159. * @param ray defines the ray to intersect with
  12160. * @param camera defines the current active camera
  12161. * @param predicate defines a predicate used to select candidate sprites
  12162. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12163. * @returns null if no hit or a PickingInfo
  12164. */
  12165. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12166. /**
  12167. * Render all child sprites
  12168. */
  12169. render(): void;
  12170. /**
  12171. * Release associated resources
  12172. */
  12173. dispose(): void;
  12174. }
  12175. }
  12176. declare module "babylonjs/Sprites/sprite" {
  12177. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12178. import { Nullable } from "babylonjs/types";
  12179. import { ActionManager } from "babylonjs/Actions/actionManager";
  12180. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12181. /**
  12182. * Class used to represent a sprite
  12183. * @see http://doc.babylonjs.com/babylon101/sprites
  12184. */
  12185. export class Sprite {
  12186. /** defines the name */
  12187. name: string;
  12188. /** Gets or sets the current world position */
  12189. position: Vector3;
  12190. /** Gets or sets the main color */
  12191. color: Color4;
  12192. /** Gets or sets the width */
  12193. width: number;
  12194. /** Gets or sets the height */
  12195. height: number;
  12196. /** Gets or sets rotation angle */
  12197. angle: number;
  12198. /** Gets or sets the cell index in the sprite sheet */
  12199. cellIndex: number;
  12200. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12201. invertU: number;
  12202. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12203. invertV: number;
  12204. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12205. disposeWhenFinishedAnimating: boolean;
  12206. /** Gets the list of attached animations */
  12207. animations: Animation[];
  12208. /** Gets or sets a boolean indicating if the sprite can be picked */
  12209. isPickable: boolean;
  12210. /**
  12211. * Gets or sets the associated action manager
  12212. */
  12213. actionManager: Nullable<ActionManager>;
  12214. private _animationStarted;
  12215. private _loopAnimation;
  12216. private _fromIndex;
  12217. private _toIndex;
  12218. private _delay;
  12219. private _direction;
  12220. private _manager;
  12221. private _time;
  12222. private _onAnimationEnd;
  12223. /**
  12224. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12225. */
  12226. isVisible: boolean;
  12227. /**
  12228. * Gets or sets the sprite size
  12229. */
  12230. size: number;
  12231. /**
  12232. * Creates a new Sprite
  12233. * @param name defines the name
  12234. * @param manager defines the manager
  12235. */
  12236. constructor(
  12237. /** defines the name */
  12238. name: string, manager: ISpriteManager);
  12239. /**
  12240. * Starts an animation
  12241. * @param from defines the initial key
  12242. * @param to defines the end key
  12243. * @param loop defines if the animation must loop
  12244. * @param delay defines the start delay (in ms)
  12245. * @param onAnimationEnd defines a callback to call when animation ends
  12246. */
  12247. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12248. /** Stops current animation (if any) */
  12249. stopAnimation(): void;
  12250. /** @hidden */
  12251. _animate(deltaTime: number): void;
  12252. /** Release associated resources */
  12253. dispose(): void;
  12254. }
  12255. }
  12256. declare module "babylonjs/Collisions/pickingInfo" {
  12257. import { Nullable } from "babylonjs/types";
  12258. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12260. import { Sprite } from "babylonjs/Sprites/sprite";
  12261. import { Ray } from "babylonjs/Culling/ray";
  12262. /**
  12263. * Information about the result of picking within a scene
  12264. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12265. */
  12266. export class PickingInfo {
  12267. /** @hidden */
  12268. _pickingUnavailable: boolean;
  12269. /**
  12270. * If the pick collided with an object
  12271. */
  12272. hit: boolean;
  12273. /**
  12274. * Distance away where the pick collided
  12275. */
  12276. distance: number;
  12277. /**
  12278. * The location of pick collision
  12279. */
  12280. pickedPoint: Nullable<Vector3>;
  12281. /**
  12282. * The mesh corresponding the the pick collision
  12283. */
  12284. pickedMesh: Nullable<AbstractMesh>;
  12285. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12286. bu: number;
  12287. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12288. bv: number;
  12289. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12290. faceId: number;
  12291. /** Id of the the submesh that was picked */
  12292. subMeshId: number;
  12293. /** If a sprite was picked, this will be the sprite the pick collided with */
  12294. pickedSprite: Nullable<Sprite>;
  12295. /**
  12296. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12297. */
  12298. originMesh: Nullable<AbstractMesh>;
  12299. /**
  12300. * The ray that was used to perform the picking.
  12301. */
  12302. ray: Nullable<Ray>;
  12303. /**
  12304. * Gets the normal correspodning to the face the pick collided with
  12305. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12306. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12307. * @returns The normal correspodning to the face the pick collided with
  12308. */
  12309. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12310. /**
  12311. * Gets the texture coordinates of where the pick occured
  12312. * @returns the vector containing the coordnates of the texture
  12313. */
  12314. getTextureCoordinates(): Nullable<Vector2>;
  12315. }
  12316. }
  12317. declare module "babylonjs/Events/pointerEvents" {
  12318. import { Nullable } from "babylonjs/types";
  12319. import { Vector2 } from "babylonjs/Maths/math";
  12320. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12321. import { Ray } from "babylonjs/Culling/ray";
  12322. /**
  12323. * Gather the list of pointer event types as constants.
  12324. */
  12325. export class PointerEventTypes {
  12326. /**
  12327. * 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.
  12328. */
  12329. static readonly POINTERDOWN: number;
  12330. /**
  12331. * The pointerup event is fired when a pointer is no longer active.
  12332. */
  12333. static readonly POINTERUP: number;
  12334. /**
  12335. * The pointermove event is fired when a pointer changes coordinates.
  12336. */
  12337. static readonly POINTERMOVE: number;
  12338. /**
  12339. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12340. */
  12341. static readonly POINTERWHEEL: number;
  12342. /**
  12343. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12344. */
  12345. static readonly POINTERPICK: number;
  12346. /**
  12347. * The pointertap event is fired when a the object has been touched and released without drag.
  12348. */
  12349. static readonly POINTERTAP: number;
  12350. /**
  12351. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12352. */
  12353. static readonly POINTERDOUBLETAP: number;
  12354. }
  12355. /**
  12356. * Base class of pointer info types.
  12357. */
  12358. export class PointerInfoBase {
  12359. /**
  12360. * Defines the type of event (PointerEventTypes)
  12361. */
  12362. type: number;
  12363. /**
  12364. * Defines the related dom event
  12365. */
  12366. event: PointerEvent | MouseWheelEvent;
  12367. /**
  12368. * Instantiates the base class of pointers info.
  12369. * @param type Defines the type of event (PointerEventTypes)
  12370. * @param event Defines the related dom event
  12371. */
  12372. constructor(
  12373. /**
  12374. * Defines the type of event (PointerEventTypes)
  12375. */
  12376. type: number,
  12377. /**
  12378. * Defines the related dom event
  12379. */
  12380. event: PointerEvent | MouseWheelEvent);
  12381. }
  12382. /**
  12383. * This class is used to store pointer related info for the onPrePointerObservable event.
  12384. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12385. */
  12386. export class PointerInfoPre extends PointerInfoBase {
  12387. /**
  12388. * Ray from a pointer if availible (eg. 6dof controller)
  12389. */
  12390. ray: Nullable<Ray>;
  12391. /**
  12392. * Defines the local position of the pointer on the canvas.
  12393. */
  12394. localPosition: Vector2;
  12395. /**
  12396. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12397. */
  12398. skipOnPointerObservable: boolean;
  12399. /**
  12400. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12401. * @param type Defines the type of event (PointerEventTypes)
  12402. * @param event Defines the related dom event
  12403. * @param localX Defines the local x coordinates of the pointer when the event occured
  12404. * @param localY Defines the local y coordinates of the pointer when the event occured
  12405. */
  12406. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12407. }
  12408. /**
  12409. * This type contains all the data related to a pointer event in Babylon.js.
  12410. * 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.
  12411. */
  12412. export class PointerInfo extends PointerInfoBase {
  12413. /**
  12414. * Defines the picking info associated to the info (if any)\
  12415. */
  12416. pickInfo: Nullable<PickingInfo>;
  12417. /**
  12418. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12419. * @param type Defines the type of event (PointerEventTypes)
  12420. * @param event Defines the related dom event
  12421. * @param pickInfo Defines the picking info associated to the info (if any)\
  12422. */
  12423. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12424. /**
  12425. * Defines the picking info associated to the info (if any)\
  12426. */
  12427. pickInfo: Nullable<PickingInfo>);
  12428. }
  12429. /**
  12430. * Data relating to a touch event on the screen.
  12431. */
  12432. export interface PointerTouch {
  12433. /**
  12434. * X coordinate of touch.
  12435. */
  12436. x: number;
  12437. /**
  12438. * Y coordinate of touch.
  12439. */
  12440. y: number;
  12441. /**
  12442. * Id of touch. Unique for each finger.
  12443. */
  12444. pointerId: number;
  12445. /**
  12446. * Event type passed from DOM.
  12447. */
  12448. type: any;
  12449. }
  12450. }
  12451. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12452. import { Observable } from "babylonjs/Misc/observable";
  12453. import { Nullable } from "babylonjs/types";
  12454. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12455. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12456. /**
  12457. * Manage the mouse inputs to control the movement of a free camera.
  12458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12459. */
  12460. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12461. /**
  12462. * Define if touch is enabled in the mouse input
  12463. */
  12464. touchEnabled: boolean;
  12465. /**
  12466. * Defines the camera the input is attached to.
  12467. */
  12468. camera: FreeCamera;
  12469. /**
  12470. * Defines the buttons associated with the input to handle camera move.
  12471. */
  12472. buttons: number[];
  12473. /**
  12474. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12475. */
  12476. angularSensibility: number;
  12477. private _pointerInput;
  12478. private _onMouseMove;
  12479. private _observer;
  12480. private previousPosition;
  12481. /**
  12482. * Observable for when a pointer move event occurs containing the move offset
  12483. */
  12484. onPointerMovedObservable: Observable<{
  12485. offsetX: number;
  12486. offsetY: number;
  12487. }>;
  12488. /**
  12489. * @hidden
  12490. * If the camera should be rotated automatically based on pointer movement
  12491. */
  12492. _allowCameraRotation: boolean;
  12493. /**
  12494. * Manage the mouse inputs to control the movement of a free camera.
  12495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12496. * @param touchEnabled Defines if touch is enabled or not
  12497. */
  12498. constructor(
  12499. /**
  12500. * Define if touch is enabled in the mouse input
  12501. */
  12502. touchEnabled?: boolean);
  12503. /**
  12504. * Attach the input controls to a specific dom element to get the input from.
  12505. * @param element Defines the element the controls should be listened from
  12506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12507. */
  12508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12509. /**
  12510. * Called on JS contextmenu event.
  12511. * Override this method to provide functionality.
  12512. */
  12513. protected onContextMenu(evt: PointerEvent): void;
  12514. /**
  12515. * Detach the current controls from the specified dom element.
  12516. * @param element Defines the element to stop listening the inputs from
  12517. */
  12518. detachControl(element: Nullable<HTMLElement>): void;
  12519. /**
  12520. * Gets the class name of the current intput.
  12521. * @returns the class name
  12522. */
  12523. getClassName(): string;
  12524. /**
  12525. * Get the friendly name associated with the input class.
  12526. * @returns the input friendly name
  12527. */
  12528. getSimpleName(): string;
  12529. }
  12530. }
  12531. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12532. import { Nullable } from "babylonjs/types";
  12533. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12534. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12535. /**
  12536. * Manage the touch inputs to control the movement of a free camera.
  12537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12538. */
  12539. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12540. /**
  12541. * Defines the camera the input is attached to.
  12542. */
  12543. camera: FreeCamera;
  12544. /**
  12545. * Defines the touch sensibility for rotation.
  12546. * The higher the faster.
  12547. */
  12548. touchAngularSensibility: number;
  12549. /**
  12550. * Defines the touch sensibility for move.
  12551. * The higher the faster.
  12552. */
  12553. touchMoveSensibility: number;
  12554. private _offsetX;
  12555. private _offsetY;
  12556. private _pointerPressed;
  12557. private _pointerInput;
  12558. private _observer;
  12559. private _onLostFocus;
  12560. /**
  12561. * Attach the input controls to a specific dom element to get the input from.
  12562. * @param element Defines the element the controls should be listened from
  12563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12564. */
  12565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12566. /**
  12567. * Detach the current controls from the specified dom element.
  12568. * @param element Defines the element to stop listening the inputs from
  12569. */
  12570. detachControl(element: Nullable<HTMLElement>): void;
  12571. /**
  12572. * Update the current camera state depending on the inputs that have been used this frame.
  12573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12574. */
  12575. checkInputs(): void;
  12576. /**
  12577. * Gets the class name of the current intput.
  12578. * @returns the class name
  12579. */
  12580. getClassName(): string;
  12581. /**
  12582. * Get the friendly name associated with the input class.
  12583. * @returns the input friendly name
  12584. */
  12585. getSimpleName(): string;
  12586. }
  12587. }
  12588. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12589. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12590. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12591. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12592. import { Nullable } from "babylonjs/types";
  12593. /**
  12594. * Default Inputs manager for the FreeCamera.
  12595. * It groups all the default supported inputs for ease of use.
  12596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12597. */
  12598. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12599. /**
  12600. * @hidden
  12601. */
  12602. _mouseInput: Nullable<FreeCameraMouseInput>;
  12603. /**
  12604. * Instantiates a new FreeCameraInputsManager.
  12605. * @param camera Defines the camera the inputs belong to
  12606. */
  12607. constructor(camera: FreeCamera);
  12608. /**
  12609. * Add keyboard input support to the input manager.
  12610. * @returns the current input manager
  12611. */
  12612. addKeyboard(): FreeCameraInputsManager;
  12613. /**
  12614. * Add mouse input support to the input manager.
  12615. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12616. * @returns the current input manager
  12617. */
  12618. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12619. /**
  12620. * Removes the mouse input support from the manager
  12621. * @returns the current input manager
  12622. */
  12623. removeMouse(): FreeCameraInputsManager;
  12624. /**
  12625. * Add touch input support to the input manager.
  12626. * @returns the current input manager
  12627. */
  12628. addTouch(): FreeCameraInputsManager;
  12629. /**
  12630. * Remove all attached input methods from a camera
  12631. */
  12632. clear(): void;
  12633. }
  12634. }
  12635. declare module "babylonjs/Cameras/freeCamera" {
  12636. import { Vector3 } from "babylonjs/Maths/math";
  12637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12638. import { Scene } from "babylonjs/scene";
  12639. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12640. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12641. /**
  12642. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12643. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12644. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12645. */
  12646. export class FreeCamera extends TargetCamera {
  12647. /**
  12648. * Define the collision ellipsoid of the camera.
  12649. * This is helpful to simulate a camera body like the player body around the camera
  12650. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12651. */
  12652. ellipsoid: Vector3;
  12653. /**
  12654. * Define an offset for the position of the ellipsoid around the camera.
  12655. * This can be helpful to determine the center of the body near the gravity center of the body
  12656. * instead of its head.
  12657. */
  12658. ellipsoidOffset: Vector3;
  12659. /**
  12660. * Enable or disable collisions of the camera with the rest of the scene objects.
  12661. */
  12662. checkCollisions: boolean;
  12663. /**
  12664. * Enable or disable gravity on the camera.
  12665. */
  12666. applyGravity: boolean;
  12667. /**
  12668. * Define the input manager associated to the camera.
  12669. */
  12670. inputs: FreeCameraInputsManager;
  12671. /**
  12672. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12673. * Higher values reduce sensitivity.
  12674. */
  12675. /**
  12676. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12677. * Higher values reduce sensitivity.
  12678. */
  12679. angularSensibility: number;
  12680. /**
  12681. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12682. */
  12683. keysUp: number[];
  12684. /**
  12685. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12686. */
  12687. keysDown: number[];
  12688. /**
  12689. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12690. */
  12691. keysLeft: number[];
  12692. /**
  12693. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12694. */
  12695. keysRight: number[];
  12696. /**
  12697. * Event raised when the camera collide with a mesh in the scene.
  12698. */
  12699. onCollide: (collidedMesh: AbstractMesh) => void;
  12700. private _collider;
  12701. private _needMoveForGravity;
  12702. private _oldPosition;
  12703. private _diffPosition;
  12704. private _newPosition;
  12705. /** @hidden */
  12706. _localDirection: Vector3;
  12707. /** @hidden */
  12708. _transformedDirection: Vector3;
  12709. /**
  12710. * Instantiates a Free Camera.
  12711. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12712. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12713. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12714. * @param name Define the name of the camera in the scene
  12715. * @param position Define the start position of the camera in the scene
  12716. * @param scene Define the scene the camera belongs to
  12717. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12718. */
  12719. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12720. /**
  12721. * Attached controls to the current camera.
  12722. * @param element Defines the element the controls should be listened from
  12723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12724. */
  12725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12726. /**
  12727. * Detach the current controls from the camera.
  12728. * The camera will stop reacting to inputs.
  12729. * @param element Defines the element to stop listening the inputs from
  12730. */
  12731. detachControl(element: HTMLElement): void;
  12732. private _collisionMask;
  12733. /**
  12734. * Define a collision mask to limit the list of object the camera can collide with
  12735. */
  12736. collisionMask: number;
  12737. /** @hidden */
  12738. _collideWithWorld(displacement: Vector3): void;
  12739. private _onCollisionPositionChange;
  12740. /** @hidden */
  12741. _checkInputs(): void;
  12742. /** @hidden */
  12743. _decideIfNeedsToMove(): boolean;
  12744. /** @hidden */
  12745. _updatePosition(): void;
  12746. /**
  12747. * Destroy the camera and release the current resources hold by it.
  12748. */
  12749. dispose(): void;
  12750. /**
  12751. * Gets the current object class name.
  12752. * @return the class name
  12753. */
  12754. getClassName(): string;
  12755. }
  12756. }
  12757. declare module "babylonjs/Gamepads/gamepad" {
  12758. import { Observable } from "babylonjs/Misc/observable";
  12759. /**
  12760. * Represents a gamepad control stick position
  12761. */
  12762. export class StickValues {
  12763. /**
  12764. * The x component of the control stick
  12765. */
  12766. x: number;
  12767. /**
  12768. * The y component of the control stick
  12769. */
  12770. y: number;
  12771. /**
  12772. * Initializes the gamepad x and y control stick values
  12773. * @param x The x component of the gamepad control stick value
  12774. * @param y The y component of the gamepad control stick value
  12775. */
  12776. constructor(
  12777. /**
  12778. * The x component of the control stick
  12779. */
  12780. x: number,
  12781. /**
  12782. * The y component of the control stick
  12783. */
  12784. y: number);
  12785. }
  12786. /**
  12787. * An interface which manages callbacks for gamepad button changes
  12788. */
  12789. export interface GamepadButtonChanges {
  12790. /**
  12791. * Called when a gamepad has been changed
  12792. */
  12793. changed: boolean;
  12794. /**
  12795. * Called when a gamepad press event has been triggered
  12796. */
  12797. pressChanged: boolean;
  12798. /**
  12799. * Called when a touch event has been triggered
  12800. */
  12801. touchChanged: boolean;
  12802. /**
  12803. * Called when a value has changed
  12804. */
  12805. valueChanged: boolean;
  12806. }
  12807. /**
  12808. * Represents a gamepad
  12809. */
  12810. export class Gamepad {
  12811. /**
  12812. * The id of the gamepad
  12813. */
  12814. id: string;
  12815. /**
  12816. * The index of the gamepad
  12817. */
  12818. index: number;
  12819. /**
  12820. * The browser gamepad
  12821. */
  12822. browserGamepad: any;
  12823. /**
  12824. * Specifies what type of gamepad this represents
  12825. */
  12826. type: number;
  12827. private _leftStick;
  12828. private _rightStick;
  12829. /** @hidden */
  12830. _isConnected: boolean;
  12831. private _leftStickAxisX;
  12832. private _leftStickAxisY;
  12833. private _rightStickAxisX;
  12834. private _rightStickAxisY;
  12835. /**
  12836. * Triggered when the left control stick has been changed
  12837. */
  12838. private _onleftstickchanged;
  12839. /**
  12840. * Triggered when the right control stick has been changed
  12841. */
  12842. private _onrightstickchanged;
  12843. /**
  12844. * Represents a gamepad controller
  12845. */
  12846. static GAMEPAD: number;
  12847. /**
  12848. * Represents a generic controller
  12849. */
  12850. static GENERIC: number;
  12851. /**
  12852. * Represents an XBox controller
  12853. */
  12854. static XBOX: number;
  12855. /**
  12856. * Represents a pose-enabled controller
  12857. */
  12858. static POSE_ENABLED: number;
  12859. /**
  12860. * Specifies whether the left control stick should be Y-inverted
  12861. */
  12862. protected _invertLeftStickY: boolean;
  12863. /**
  12864. * Specifies if the gamepad has been connected
  12865. */
  12866. readonly isConnected: boolean;
  12867. /**
  12868. * Initializes the gamepad
  12869. * @param id The id of the gamepad
  12870. * @param index The index of the gamepad
  12871. * @param browserGamepad The browser gamepad
  12872. * @param leftStickX The x component of the left joystick
  12873. * @param leftStickY The y component of the left joystick
  12874. * @param rightStickX The x component of the right joystick
  12875. * @param rightStickY The y component of the right joystick
  12876. */
  12877. constructor(
  12878. /**
  12879. * The id of the gamepad
  12880. */
  12881. id: string,
  12882. /**
  12883. * The index of the gamepad
  12884. */
  12885. index: number,
  12886. /**
  12887. * The browser gamepad
  12888. */
  12889. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12890. /**
  12891. * Callback triggered when the left joystick has changed
  12892. * @param callback
  12893. */
  12894. onleftstickchanged(callback: (values: StickValues) => void): void;
  12895. /**
  12896. * Callback triggered when the right joystick has changed
  12897. * @param callback
  12898. */
  12899. onrightstickchanged(callback: (values: StickValues) => void): void;
  12900. /**
  12901. * Gets the left joystick
  12902. */
  12903. /**
  12904. * Sets the left joystick values
  12905. */
  12906. leftStick: StickValues;
  12907. /**
  12908. * Gets the right joystick
  12909. */
  12910. /**
  12911. * Sets the right joystick value
  12912. */
  12913. rightStick: StickValues;
  12914. /**
  12915. * Updates the gamepad joystick positions
  12916. */
  12917. update(): void;
  12918. /**
  12919. * Disposes the gamepad
  12920. */
  12921. dispose(): void;
  12922. }
  12923. /**
  12924. * Represents a generic gamepad
  12925. */
  12926. export class GenericPad extends Gamepad {
  12927. private _buttons;
  12928. private _onbuttondown;
  12929. private _onbuttonup;
  12930. /**
  12931. * Observable triggered when a button has been pressed
  12932. */
  12933. onButtonDownObservable: Observable<number>;
  12934. /**
  12935. * Observable triggered when a button has been released
  12936. */
  12937. onButtonUpObservable: Observable<number>;
  12938. /**
  12939. * Callback triggered when a button has been pressed
  12940. * @param callback Called when a button has been pressed
  12941. */
  12942. onbuttondown(callback: (buttonPressed: number) => void): void;
  12943. /**
  12944. * Callback triggered when a button has been released
  12945. * @param callback Called when a button has been released
  12946. */
  12947. onbuttonup(callback: (buttonReleased: number) => void): void;
  12948. /**
  12949. * Initializes the generic gamepad
  12950. * @param id The id of the generic gamepad
  12951. * @param index The index of the generic gamepad
  12952. * @param browserGamepad The browser gamepad
  12953. */
  12954. constructor(id: string, index: number, browserGamepad: any);
  12955. private _setButtonValue;
  12956. /**
  12957. * Updates the generic gamepad
  12958. */
  12959. update(): void;
  12960. /**
  12961. * Disposes the generic gamepad
  12962. */
  12963. dispose(): void;
  12964. }
  12965. }
  12966. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12967. import { Observable } from "babylonjs/Misc/observable";
  12968. import { Nullable } from "babylonjs/types";
  12969. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12970. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12972. import { Ray } from "babylonjs/Culling/ray";
  12973. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12974. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12975. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12976. /**
  12977. * Defines the types of pose enabled controllers that are supported
  12978. */
  12979. export enum PoseEnabledControllerType {
  12980. /**
  12981. * HTC Vive
  12982. */
  12983. VIVE = 0,
  12984. /**
  12985. * Oculus Rift
  12986. */
  12987. OCULUS = 1,
  12988. /**
  12989. * Windows mixed reality
  12990. */
  12991. WINDOWS = 2,
  12992. /**
  12993. * Samsung gear VR
  12994. */
  12995. GEAR_VR = 3,
  12996. /**
  12997. * Google Daydream
  12998. */
  12999. DAYDREAM = 4,
  13000. /**
  13001. * Generic
  13002. */
  13003. GENERIC = 5
  13004. }
  13005. /**
  13006. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13007. */
  13008. export interface MutableGamepadButton {
  13009. /**
  13010. * Value of the button/trigger
  13011. */
  13012. value: number;
  13013. /**
  13014. * If the button/trigger is currently touched
  13015. */
  13016. touched: boolean;
  13017. /**
  13018. * If the button/trigger is currently pressed
  13019. */
  13020. pressed: boolean;
  13021. }
  13022. /**
  13023. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13024. * @hidden
  13025. */
  13026. export interface ExtendedGamepadButton extends GamepadButton {
  13027. /**
  13028. * If the button/trigger is currently pressed
  13029. */
  13030. readonly pressed: boolean;
  13031. /**
  13032. * If the button/trigger is currently touched
  13033. */
  13034. readonly touched: boolean;
  13035. /**
  13036. * Value of the button/trigger
  13037. */
  13038. readonly value: number;
  13039. }
  13040. /** @hidden */
  13041. export interface _GamePadFactory {
  13042. /**
  13043. * Returns wether or not the current gamepad can be created for this type of controller.
  13044. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13045. * @returns true if it can be created, otherwise false
  13046. */
  13047. canCreate(gamepadInfo: any): boolean;
  13048. /**
  13049. * Creates a new instance of the Gamepad.
  13050. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13051. * @returns the new gamepad instance
  13052. */
  13053. create(gamepadInfo: any): Gamepad;
  13054. }
  13055. /**
  13056. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13057. */
  13058. export class PoseEnabledControllerHelper {
  13059. /** @hidden */
  13060. static _ControllerFactories: _GamePadFactory[];
  13061. /** @hidden */
  13062. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13063. /**
  13064. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13065. * @param vrGamepad the gamepad to initialized
  13066. * @returns a vr controller of the type the gamepad identified as
  13067. */
  13068. static InitiateController(vrGamepad: any): Gamepad;
  13069. }
  13070. /**
  13071. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13072. */
  13073. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13074. private _deviceRoomPosition;
  13075. private _deviceRoomRotationQuaternion;
  13076. /**
  13077. * The device position in babylon space
  13078. */
  13079. devicePosition: Vector3;
  13080. /**
  13081. * The device rotation in babylon space
  13082. */
  13083. deviceRotationQuaternion: Quaternion;
  13084. /**
  13085. * The scale factor of the device in babylon space
  13086. */
  13087. deviceScaleFactor: number;
  13088. /**
  13089. * (Likely devicePosition should be used instead) The device position in its room space
  13090. */
  13091. position: Vector3;
  13092. /**
  13093. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13094. */
  13095. rotationQuaternion: Quaternion;
  13096. /**
  13097. * The type of controller (Eg. Windows mixed reality)
  13098. */
  13099. controllerType: PoseEnabledControllerType;
  13100. protected _calculatedPosition: Vector3;
  13101. private _calculatedRotation;
  13102. /**
  13103. * The raw pose from the device
  13104. */
  13105. rawPose: DevicePose;
  13106. private _trackPosition;
  13107. private _maxRotationDistFromHeadset;
  13108. private _draggedRoomRotation;
  13109. /**
  13110. * @hidden
  13111. */
  13112. _disableTrackPosition(fixedPosition: Vector3): void;
  13113. /**
  13114. * Internal, the mesh attached to the controller
  13115. * @hidden
  13116. */
  13117. _mesh: Nullable<AbstractMesh>;
  13118. private _poseControlledCamera;
  13119. private _leftHandSystemQuaternion;
  13120. /**
  13121. * Internal, matrix used to convert room space to babylon space
  13122. * @hidden
  13123. */
  13124. _deviceToWorld: Matrix;
  13125. /**
  13126. * Node to be used when casting a ray from the controller
  13127. * @hidden
  13128. */
  13129. _pointingPoseNode: Nullable<TransformNode>;
  13130. /**
  13131. * Name of the child mesh that can be used to cast a ray from the controller
  13132. */
  13133. static readonly POINTING_POSE: string;
  13134. /**
  13135. * Creates a new PoseEnabledController from a gamepad
  13136. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13137. */
  13138. constructor(browserGamepad: any);
  13139. private _workingMatrix;
  13140. /**
  13141. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13142. */
  13143. update(): void;
  13144. /**
  13145. * Updates only the pose device and mesh without doing any button event checking
  13146. */
  13147. protected _updatePoseAndMesh(): void;
  13148. /**
  13149. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13150. * @param poseData raw pose fromthe device
  13151. */
  13152. updateFromDevice(poseData: DevicePose): void;
  13153. /**
  13154. * @hidden
  13155. */
  13156. _meshAttachedObservable: Observable<AbstractMesh>;
  13157. /**
  13158. * Attaches a mesh to the controller
  13159. * @param mesh the mesh to be attached
  13160. */
  13161. attachToMesh(mesh: AbstractMesh): void;
  13162. /**
  13163. * Attaches the controllers mesh to a camera
  13164. * @param camera the camera the mesh should be attached to
  13165. */
  13166. attachToPoseControlledCamera(camera: TargetCamera): void;
  13167. /**
  13168. * Disposes of the controller
  13169. */
  13170. dispose(): void;
  13171. /**
  13172. * The mesh that is attached to the controller
  13173. */
  13174. readonly mesh: Nullable<AbstractMesh>;
  13175. /**
  13176. * Gets the ray of the controller in the direction the controller is pointing
  13177. * @param length the length the resulting ray should be
  13178. * @returns a ray in the direction the controller is pointing
  13179. */
  13180. getForwardRay(length?: number): Ray;
  13181. }
  13182. }
  13183. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13184. import { Observable } from "babylonjs/Misc/observable";
  13185. import { Scene } from "babylonjs/scene";
  13186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13187. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13188. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13189. /**
  13190. * Defines the WebVRController object that represents controllers tracked in 3D space
  13191. */
  13192. export abstract class WebVRController extends PoseEnabledController {
  13193. /**
  13194. * Internal, the default controller model for the controller
  13195. */
  13196. protected _defaultModel: AbstractMesh;
  13197. /**
  13198. * Fired when the trigger state has changed
  13199. */
  13200. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13201. /**
  13202. * Fired when the main button state has changed
  13203. */
  13204. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13205. /**
  13206. * Fired when the secondary button state has changed
  13207. */
  13208. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13209. /**
  13210. * Fired when the pad state has changed
  13211. */
  13212. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13213. /**
  13214. * Fired when controllers stick values have changed
  13215. */
  13216. onPadValuesChangedObservable: Observable<StickValues>;
  13217. /**
  13218. * Array of button availible on the controller
  13219. */
  13220. protected _buttons: Array<MutableGamepadButton>;
  13221. private _onButtonStateChange;
  13222. /**
  13223. * Fired when a controller button's state has changed
  13224. * @param callback the callback containing the button that was modified
  13225. */
  13226. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13227. /**
  13228. * X and Y axis corrisponding to the controllers joystick
  13229. */
  13230. pad: StickValues;
  13231. /**
  13232. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13233. */
  13234. hand: string;
  13235. /**
  13236. * The default controller model for the controller
  13237. */
  13238. readonly defaultModel: AbstractMesh;
  13239. /**
  13240. * Creates a new WebVRController from a gamepad
  13241. * @param vrGamepad the gamepad that the WebVRController should be created from
  13242. */
  13243. constructor(vrGamepad: any);
  13244. /**
  13245. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13246. */
  13247. update(): void;
  13248. /**
  13249. * Function to be called when a button is modified
  13250. */
  13251. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13252. /**
  13253. * Loads a mesh and attaches it to the controller
  13254. * @param scene the scene the mesh should be added to
  13255. * @param meshLoaded callback for when the mesh has been loaded
  13256. */
  13257. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13258. private _setButtonValue;
  13259. private _changes;
  13260. private _checkChanges;
  13261. /**
  13262. * Disposes of th webVRCOntroller
  13263. */
  13264. dispose(): void;
  13265. }
  13266. }
  13267. declare module "babylonjs/Lights/hemisphericLight" {
  13268. import { Nullable } from "babylonjs/types";
  13269. import { Scene } from "babylonjs/scene";
  13270. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13271. import { Effect } from "babylonjs/Materials/effect";
  13272. import { Light } from "babylonjs/Lights/light";
  13273. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13274. /**
  13275. * The HemisphericLight simulates the ambient environment light,
  13276. * so the passed direction is the light reflection direction, not the incoming direction.
  13277. */
  13278. export class HemisphericLight extends Light {
  13279. /**
  13280. * The groundColor is the light in the opposite direction to the one specified during creation.
  13281. * 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.
  13282. */
  13283. groundColor: Color3;
  13284. /**
  13285. * The light reflection direction, not the incoming direction.
  13286. */
  13287. direction: Vector3;
  13288. /**
  13289. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13290. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13291. * The HemisphericLight can't cast shadows.
  13292. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13293. * @param name The friendly name of the light
  13294. * @param direction The direction of the light reflection
  13295. * @param scene The scene the light belongs to
  13296. */
  13297. constructor(name: string, direction: Vector3, scene: Scene);
  13298. protected _buildUniformLayout(): void;
  13299. /**
  13300. * Returns the string "HemisphericLight".
  13301. * @return The class name
  13302. */
  13303. getClassName(): string;
  13304. /**
  13305. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13306. * Returns the updated direction.
  13307. * @param target The target the direction should point to
  13308. * @return The computed direction
  13309. */
  13310. setDirectionToTarget(target: Vector3): Vector3;
  13311. /**
  13312. * Returns the shadow generator associated to the light.
  13313. * @returns Always null for hemispheric lights because it does not support shadows.
  13314. */
  13315. getShadowGenerator(): Nullable<IShadowGenerator>;
  13316. /**
  13317. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13318. * @param effect The effect to update
  13319. * @param lightIndex The index of the light in the effect to update
  13320. * @returns The hemispheric light
  13321. */
  13322. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13323. /**
  13324. * Computes the world matrix of the node
  13325. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13326. * @param useWasUpdatedFlag defines a reserved property
  13327. * @returns the world matrix
  13328. */
  13329. computeWorldMatrix(): Matrix;
  13330. /**
  13331. * Returns the integer 3.
  13332. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13333. */
  13334. getTypeID(): number;
  13335. /**
  13336. * Prepares the list of defines specific to the light type.
  13337. * @param defines the list of defines
  13338. * @param lightIndex defines the index of the light for the effect
  13339. */
  13340. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13341. }
  13342. }
  13343. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13344. /** @hidden */
  13345. export var vrMultiviewToSingleviewPixelShader: {
  13346. name: string;
  13347. shader: string;
  13348. };
  13349. }
  13350. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13351. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13352. import { Scene } from "babylonjs/scene";
  13353. /**
  13354. * Renders to multiple views with a single draw call
  13355. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13356. */
  13357. export class MultiviewRenderTarget extends RenderTargetTexture {
  13358. /**
  13359. * Creates a multiview render target
  13360. * @param scene scene used with the render target
  13361. * @param size the size of the render target (used for each view)
  13362. */
  13363. constructor(scene: Scene, size?: number | {
  13364. width: number;
  13365. height: number;
  13366. } | {
  13367. ratio: number;
  13368. });
  13369. /**
  13370. * @hidden
  13371. * @param faceIndex the face index, if its a cube texture
  13372. */
  13373. _bindFrameBuffer(faceIndex?: number): void;
  13374. /**
  13375. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13376. * @returns the view count
  13377. */
  13378. getViewCount(): number;
  13379. }
  13380. }
  13381. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13382. import { Camera } from "babylonjs/Cameras/camera";
  13383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13384. import { Nullable } from "babylonjs/types";
  13385. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13386. import { Matrix } from "babylonjs/Maths/math";
  13387. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13388. module "babylonjs/Engines/engine" {
  13389. interface Engine {
  13390. /**
  13391. * Creates a new multiview render target
  13392. * @param width defines the width of the texture
  13393. * @param height defines the height of the texture
  13394. * @returns the created multiview texture
  13395. */
  13396. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13397. /**
  13398. * Binds a multiview framebuffer to be drawn to
  13399. * @param multiviewTexture texture to bind
  13400. */
  13401. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13402. }
  13403. }
  13404. module "babylonjs/Cameras/camera" {
  13405. interface Camera {
  13406. /**
  13407. * @hidden
  13408. * 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)
  13409. */
  13410. _useMultiviewToSingleView: boolean;
  13411. /**
  13412. * @hidden
  13413. * 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)
  13414. */
  13415. _multiviewTexture: Nullable<RenderTargetTexture>;
  13416. /**
  13417. * @hidden
  13418. * ensures the multiview texture of the camera exists and has the specified width/height
  13419. * @param width height to set on the multiview texture
  13420. * @param height width to set on the multiview texture
  13421. */
  13422. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13423. }
  13424. }
  13425. module "babylonjs/scene" {
  13426. interface Scene {
  13427. /** @hidden */
  13428. _transformMatrixR: Matrix;
  13429. /** @hidden */
  13430. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13431. /** @hidden */
  13432. _createMultiviewUbo(): void;
  13433. /** @hidden */
  13434. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13435. /** @hidden */
  13436. _renderMultiviewToSingleView(camera: Camera): void;
  13437. }
  13438. }
  13439. }
  13440. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13441. import { Camera } from "babylonjs/Cameras/camera";
  13442. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13443. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13444. import "babylonjs/Engines/Extensions/engine.multiview";
  13445. /**
  13446. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13447. * This will not be used for webXR as it supports displaying texture arrays directly
  13448. */
  13449. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13450. /**
  13451. * Initializes a VRMultiviewToSingleview
  13452. * @param name name of the post process
  13453. * @param camera camera to be applied to
  13454. * @param scaleFactor scaling factor to the size of the output texture
  13455. */
  13456. constructor(name: string, camera: Camera, scaleFactor: number);
  13457. }
  13458. }
  13459. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13460. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13461. import { Nullable } from "babylonjs/types";
  13462. import { Size } from "babylonjs/Maths/math";
  13463. import { Observable } from "babylonjs/Misc/observable";
  13464. module "babylonjs/Engines/engine" {
  13465. /**
  13466. * Defines the interface used by display changed events
  13467. */
  13468. interface IDisplayChangedEventArgs {
  13469. /** Gets the vrDisplay object (if any) */
  13470. vrDisplay: Nullable<any>;
  13471. /** Gets a boolean indicating if webVR is supported */
  13472. vrSupported: boolean;
  13473. }
  13474. interface Engine {
  13475. /** @hidden */
  13476. _vrDisplay: any;
  13477. /** @hidden */
  13478. _vrSupported: boolean;
  13479. /** @hidden */
  13480. _oldSize: Size;
  13481. /** @hidden */
  13482. _oldHardwareScaleFactor: number;
  13483. /** @hidden */
  13484. _vrExclusivePointerMode: boolean;
  13485. /** @hidden */
  13486. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13487. /** @hidden */
  13488. _onVRDisplayPointerRestricted: () => void;
  13489. /** @hidden */
  13490. _onVRDisplayPointerUnrestricted: () => void;
  13491. /** @hidden */
  13492. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13493. /** @hidden */
  13494. _onVrDisplayDisconnect: Nullable<() => void>;
  13495. /** @hidden */
  13496. _onVrDisplayPresentChange: Nullable<() => void>;
  13497. /**
  13498. * Observable signaled when VR display mode changes
  13499. */
  13500. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13501. /**
  13502. * Observable signaled when VR request present is complete
  13503. */
  13504. onVRRequestPresentComplete: Observable<boolean>;
  13505. /**
  13506. * Observable signaled when VR request present starts
  13507. */
  13508. onVRRequestPresentStart: Observable<Engine>;
  13509. /**
  13510. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13511. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13512. */
  13513. isInVRExclusivePointerMode: boolean;
  13514. /**
  13515. * Gets a boolean indicating if a webVR device was detected
  13516. * @returns true if a webVR device was detected
  13517. */
  13518. isVRDevicePresent(): boolean;
  13519. /**
  13520. * Gets the current webVR device
  13521. * @returns the current webVR device (or null)
  13522. */
  13523. getVRDevice(): any;
  13524. /**
  13525. * Initializes a webVR display and starts listening to display change events
  13526. * The onVRDisplayChangedObservable will be notified upon these changes
  13527. * @returns A promise containing a VRDisplay and if vr is supported
  13528. */
  13529. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13530. /** @hidden */
  13531. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13532. /**
  13533. * Call this function to switch to webVR mode
  13534. * Will do nothing if webVR is not supported or if there is no webVR device
  13535. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13536. */
  13537. enableVR(): void;
  13538. /** @hidden */
  13539. _onVRFullScreenTriggered(): void;
  13540. }
  13541. }
  13542. }
  13543. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13544. import { Nullable } from "babylonjs/types";
  13545. import { Observable } from "babylonjs/Misc/observable";
  13546. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13547. import { Scene } from "babylonjs/scene";
  13548. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13549. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13550. import { Node } from "babylonjs/node";
  13551. import { Ray } from "babylonjs/Culling/ray";
  13552. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13553. import "babylonjs/Engines/Extensions/engine.webVR";
  13554. /**
  13555. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13556. * IMPORTANT!! The data is right-hand data.
  13557. * @export
  13558. * @interface DevicePose
  13559. */
  13560. export interface DevicePose {
  13561. /**
  13562. * The position of the device, values in array are [x,y,z].
  13563. */
  13564. readonly position: Nullable<Float32Array>;
  13565. /**
  13566. * The linearVelocity of the device, values in array are [x,y,z].
  13567. */
  13568. readonly linearVelocity: Nullable<Float32Array>;
  13569. /**
  13570. * The linearAcceleration of the device, values in array are [x,y,z].
  13571. */
  13572. readonly linearAcceleration: Nullable<Float32Array>;
  13573. /**
  13574. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13575. */
  13576. readonly orientation: Nullable<Float32Array>;
  13577. /**
  13578. * The angularVelocity of the device, values in array are [x,y,z].
  13579. */
  13580. readonly angularVelocity: Nullable<Float32Array>;
  13581. /**
  13582. * The angularAcceleration of the device, values in array are [x,y,z].
  13583. */
  13584. readonly angularAcceleration: Nullable<Float32Array>;
  13585. }
  13586. /**
  13587. * Interface representing a pose controlled object in Babylon.
  13588. * A pose controlled object has both regular pose values as well as pose values
  13589. * from an external device such as a VR head mounted display
  13590. */
  13591. export interface PoseControlled {
  13592. /**
  13593. * The position of the object in babylon space.
  13594. */
  13595. position: Vector3;
  13596. /**
  13597. * The rotation quaternion of the object in babylon space.
  13598. */
  13599. rotationQuaternion: Quaternion;
  13600. /**
  13601. * The position of the device in babylon space.
  13602. */
  13603. devicePosition?: Vector3;
  13604. /**
  13605. * The rotation quaternion of the device in babylon space.
  13606. */
  13607. deviceRotationQuaternion: Quaternion;
  13608. /**
  13609. * The raw pose coming from the device.
  13610. */
  13611. rawPose: Nullable<DevicePose>;
  13612. /**
  13613. * The scale of the device to be used when translating from device space to babylon space.
  13614. */
  13615. deviceScaleFactor: number;
  13616. /**
  13617. * Updates the poseControlled values based on the input device pose.
  13618. * @param poseData the pose data to update the object with
  13619. */
  13620. updateFromDevice(poseData: DevicePose): void;
  13621. }
  13622. /**
  13623. * Set of options to customize the webVRCamera
  13624. */
  13625. export interface WebVROptions {
  13626. /**
  13627. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13628. */
  13629. trackPosition?: boolean;
  13630. /**
  13631. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13632. */
  13633. positionScale?: number;
  13634. /**
  13635. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13636. */
  13637. displayName?: string;
  13638. /**
  13639. * Should the native controller meshes be initialized. (default: true)
  13640. */
  13641. controllerMeshes?: boolean;
  13642. /**
  13643. * Creating a default HemiLight only on controllers. (default: true)
  13644. */
  13645. defaultLightingOnControllers?: boolean;
  13646. /**
  13647. * If you don't want to use the default VR button of the helper. (default: false)
  13648. */
  13649. useCustomVRButton?: boolean;
  13650. /**
  13651. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13652. */
  13653. customVRButton?: HTMLButtonElement;
  13654. /**
  13655. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13656. */
  13657. rayLength?: number;
  13658. /**
  13659. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13660. */
  13661. defaultHeight?: number;
  13662. /**
  13663. * If multiview should be used if availible (default: false)
  13664. */
  13665. useMultiview?: boolean;
  13666. }
  13667. /**
  13668. * This represents a WebVR camera.
  13669. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13670. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13671. */
  13672. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13673. private webVROptions;
  13674. /**
  13675. * @hidden
  13676. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13677. */
  13678. _vrDevice: any;
  13679. /**
  13680. * The rawPose of the vrDevice.
  13681. */
  13682. rawPose: Nullable<DevicePose>;
  13683. private _onVREnabled;
  13684. private _specsVersion;
  13685. private _attached;
  13686. private _frameData;
  13687. protected _descendants: Array<Node>;
  13688. private _deviceRoomPosition;
  13689. /** @hidden */
  13690. _deviceRoomRotationQuaternion: Quaternion;
  13691. private _standingMatrix;
  13692. /**
  13693. * Represents device position in babylon space.
  13694. */
  13695. devicePosition: Vector3;
  13696. /**
  13697. * Represents device rotation in babylon space.
  13698. */
  13699. deviceRotationQuaternion: Quaternion;
  13700. /**
  13701. * The scale of the device to be used when translating from device space to babylon space.
  13702. */
  13703. deviceScaleFactor: number;
  13704. private _deviceToWorld;
  13705. private _worldToDevice;
  13706. /**
  13707. * References to the webVR controllers for the vrDevice.
  13708. */
  13709. controllers: Array<WebVRController>;
  13710. /**
  13711. * Emits an event when a controller is attached.
  13712. */
  13713. onControllersAttachedObservable: Observable<WebVRController[]>;
  13714. /**
  13715. * Emits an event when a controller's mesh has been loaded;
  13716. */
  13717. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13718. /**
  13719. * Emits an event when the HMD's pose has been updated.
  13720. */
  13721. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13722. private _poseSet;
  13723. /**
  13724. * If the rig cameras be used as parent instead of this camera.
  13725. */
  13726. rigParenting: boolean;
  13727. private _lightOnControllers;
  13728. private _defaultHeight?;
  13729. /**
  13730. * Instantiates a WebVRFreeCamera.
  13731. * @param name The name of the WebVRFreeCamera
  13732. * @param position The starting anchor position for the camera
  13733. * @param scene The scene the camera belongs to
  13734. * @param webVROptions a set of customizable options for the webVRCamera
  13735. */
  13736. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13737. /**
  13738. * Gets the device distance from the ground in meters.
  13739. * @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.
  13740. */
  13741. deviceDistanceToRoomGround(): number;
  13742. /**
  13743. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13744. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13745. */
  13746. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13747. /**
  13748. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13749. * @returns A promise with a boolean set to if the standing matrix is supported.
  13750. */
  13751. useStandingMatrixAsync(): Promise<boolean>;
  13752. /**
  13753. * Disposes the camera
  13754. */
  13755. dispose(): void;
  13756. /**
  13757. * Gets a vrController by name.
  13758. * @param name The name of the controller to retreive
  13759. * @returns the controller matching the name specified or null if not found
  13760. */
  13761. getControllerByName(name: string): Nullable<WebVRController>;
  13762. private _leftController;
  13763. /**
  13764. * The controller corrisponding to the users left hand.
  13765. */
  13766. readonly leftController: Nullable<WebVRController>;
  13767. private _rightController;
  13768. /**
  13769. * The controller corrisponding to the users right hand.
  13770. */
  13771. readonly rightController: Nullable<WebVRController>;
  13772. /**
  13773. * Casts a ray forward from the vrCamera's gaze.
  13774. * @param length Length of the ray (default: 100)
  13775. * @returns the ray corrisponding to the gaze
  13776. */
  13777. getForwardRay(length?: number): Ray;
  13778. /**
  13779. * @hidden
  13780. * Updates the camera based on device's frame data
  13781. */
  13782. _checkInputs(): void;
  13783. /**
  13784. * Updates the poseControlled values based on the input device pose.
  13785. * @param poseData Pose coming from the device
  13786. */
  13787. updateFromDevice(poseData: DevicePose): void;
  13788. private _htmlElementAttached;
  13789. private _detachIfAttached;
  13790. /**
  13791. * WebVR's attach control will start broadcasting frames to the device.
  13792. * Note that in certain browsers (chrome for example) this function must be called
  13793. * within a user-interaction callback. Example:
  13794. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13795. *
  13796. * @param element html element to attach the vrDevice to
  13797. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13798. */
  13799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13800. /**
  13801. * Detaches the camera from the html element and disables VR
  13802. *
  13803. * @param element html element to detach from
  13804. */
  13805. detachControl(element: HTMLElement): void;
  13806. /**
  13807. * @returns the name of this class
  13808. */
  13809. getClassName(): string;
  13810. /**
  13811. * Calls resetPose on the vrDisplay
  13812. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13813. */
  13814. resetToCurrentRotation(): void;
  13815. /**
  13816. * @hidden
  13817. * Updates the rig cameras (left and right eye)
  13818. */
  13819. _updateRigCameras(): void;
  13820. private _workingVector;
  13821. private _oneVector;
  13822. private _workingMatrix;
  13823. private updateCacheCalled;
  13824. private _correctPositionIfNotTrackPosition;
  13825. /**
  13826. * @hidden
  13827. * Updates the cached values of the camera
  13828. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13829. */
  13830. _updateCache(ignoreParentClass?: boolean): void;
  13831. /**
  13832. * @hidden
  13833. * Get current device position in babylon world
  13834. */
  13835. _computeDevicePosition(): void;
  13836. /**
  13837. * Updates the current device position and rotation in the babylon world
  13838. */
  13839. update(): void;
  13840. /**
  13841. * @hidden
  13842. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13843. * @returns an identity matrix
  13844. */
  13845. _getViewMatrix(): Matrix;
  13846. private _tmpMatrix;
  13847. /**
  13848. * This function is called by the two RIG cameras.
  13849. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13850. * @hidden
  13851. */
  13852. _getWebVRViewMatrix(): Matrix;
  13853. /** @hidden */
  13854. _getWebVRProjectionMatrix(): Matrix;
  13855. private _onGamepadConnectedObserver;
  13856. private _onGamepadDisconnectedObserver;
  13857. private _updateCacheWhenTrackingDisabledObserver;
  13858. /**
  13859. * Initializes the controllers and their meshes
  13860. */
  13861. initControllers(): void;
  13862. }
  13863. }
  13864. declare module "babylonjs/PostProcesses/postProcess" {
  13865. import { Nullable } from "babylonjs/types";
  13866. import { SmartArray } from "babylonjs/Misc/smartArray";
  13867. import { Observable } from "babylonjs/Misc/observable";
  13868. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13869. import { Camera } from "babylonjs/Cameras/camera";
  13870. import { Effect } from "babylonjs/Materials/effect";
  13871. import "babylonjs/Shaders/postprocess.vertex";
  13872. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13873. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13874. import { Engine } from "babylonjs/Engines/engine";
  13875. /**
  13876. * Size options for a post process
  13877. */
  13878. export type PostProcessOptions = {
  13879. width: number;
  13880. height: number;
  13881. };
  13882. /**
  13883. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13884. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13885. */
  13886. export class PostProcess {
  13887. /** Name of the PostProcess. */
  13888. name: string;
  13889. /**
  13890. * Gets or sets the unique id of the post process
  13891. */
  13892. uniqueId: number;
  13893. /**
  13894. * Width of the texture to apply the post process on
  13895. */
  13896. width: number;
  13897. /**
  13898. * Height of the texture to apply the post process on
  13899. */
  13900. height: number;
  13901. /**
  13902. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13903. * @hidden
  13904. */
  13905. _outputTexture: Nullable<InternalTexture>;
  13906. /**
  13907. * Sampling mode used by the shader
  13908. * See https://doc.babylonjs.com/classes/3.1/texture
  13909. */
  13910. renderTargetSamplingMode: number;
  13911. /**
  13912. * Clear color to use when screen clearing
  13913. */
  13914. clearColor: Color4;
  13915. /**
  13916. * If the buffer needs to be cleared before applying the post process. (default: true)
  13917. * Should be set to false if shader will overwrite all previous pixels.
  13918. */
  13919. autoClear: boolean;
  13920. /**
  13921. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13922. */
  13923. alphaMode: number;
  13924. /**
  13925. * Sets the setAlphaBlendConstants of the babylon engine
  13926. */
  13927. alphaConstants: Color4;
  13928. /**
  13929. * Animations to be used for the post processing
  13930. */
  13931. animations: import("babylonjs/Animations/animation").Animation[];
  13932. /**
  13933. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13934. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13935. */
  13936. enablePixelPerfectMode: boolean;
  13937. /**
  13938. * Force the postprocess to be applied without taking in account viewport
  13939. */
  13940. forceFullscreenViewport: boolean;
  13941. /**
  13942. * List of inspectable custom properties (used by the Inspector)
  13943. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13944. */
  13945. inspectableCustomProperties: IInspectable[];
  13946. /**
  13947. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13948. *
  13949. * | Value | Type | Description |
  13950. * | ----- | ----------------------------------- | ----------- |
  13951. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13952. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13953. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13954. *
  13955. */
  13956. scaleMode: number;
  13957. /**
  13958. * Force textures to be a power of two (default: false)
  13959. */
  13960. alwaysForcePOT: boolean;
  13961. private _samples;
  13962. /**
  13963. * Number of sample textures (default: 1)
  13964. */
  13965. samples: number;
  13966. /**
  13967. * Modify the scale of the post process to be the same as the viewport (default: false)
  13968. */
  13969. adaptScaleToCurrentViewport: boolean;
  13970. private _camera;
  13971. private _scene;
  13972. private _engine;
  13973. private _options;
  13974. private _reusable;
  13975. private _textureType;
  13976. /**
  13977. * Smart array of input and output textures for the post process.
  13978. * @hidden
  13979. */
  13980. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13981. /**
  13982. * The index in _textures that corresponds to the output texture.
  13983. * @hidden
  13984. */
  13985. _currentRenderTextureInd: number;
  13986. private _effect;
  13987. private _samplers;
  13988. private _fragmentUrl;
  13989. private _vertexUrl;
  13990. private _parameters;
  13991. private _scaleRatio;
  13992. protected _indexParameters: any;
  13993. private _shareOutputWithPostProcess;
  13994. private _texelSize;
  13995. private _forcedOutputTexture;
  13996. /**
  13997. * Returns the fragment url or shader name used in the post process.
  13998. * @returns the fragment url or name in the shader store.
  13999. */
  14000. getEffectName(): string;
  14001. /**
  14002. * An event triggered when the postprocess is activated.
  14003. */
  14004. onActivateObservable: Observable<Camera>;
  14005. private _onActivateObserver;
  14006. /**
  14007. * A function that is added to the onActivateObservable
  14008. */
  14009. onActivate: Nullable<(camera: Camera) => void>;
  14010. /**
  14011. * An event triggered when the postprocess changes its size.
  14012. */
  14013. onSizeChangedObservable: Observable<PostProcess>;
  14014. private _onSizeChangedObserver;
  14015. /**
  14016. * A function that is added to the onSizeChangedObservable
  14017. */
  14018. onSizeChanged: (postProcess: PostProcess) => void;
  14019. /**
  14020. * An event triggered when the postprocess applies its effect.
  14021. */
  14022. onApplyObservable: Observable<Effect>;
  14023. private _onApplyObserver;
  14024. /**
  14025. * A function that is added to the onApplyObservable
  14026. */
  14027. onApply: (effect: Effect) => void;
  14028. /**
  14029. * An event triggered before rendering the postprocess
  14030. */
  14031. onBeforeRenderObservable: Observable<Effect>;
  14032. private _onBeforeRenderObserver;
  14033. /**
  14034. * A function that is added to the onBeforeRenderObservable
  14035. */
  14036. onBeforeRender: (effect: Effect) => void;
  14037. /**
  14038. * An event triggered after rendering the postprocess
  14039. */
  14040. onAfterRenderObservable: Observable<Effect>;
  14041. private _onAfterRenderObserver;
  14042. /**
  14043. * A function that is added to the onAfterRenderObservable
  14044. */
  14045. onAfterRender: (efect: Effect) => void;
  14046. /**
  14047. * 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
  14048. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14049. */
  14050. inputTexture: InternalTexture;
  14051. /**
  14052. * Gets the camera which post process is applied to.
  14053. * @returns The camera the post process is applied to.
  14054. */
  14055. getCamera(): Camera;
  14056. /**
  14057. * Gets the texel size of the postprocess.
  14058. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14059. */
  14060. readonly texelSize: Vector2;
  14061. /**
  14062. * Creates a new instance PostProcess
  14063. * @param name The name of the PostProcess.
  14064. * @param fragmentUrl The url of the fragment shader to be used.
  14065. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14066. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14067. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14068. * @param camera The camera to apply the render pass to.
  14069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14070. * @param engine The engine which the post process will be applied. (default: current engine)
  14071. * @param reusable If the post process can be reused on the same frame. (default: false)
  14072. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14073. * @param textureType Type of textures used when performing the post process. (default: 0)
  14074. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14075. * @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
  14076. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14077. */
  14078. constructor(
  14079. /** Name of the PostProcess. */
  14080. 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);
  14081. /**
  14082. * Gets a string idenfifying the name of the class
  14083. * @returns "PostProcess" string
  14084. */
  14085. getClassName(): string;
  14086. /**
  14087. * Gets the engine which this post process belongs to.
  14088. * @returns The engine the post process was enabled with.
  14089. */
  14090. getEngine(): Engine;
  14091. /**
  14092. * The effect that is created when initializing the post process.
  14093. * @returns The created effect corrisponding the the postprocess.
  14094. */
  14095. getEffect(): Effect;
  14096. /**
  14097. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14098. * @param postProcess The post process to share the output with.
  14099. * @returns This post process.
  14100. */
  14101. shareOutputWith(postProcess: PostProcess): PostProcess;
  14102. /**
  14103. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14104. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14105. */
  14106. useOwnOutput(): void;
  14107. /**
  14108. * Updates the effect with the current post process compile time values and recompiles the shader.
  14109. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14110. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14111. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14112. * @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
  14113. * @param onCompiled Called when the shader has been compiled.
  14114. * @param onError Called if there is an error when compiling a shader.
  14115. */
  14116. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14117. /**
  14118. * The post process is reusable if it can be used multiple times within one frame.
  14119. * @returns If the post process is reusable
  14120. */
  14121. isReusable(): boolean;
  14122. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14123. markTextureDirty(): void;
  14124. /**
  14125. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14126. * 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.
  14127. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14128. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14129. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14130. * @returns The target texture that was bound to be written to.
  14131. */
  14132. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14133. /**
  14134. * If the post process is supported.
  14135. */
  14136. readonly isSupported: boolean;
  14137. /**
  14138. * The aspect ratio of the output texture.
  14139. */
  14140. readonly aspectRatio: number;
  14141. /**
  14142. * Get a value indicating if the post-process is ready to be used
  14143. * @returns true if the post-process is ready (shader is compiled)
  14144. */
  14145. isReady(): boolean;
  14146. /**
  14147. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14148. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14149. */
  14150. apply(): Nullable<Effect>;
  14151. private _disposeTextures;
  14152. /**
  14153. * Disposes the post process.
  14154. * @param camera The camera to dispose the post process on.
  14155. */
  14156. dispose(camera?: Camera): void;
  14157. }
  14158. }
  14159. declare module "babylonjs/PostProcesses/postProcessManager" {
  14160. import { Nullable } from "babylonjs/types";
  14161. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14162. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14163. import { Scene } from "babylonjs/scene";
  14164. /**
  14165. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14166. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14167. */
  14168. export class PostProcessManager {
  14169. private _scene;
  14170. private _indexBuffer;
  14171. private _vertexBuffers;
  14172. /**
  14173. * Creates a new instance PostProcess
  14174. * @param scene The scene that the post process is associated with.
  14175. */
  14176. constructor(scene: Scene);
  14177. private _prepareBuffers;
  14178. private _buildIndexBuffer;
  14179. /**
  14180. * Rebuilds the vertex buffers of the manager.
  14181. * @hidden
  14182. */
  14183. _rebuild(): void;
  14184. /**
  14185. * Prepares a frame to be run through a post process.
  14186. * @param sourceTexture The input texture to the post procesess. (default: null)
  14187. * @param postProcesses An array of post processes to be run. (default: null)
  14188. * @returns True if the post processes were able to be run.
  14189. * @hidden
  14190. */
  14191. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14192. /**
  14193. * Manually render a set of post processes to a texture.
  14194. * @param postProcesses An array of post processes to be run.
  14195. * @param targetTexture The target texture to render to.
  14196. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14197. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14198. * @param lodLevel defines which lod of the texture to render to
  14199. */
  14200. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14201. /**
  14202. * Finalize the result of the output of the postprocesses.
  14203. * @param doNotPresent If true the result will not be displayed to the screen.
  14204. * @param targetTexture The target texture to render to.
  14205. * @param faceIndex The index of the face to bind the target texture to.
  14206. * @param postProcesses The array of post processes to render.
  14207. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14208. * @hidden
  14209. */
  14210. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14211. /**
  14212. * Disposes of the post process manager.
  14213. */
  14214. dispose(): void;
  14215. }
  14216. }
  14217. declare module "babylonjs/Layers/layerSceneComponent" {
  14218. import { Scene } from "babylonjs/scene";
  14219. import { ISceneComponent } from "babylonjs/sceneComponent";
  14220. import { Layer } from "babylonjs/Layers/layer";
  14221. module "babylonjs/abstractScene" {
  14222. interface AbstractScene {
  14223. /**
  14224. * The list of layers (background and foreground) of the scene
  14225. */
  14226. layers: Array<Layer>;
  14227. }
  14228. }
  14229. /**
  14230. * Defines the layer scene component responsible to manage any layers
  14231. * in a given scene.
  14232. */
  14233. export class LayerSceneComponent implements ISceneComponent {
  14234. /**
  14235. * The component name helpfull to identify the component in the list of scene components.
  14236. */
  14237. readonly name: string;
  14238. /**
  14239. * The scene the component belongs to.
  14240. */
  14241. scene: Scene;
  14242. private _engine;
  14243. /**
  14244. * Creates a new instance of the component for the given scene
  14245. * @param scene Defines the scene to register the component in
  14246. */
  14247. constructor(scene: Scene);
  14248. /**
  14249. * Registers the component in a given scene
  14250. */
  14251. register(): void;
  14252. /**
  14253. * Rebuilds the elements related to this component in case of
  14254. * context lost for instance.
  14255. */
  14256. rebuild(): void;
  14257. /**
  14258. * Disposes the component and the associated ressources.
  14259. */
  14260. dispose(): void;
  14261. private _draw;
  14262. private _drawCameraPredicate;
  14263. private _drawCameraBackground;
  14264. private _drawCameraForeground;
  14265. private _drawRenderTargetPredicate;
  14266. private _drawRenderTargetBackground;
  14267. private _drawRenderTargetForeground;
  14268. }
  14269. }
  14270. declare module "babylonjs/Shaders/layer.fragment" {
  14271. /** @hidden */
  14272. export var layerPixelShader: {
  14273. name: string;
  14274. shader: string;
  14275. };
  14276. }
  14277. declare module "babylonjs/Shaders/layer.vertex" {
  14278. /** @hidden */
  14279. export var layerVertexShader: {
  14280. name: string;
  14281. shader: string;
  14282. };
  14283. }
  14284. declare module "babylonjs/Layers/layer" {
  14285. import { Observable } from "babylonjs/Misc/observable";
  14286. import { Nullable } from "babylonjs/types";
  14287. import { Scene } from "babylonjs/scene";
  14288. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14289. import { Texture } from "babylonjs/Materials/Textures/texture";
  14290. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14291. import "babylonjs/Shaders/layer.fragment";
  14292. import "babylonjs/Shaders/layer.vertex";
  14293. /**
  14294. * This represents a full screen 2d layer.
  14295. * This can be useful to display a picture in the background of your scene for instance.
  14296. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14297. */
  14298. export class Layer {
  14299. /**
  14300. * Define the name of the layer.
  14301. */
  14302. name: string;
  14303. /**
  14304. * Define the texture the layer should display.
  14305. */
  14306. texture: Nullable<Texture>;
  14307. /**
  14308. * Is the layer in background or foreground.
  14309. */
  14310. isBackground: boolean;
  14311. /**
  14312. * Define the color of the layer (instead of texture).
  14313. */
  14314. color: Color4;
  14315. /**
  14316. * Define the scale of the layer in order to zoom in out of the texture.
  14317. */
  14318. scale: Vector2;
  14319. /**
  14320. * Define an offset for the layer in order to shift the texture.
  14321. */
  14322. offset: Vector2;
  14323. /**
  14324. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14325. */
  14326. alphaBlendingMode: number;
  14327. /**
  14328. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14329. * Alpha test will not mix with the background color in case of transparency.
  14330. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14331. */
  14332. alphaTest: boolean;
  14333. /**
  14334. * Define a mask to restrict the layer to only some of the scene cameras.
  14335. */
  14336. layerMask: number;
  14337. /**
  14338. * Define the list of render target the layer is visible into.
  14339. */
  14340. renderTargetTextures: RenderTargetTexture[];
  14341. /**
  14342. * Define if the layer is only used in renderTarget or if it also
  14343. * renders in the main frame buffer of the canvas.
  14344. */
  14345. renderOnlyInRenderTargetTextures: boolean;
  14346. private _scene;
  14347. private _vertexBuffers;
  14348. private _indexBuffer;
  14349. private _effect;
  14350. private _alphaTestEffect;
  14351. /**
  14352. * An event triggered when the layer is disposed.
  14353. */
  14354. onDisposeObservable: Observable<Layer>;
  14355. private _onDisposeObserver;
  14356. /**
  14357. * Back compatibility with callback before the onDisposeObservable existed.
  14358. * The set callback will be triggered when the layer has been disposed.
  14359. */
  14360. onDispose: () => void;
  14361. /**
  14362. * An event triggered before rendering the scene
  14363. */
  14364. onBeforeRenderObservable: Observable<Layer>;
  14365. private _onBeforeRenderObserver;
  14366. /**
  14367. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14368. * The set callback will be triggered just before rendering the layer.
  14369. */
  14370. onBeforeRender: () => void;
  14371. /**
  14372. * An event triggered after rendering the scene
  14373. */
  14374. onAfterRenderObservable: Observable<Layer>;
  14375. private _onAfterRenderObserver;
  14376. /**
  14377. * Back compatibility with callback before the onAfterRenderObservable existed.
  14378. * The set callback will be triggered just after rendering the layer.
  14379. */
  14380. onAfterRender: () => void;
  14381. /**
  14382. * Instantiates a new layer.
  14383. * This represents a full screen 2d layer.
  14384. * This can be useful to display a picture in the background of your scene for instance.
  14385. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14386. * @param name Define the name of the layer in the scene
  14387. * @param imgUrl Define the url of the texture to display in the layer
  14388. * @param scene Define the scene the layer belongs to
  14389. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14390. * @param color Defines a color for the layer
  14391. */
  14392. constructor(
  14393. /**
  14394. * Define the name of the layer.
  14395. */
  14396. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14397. private _createIndexBuffer;
  14398. /** @hidden */
  14399. _rebuild(): void;
  14400. /**
  14401. * Renders the layer in the scene.
  14402. */
  14403. render(): void;
  14404. /**
  14405. * Disposes and releases the associated ressources.
  14406. */
  14407. dispose(): void;
  14408. }
  14409. }
  14410. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14411. import { Scene } from "babylonjs/scene";
  14412. import { ISceneComponent } from "babylonjs/sceneComponent";
  14413. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14414. module "babylonjs/abstractScene" {
  14415. interface AbstractScene {
  14416. /**
  14417. * The list of procedural textures added to the scene
  14418. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14419. */
  14420. proceduralTextures: Array<ProceduralTexture>;
  14421. }
  14422. }
  14423. /**
  14424. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14425. * in a given scene.
  14426. */
  14427. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14428. /**
  14429. * The component name helpfull to identify the component in the list of scene components.
  14430. */
  14431. readonly name: string;
  14432. /**
  14433. * The scene the component belongs to.
  14434. */
  14435. scene: Scene;
  14436. /**
  14437. * Creates a new instance of the component for the given scene
  14438. * @param scene Defines the scene to register the component in
  14439. */
  14440. constructor(scene: Scene);
  14441. /**
  14442. * Registers the component in a given scene
  14443. */
  14444. register(): void;
  14445. /**
  14446. * Rebuilds the elements related to this component in case of
  14447. * context lost for instance.
  14448. */
  14449. rebuild(): void;
  14450. /**
  14451. * Disposes the component and the associated ressources.
  14452. */
  14453. dispose(): void;
  14454. private _beforeClear;
  14455. }
  14456. }
  14457. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14458. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14459. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14460. module "babylonjs/Engines/engine" {
  14461. interface Engine {
  14462. /**
  14463. * Creates a new render target cube texture
  14464. * @param size defines the size of the texture
  14465. * @param options defines the options used to create the texture
  14466. * @returns a new render target cube texture stored in an InternalTexture
  14467. */
  14468. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14469. }
  14470. }
  14471. }
  14472. declare module "babylonjs/Shaders/procedural.vertex" {
  14473. /** @hidden */
  14474. export var proceduralVertexShader: {
  14475. name: string;
  14476. shader: string;
  14477. };
  14478. }
  14479. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14480. import { Observable } from "babylonjs/Misc/observable";
  14481. import { Nullable } from "babylonjs/types";
  14482. import { Scene } from "babylonjs/scene";
  14483. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14484. import { Effect } from "babylonjs/Materials/effect";
  14485. import { Texture } from "babylonjs/Materials/Textures/texture";
  14486. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14487. import "babylonjs/Shaders/procedural.vertex";
  14488. /**
  14489. * 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.
  14490. * This is the base class of any Procedural texture and contains most of the shareable code.
  14491. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14492. */
  14493. export class ProceduralTexture extends Texture {
  14494. isCube: boolean;
  14495. /**
  14496. * Define if the texture is enabled or not (disabled texture will not render)
  14497. */
  14498. isEnabled: boolean;
  14499. /**
  14500. * Define if the texture must be cleared before rendering (default is true)
  14501. */
  14502. autoClear: boolean;
  14503. /**
  14504. * Callback called when the texture is generated
  14505. */
  14506. onGenerated: () => void;
  14507. /**
  14508. * Event raised when the texture is generated
  14509. */
  14510. onGeneratedObservable: Observable<ProceduralTexture>;
  14511. /** @hidden */
  14512. _generateMipMaps: boolean;
  14513. /** @hidden **/
  14514. _effect: Effect;
  14515. /** @hidden */
  14516. _textures: {
  14517. [key: string]: Texture;
  14518. };
  14519. private _size;
  14520. private _currentRefreshId;
  14521. private _refreshRate;
  14522. private _vertexBuffers;
  14523. private _indexBuffer;
  14524. private _uniforms;
  14525. private _samplers;
  14526. private _fragment;
  14527. private _floats;
  14528. private _ints;
  14529. private _floatsArrays;
  14530. private _colors3;
  14531. private _colors4;
  14532. private _vectors2;
  14533. private _vectors3;
  14534. private _matrices;
  14535. private _fallbackTexture;
  14536. private _fallbackTextureUsed;
  14537. private _engine;
  14538. private _cachedDefines;
  14539. private _contentUpdateId;
  14540. private _contentData;
  14541. /**
  14542. * Instantiates a new procedural texture.
  14543. * 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.
  14544. * This is the base class of any Procedural texture and contains most of the shareable code.
  14545. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14546. * @param name Define the name of the texture
  14547. * @param size Define the size of the texture to create
  14548. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14549. * @param scene Define the scene the texture belongs to
  14550. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14551. * @param generateMipMaps Define if the texture should creates mip maps or not
  14552. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14553. */
  14554. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14555. /**
  14556. * The effect that is created when initializing the post process.
  14557. * @returns The created effect corrisponding the the postprocess.
  14558. */
  14559. getEffect(): Effect;
  14560. /**
  14561. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14562. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14563. */
  14564. getContent(): Nullable<ArrayBufferView>;
  14565. private _createIndexBuffer;
  14566. /** @hidden */
  14567. _rebuild(): void;
  14568. /**
  14569. * Resets the texture in order to recreate its associated resources.
  14570. * This can be called in case of context loss
  14571. */
  14572. reset(): void;
  14573. protected _getDefines(): string;
  14574. /**
  14575. * Is the texture ready to be used ? (rendered at least once)
  14576. * @returns true if ready, otherwise, false.
  14577. */
  14578. isReady(): boolean;
  14579. /**
  14580. * Resets the refresh counter of the texture and start bak from scratch.
  14581. * Could be useful to regenerate the texture if it is setup to render only once.
  14582. */
  14583. resetRefreshCounter(): void;
  14584. /**
  14585. * Set the fragment shader to use in order to render the texture.
  14586. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14587. */
  14588. setFragment(fragment: any): void;
  14589. /**
  14590. * Define the refresh rate of the texture or the rendering frequency.
  14591. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14592. */
  14593. refreshRate: number;
  14594. /** @hidden */
  14595. _shouldRender(): boolean;
  14596. /**
  14597. * Get the size the texture is rendering at.
  14598. * @returns the size (texture is always squared)
  14599. */
  14600. getRenderSize(): number;
  14601. /**
  14602. * Resize the texture to new value.
  14603. * @param size Define the new size the texture should have
  14604. * @param generateMipMaps Define whether the new texture should create mip maps
  14605. */
  14606. resize(size: number, generateMipMaps: boolean): void;
  14607. private _checkUniform;
  14608. /**
  14609. * Set a texture in the shader program used to render.
  14610. * @param name Define the name of the uniform samplers as defined in the shader
  14611. * @param texture Define the texture to bind to this sampler
  14612. * @return the texture itself allowing "fluent" like uniform updates
  14613. */
  14614. setTexture(name: string, texture: Texture): ProceduralTexture;
  14615. /**
  14616. * Set a float in the shader.
  14617. * @param name Define the name of the uniform as defined in the shader
  14618. * @param value Define the value to give to the uniform
  14619. * @return the texture itself allowing "fluent" like uniform updates
  14620. */
  14621. setFloat(name: string, value: number): ProceduralTexture;
  14622. /**
  14623. * Set a int in the shader.
  14624. * @param name Define the name of the uniform as defined in the shader
  14625. * @param value Define the value to give to the uniform
  14626. * @return the texture itself allowing "fluent" like uniform updates
  14627. */
  14628. setInt(name: string, value: number): ProceduralTexture;
  14629. /**
  14630. * Set an array of floats in the shader.
  14631. * @param name Define the name of the uniform as defined in the shader
  14632. * @param value Define the value to give to the uniform
  14633. * @return the texture itself allowing "fluent" like uniform updates
  14634. */
  14635. setFloats(name: string, value: number[]): ProceduralTexture;
  14636. /**
  14637. * Set a vec3 in the shader from a Color3.
  14638. * @param name Define the name of the uniform as defined in the shader
  14639. * @param value Define the value to give to the uniform
  14640. * @return the texture itself allowing "fluent" like uniform updates
  14641. */
  14642. setColor3(name: string, value: Color3): ProceduralTexture;
  14643. /**
  14644. * Set a vec4 in the shader from a Color4.
  14645. * @param name Define the name of the uniform as defined in the shader
  14646. * @param value Define the value to give to the uniform
  14647. * @return the texture itself allowing "fluent" like uniform updates
  14648. */
  14649. setColor4(name: string, value: Color4): ProceduralTexture;
  14650. /**
  14651. * Set a vec2 in the shader from a Vector2.
  14652. * @param name Define the name of the uniform as defined in the shader
  14653. * @param value Define the value to give to the uniform
  14654. * @return the texture itself allowing "fluent" like uniform updates
  14655. */
  14656. setVector2(name: string, value: Vector2): ProceduralTexture;
  14657. /**
  14658. * Set a vec3 in the shader from a Vector3.
  14659. * @param name Define the name of the uniform as defined in the shader
  14660. * @param value Define the value to give to the uniform
  14661. * @return the texture itself allowing "fluent" like uniform updates
  14662. */
  14663. setVector3(name: string, value: Vector3): ProceduralTexture;
  14664. /**
  14665. * Set a mat4 in the shader from a MAtrix.
  14666. * @param name Define the name of the uniform as defined in the shader
  14667. * @param value Define the value to give to the uniform
  14668. * @return the texture itself allowing "fluent" like uniform updates
  14669. */
  14670. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14671. /**
  14672. * Render the texture to its associated render target.
  14673. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14674. */
  14675. render(useCameraPostProcess?: boolean): void;
  14676. /**
  14677. * Clone the texture.
  14678. * @returns the cloned texture
  14679. */
  14680. clone(): ProceduralTexture;
  14681. /**
  14682. * Dispose the texture and release its asoociated resources.
  14683. */
  14684. dispose(): void;
  14685. }
  14686. }
  14687. declare module "babylonjs/Particles/baseParticleSystem" {
  14688. import { Nullable } from "babylonjs/types";
  14689. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14691. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14692. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14693. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14694. import { Scene } from "babylonjs/scene";
  14695. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14696. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14697. import { Texture } from "babylonjs/Materials/Textures/texture";
  14698. import { Animation } from "babylonjs/Animations/animation";
  14699. /**
  14700. * This represents the base class for particle system in Babylon.
  14701. * 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.
  14702. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14703. * @example https://doc.babylonjs.com/babylon101/particles
  14704. */
  14705. export class BaseParticleSystem {
  14706. /**
  14707. * Source color is added to the destination color without alpha affecting the result
  14708. */
  14709. static BLENDMODE_ONEONE: number;
  14710. /**
  14711. * Blend current color and particle color using particle’s alpha
  14712. */
  14713. static BLENDMODE_STANDARD: number;
  14714. /**
  14715. * Add current color and particle color multiplied by particle’s alpha
  14716. */
  14717. static BLENDMODE_ADD: number;
  14718. /**
  14719. * Multiply current color with particle color
  14720. */
  14721. static BLENDMODE_MULTIPLY: number;
  14722. /**
  14723. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14724. */
  14725. static BLENDMODE_MULTIPLYADD: number;
  14726. /**
  14727. * List of animations used by the particle system.
  14728. */
  14729. animations: Animation[];
  14730. /**
  14731. * The id of the Particle system.
  14732. */
  14733. id: string;
  14734. /**
  14735. * The friendly name of the Particle system.
  14736. */
  14737. name: string;
  14738. /**
  14739. * The rendering group used by the Particle system to chose when to render.
  14740. */
  14741. renderingGroupId: number;
  14742. /**
  14743. * The emitter represents the Mesh or position we are attaching the particle system to.
  14744. */
  14745. emitter: Nullable<AbstractMesh | Vector3>;
  14746. /**
  14747. * The maximum number of particles to emit per frame
  14748. */
  14749. emitRate: number;
  14750. /**
  14751. * If you want to launch only a few particles at once, that can be done, as well.
  14752. */
  14753. manualEmitCount: number;
  14754. /**
  14755. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14756. */
  14757. updateSpeed: number;
  14758. /**
  14759. * The amount of time the particle system is running (depends of the overall update speed).
  14760. */
  14761. targetStopDuration: number;
  14762. /**
  14763. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14764. */
  14765. disposeOnStop: boolean;
  14766. /**
  14767. * Minimum power of emitting particles.
  14768. */
  14769. minEmitPower: number;
  14770. /**
  14771. * Maximum power of emitting particles.
  14772. */
  14773. maxEmitPower: number;
  14774. /**
  14775. * Minimum life time of emitting particles.
  14776. */
  14777. minLifeTime: number;
  14778. /**
  14779. * Maximum life time of emitting particles.
  14780. */
  14781. maxLifeTime: number;
  14782. /**
  14783. * Minimum Size of emitting particles.
  14784. */
  14785. minSize: number;
  14786. /**
  14787. * Maximum Size of emitting particles.
  14788. */
  14789. maxSize: number;
  14790. /**
  14791. * Minimum scale of emitting particles on X axis.
  14792. */
  14793. minScaleX: number;
  14794. /**
  14795. * Maximum scale of emitting particles on X axis.
  14796. */
  14797. maxScaleX: number;
  14798. /**
  14799. * Minimum scale of emitting particles on Y axis.
  14800. */
  14801. minScaleY: number;
  14802. /**
  14803. * Maximum scale of emitting particles on Y axis.
  14804. */
  14805. maxScaleY: number;
  14806. /**
  14807. * Gets or sets the minimal initial rotation in radians.
  14808. */
  14809. minInitialRotation: number;
  14810. /**
  14811. * Gets or sets the maximal initial rotation in radians.
  14812. */
  14813. maxInitialRotation: number;
  14814. /**
  14815. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14816. */
  14817. minAngularSpeed: number;
  14818. /**
  14819. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14820. */
  14821. maxAngularSpeed: number;
  14822. /**
  14823. * The texture used to render each particle. (this can be a spritesheet)
  14824. */
  14825. particleTexture: Nullable<Texture>;
  14826. /**
  14827. * The layer mask we are rendering the particles through.
  14828. */
  14829. layerMask: number;
  14830. /**
  14831. * This can help using your own shader to render the particle system.
  14832. * The according effect will be created
  14833. */
  14834. customShader: any;
  14835. /**
  14836. * By default particle system starts as soon as they are created. This prevents the
  14837. * automatic start to happen and let you decide when to start emitting particles.
  14838. */
  14839. preventAutoStart: boolean;
  14840. private _noiseTexture;
  14841. /**
  14842. * Gets or sets a texture used to add random noise to particle positions
  14843. */
  14844. noiseTexture: Nullable<ProceduralTexture>;
  14845. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14846. noiseStrength: Vector3;
  14847. /**
  14848. * Callback triggered when the particle animation is ending.
  14849. */
  14850. onAnimationEnd: Nullable<() => void>;
  14851. /**
  14852. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14853. */
  14854. blendMode: number;
  14855. /**
  14856. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14857. * to override the particles.
  14858. */
  14859. forceDepthWrite: boolean;
  14860. /** 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 */
  14861. preWarmCycles: number;
  14862. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14863. preWarmStepOffset: number;
  14864. /**
  14865. * 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)
  14866. */
  14867. spriteCellChangeSpeed: number;
  14868. /**
  14869. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14870. */
  14871. startSpriteCellID: number;
  14872. /**
  14873. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14874. */
  14875. endSpriteCellID: number;
  14876. /**
  14877. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14878. */
  14879. spriteCellWidth: number;
  14880. /**
  14881. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14882. */
  14883. spriteCellHeight: number;
  14884. /**
  14885. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14886. */
  14887. spriteRandomStartCell: boolean;
  14888. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14889. translationPivot: Vector2;
  14890. /** @hidden */
  14891. protected _isAnimationSheetEnabled: boolean;
  14892. /**
  14893. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14894. */
  14895. beginAnimationOnStart: boolean;
  14896. /**
  14897. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14898. */
  14899. beginAnimationFrom: number;
  14900. /**
  14901. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14902. */
  14903. beginAnimationTo: number;
  14904. /**
  14905. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14906. */
  14907. beginAnimationLoop: boolean;
  14908. /**
  14909. * Gets or sets a world offset applied to all particles
  14910. */
  14911. worldOffset: Vector3;
  14912. /**
  14913. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14914. */
  14915. isAnimationSheetEnabled: boolean;
  14916. /**
  14917. * Get hosting scene
  14918. * @returns the scene
  14919. */
  14920. getScene(): Scene;
  14921. /**
  14922. * You can use gravity if you want to give an orientation to your particles.
  14923. */
  14924. gravity: Vector3;
  14925. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14926. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14927. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14928. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14929. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14930. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14931. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14932. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14933. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14934. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14935. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14936. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14937. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14938. /**
  14939. * Defines the delay in milliseconds before starting the system (0 by default)
  14940. */
  14941. startDelay: number;
  14942. /**
  14943. * Gets the current list of drag gradients.
  14944. * You must use addDragGradient and removeDragGradient to udpate this list
  14945. * @returns the list of drag gradients
  14946. */
  14947. getDragGradients(): Nullable<Array<FactorGradient>>;
  14948. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14949. limitVelocityDamping: number;
  14950. /**
  14951. * Gets the current list of limit velocity gradients.
  14952. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14953. * @returns the list of limit velocity gradients
  14954. */
  14955. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14956. /**
  14957. * Gets the current list of color gradients.
  14958. * You must use addColorGradient and removeColorGradient to udpate this list
  14959. * @returns the list of color gradients
  14960. */
  14961. getColorGradients(): Nullable<Array<ColorGradient>>;
  14962. /**
  14963. * Gets the current list of size gradients.
  14964. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14965. * @returns the list of size gradients
  14966. */
  14967. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14968. /**
  14969. * Gets the current list of color remap gradients.
  14970. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14971. * @returns the list of color remap gradients
  14972. */
  14973. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14974. /**
  14975. * Gets the current list of alpha remap gradients.
  14976. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14977. * @returns the list of alpha remap gradients
  14978. */
  14979. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14980. /**
  14981. * Gets the current list of life time gradients.
  14982. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14983. * @returns the list of life time gradients
  14984. */
  14985. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14986. /**
  14987. * Gets the current list of angular speed gradients.
  14988. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14989. * @returns the list of angular speed gradients
  14990. */
  14991. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14992. /**
  14993. * Gets the current list of velocity gradients.
  14994. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14995. * @returns the list of velocity gradients
  14996. */
  14997. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14998. /**
  14999. * Gets the current list of start size gradients.
  15000. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15001. * @returns the list of start size gradients
  15002. */
  15003. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15004. /**
  15005. * Gets the current list of emit rate gradients.
  15006. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15007. * @returns the list of emit rate gradients
  15008. */
  15009. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15010. /**
  15011. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15012. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15013. */
  15014. direction1: Vector3;
  15015. /**
  15016. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15017. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15018. */
  15019. direction2: Vector3;
  15020. /**
  15021. * 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.
  15022. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15023. */
  15024. minEmitBox: Vector3;
  15025. /**
  15026. * 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.
  15027. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15028. */
  15029. maxEmitBox: Vector3;
  15030. /**
  15031. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15032. */
  15033. color1: Color4;
  15034. /**
  15035. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15036. */
  15037. color2: Color4;
  15038. /**
  15039. * Color the particle will have at the end of its lifetime
  15040. */
  15041. colorDead: Color4;
  15042. /**
  15043. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15044. */
  15045. textureMask: Color4;
  15046. /**
  15047. * The particle emitter type defines the emitter used by the particle system.
  15048. * It can be for example box, sphere, or cone...
  15049. */
  15050. particleEmitterType: IParticleEmitterType;
  15051. /** @hidden */
  15052. _isSubEmitter: boolean;
  15053. /**
  15054. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15055. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15056. */
  15057. billboardMode: number;
  15058. protected _isBillboardBased: boolean;
  15059. /**
  15060. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15061. */
  15062. isBillboardBased: boolean;
  15063. /**
  15064. * The scene the particle system belongs to.
  15065. */
  15066. protected _scene: Scene;
  15067. /**
  15068. * Local cache of defines for image processing.
  15069. */
  15070. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15071. /**
  15072. * Default configuration related to image processing available in the standard Material.
  15073. */
  15074. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15075. /**
  15076. * Gets the image processing configuration used either in this material.
  15077. */
  15078. /**
  15079. * Sets the Default image processing configuration used either in the this material.
  15080. *
  15081. * If sets to null, the scene one is in use.
  15082. */
  15083. imageProcessingConfiguration: ImageProcessingConfiguration;
  15084. /**
  15085. * Attaches a new image processing configuration to the Standard Material.
  15086. * @param configuration
  15087. */
  15088. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15089. /** @hidden */
  15090. protected _reset(): void;
  15091. /** @hidden */
  15092. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15093. /**
  15094. * Instantiates a particle system.
  15095. * 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.
  15096. * @param name The name of the particle system
  15097. */
  15098. constructor(name: string);
  15099. /**
  15100. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15101. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15102. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15103. * @returns the emitter
  15104. */
  15105. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15106. /**
  15107. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15108. * @param radius The radius of the hemisphere to emit from
  15109. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15110. * @returns the emitter
  15111. */
  15112. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15113. /**
  15114. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15115. * @param radius The radius of the sphere to emit from
  15116. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15117. * @returns the emitter
  15118. */
  15119. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15120. /**
  15121. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15122. * @param radius The radius of the sphere to emit from
  15123. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15124. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15125. * @returns the emitter
  15126. */
  15127. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15128. /**
  15129. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15130. * @param radius The radius of the emission cylinder
  15131. * @param height The height of the emission cylinder
  15132. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15133. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15134. * @returns the emitter
  15135. */
  15136. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15137. /**
  15138. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15139. * @param radius The radius of the cylinder to emit from
  15140. * @param height The height of the emission cylinder
  15141. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15142. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15143. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15144. * @returns the emitter
  15145. */
  15146. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15147. /**
  15148. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15149. * @param radius The radius of the cone to emit from
  15150. * @param angle The base angle of the cone
  15151. * @returns the emitter
  15152. */
  15153. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15154. /**
  15155. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15156. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15157. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15158. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15159. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15160. * @returns the emitter
  15161. */
  15162. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15163. }
  15164. }
  15165. declare module "babylonjs/Particles/subEmitter" {
  15166. import { Scene } from "babylonjs/scene";
  15167. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15168. /**
  15169. * Type of sub emitter
  15170. */
  15171. export enum SubEmitterType {
  15172. /**
  15173. * Attached to the particle over it's lifetime
  15174. */
  15175. ATTACHED = 0,
  15176. /**
  15177. * Created when the particle dies
  15178. */
  15179. END = 1
  15180. }
  15181. /**
  15182. * Sub emitter class used to emit particles from an existing particle
  15183. */
  15184. export class SubEmitter {
  15185. /**
  15186. * the particle system to be used by the sub emitter
  15187. */
  15188. particleSystem: ParticleSystem;
  15189. /**
  15190. * Type of the submitter (Default: END)
  15191. */
  15192. type: SubEmitterType;
  15193. /**
  15194. * 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)
  15195. * Note: This only is supported when using an emitter of type Mesh
  15196. */
  15197. inheritDirection: boolean;
  15198. /**
  15199. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15200. */
  15201. inheritedVelocityAmount: number;
  15202. /**
  15203. * Creates a sub emitter
  15204. * @param particleSystem the particle system to be used by the sub emitter
  15205. */
  15206. constructor(
  15207. /**
  15208. * the particle system to be used by the sub emitter
  15209. */
  15210. particleSystem: ParticleSystem);
  15211. /**
  15212. * Clones the sub emitter
  15213. * @returns the cloned sub emitter
  15214. */
  15215. clone(): SubEmitter;
  15216. /**
  15217. * Serialize current object to a JSON object
  15218. * @returns the serialized object
  15219. */
  15220. serialize(): any;
  15221. /** @hidden */
  15222. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15223. /**
  15224. * Creates a new SubEmitter from a serialized JSON version
  15225. * @param serializationObject defines the JSON object to read from
  15226. * @param scene defines the hosting scene
  15227. * @param rootUrl defines the rootUrl for data loading
  15228. * @returns a new SubEmitter
  15229. */
  15230. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15231. /** Release associated resources */
  15232. dispose(): void;
  15233. }
  15234. }
  15235. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15236. /** @hidden */
  15237. export var clipPlaneFragmentDeclaration: {
  15238. name: string;
  15239. shader: string;
  15240. };
  15241. }
  15242. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15243. /** @hidden */
  15244. export var imageProcessingDeclaration: {
  15245. name: string;
  15246. shader: string;
  15247. };
  15248. }
  15249. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15250. /** @hidden */
  15251. export var imageProcessingFunctions: {
  15252. name: string;
  15253. shader: string;
  15254. };
  15255. }
  15256. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15257. /** @hidden */
  15258. export var clipPlaneFragment: {
  15259. name: string;
  15260. shader: string;
  15261. };
  15262. }
  15263. declare module "babylonjs/Shaders/particles.fragment" {
  15264. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15265. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15266. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15267. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15268. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15269. /** @hidden */
  15270. export var particlesPixelShader: {
  15271. name: string;
  15272. shader: string;
  15273. };
  15274. }
  15275. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15276. /** @hidden */
  15277. export var clipPlaneVertexDeclaration: {
  15278. name: string;
  15279. shader: string;
  15280. };
  15281. }
  15282. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15283. /** @hidden */
  15284. export var clipPlaneVertex: {
  15285. name: string;
  15286. shader: string;
  15287. };
  15288. }
  15289. declare module "babylonjs/Shaders/particles.vertex" {
  15290. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15291. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15292. /** @hidden */
  15293. export var particlesVertexShader: {
  15294. name: string;
  15295. shader: string;
  15296. };
  15297. }
  15298. declare module "babylonjs/Particles/particleSystem" {
  15299. import { Nullable } from "babylonjs/types";
  15300. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15301. import { Observable } from "babylonjs/Misc/observable";
  15302. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15303. import { Effect } from "babylonjs/Materials/effect";
  15304. import { Scene, IDisposable } from "babylonjs/scene";
  15305. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15306. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15307. import { Particle } from "babylonjs/Particles/particle";
  15308. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15309. import "babylonjs/Shaders/particles.fragment";
  15310. import "babylonjs/Shaders/particles.vertex";
  15311. /**
  15312. * This represents a particle system in Babylon.
  15313. * 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.
  15314. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15315. * @example https://doc.babylonjs.com/babylon101/particles
  15316. */
  15317. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15318. /**
  15319. * Billboard mode will only apply to Y axis
  15320. */
  15321. static readonly BILLBOARDMODE_Y: number;
  15322. /**
  15323. * Billboard mode will apply to all axes
  15324. */
  15325. static readonly BILLBOARDMODE_ALL: number;
  15326. /**
  15327. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15328. */
  15329. static readonly BILLBOARDMODE_STRETCHED: number;
  15330. /**
  15331. * This function can be defined to provide custom update for active particles.
  15332. * This function will be called instead of regular update (age, position, color, etc.).
  15333. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15334. */
  15335. updateFunction: (particles: Particle[]) => void;
  15336. private _emitterWorldMatrix;
  15337. /**
  15338. * This function can be defined to specify initial direction for every new particle.
  15339. * It by default use the emitterType defined function
  15340. */
  15341. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15342. /**
  15343. * This function can be defined to specify initial position for every new particle.
  15344. * It by default use the emitterType defined function
  15345. */
  15346. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15347. /**
  15348. * @hidden
  15349. */
  15350. _inheritedVelocityOffset: Vector3;
  15351. /**
  15352. * An event triggered when the system is disposed
  15353. */
  15354. onDisposeObservable: Observable<ParticleSystem>;
  15355. private _onDisposeObserver;
  15356. /**
  15357. * Sets a callback that will be triggered when the system is disposed
  15358. */
  15359. onDispose: () => void;
  15360. private _particles;
  15361. private _epsilon;
  15362. private _capacity;
  15363. private _stockParticles;
  15364. private _newPartsExcess;
  15365. private _vertexData;
  15366. private _vertexBuffer;
  15367. private _vertexBuffers;
  15368. private _spriteBuffer;
  15369. private _indexBuffer;
  15370. private _effect;
  15371. private _customEffect;
  15372. private _cachedDefines;
  15373. private _scaledColorStep;
  15374. private _colorDiff;
  15375. private _scaledDirection;
  15376. private _scaledGravity;
  15377. private _currentRenderId;
  15378. private _alive;
  15379. private _useInstancing;
  15380. private _started;
  15381. private _stopped;
  15382. private _actualFrame;
  15383. private _scaledUpdateSpeed;
  15384. private _vertexBufferSize;
  15385. /** @hidden */
  15386. _currentEmitRateGradient: Nullable<FactorGradient>;
  15387. /** @hidden */
  15388. _currentEmitRate1: number;
  15389. /** @hidden */
  15390. _currentEmitRate2: number;
  15391. /** @hidden */
  15392. _currentStartSizeGradient: Nullable<FactorGradient>;
  15393. /** @hidden */
  15394. _currentStartSize1: number;
  15395. /** @hidden */
  15396. _currentStartSize2: number;
  15397. private readonly _rawTextureWidth;
  15398. private _rampGradientsTexture;
  15399. private _useRampGradients;
  15400. /** Gets or sets a boolean indicating that ramp gradients must be used
  15401. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15402. */
  15403. useRampGradients: boolean;
  15404. /**
  15405. * 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.
  15406. * 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: [])
  15407. */
  15408. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15409. private _subEmitters;
  15410. /**
  15411. * @hidden
  15412. * If the particle systems emitter should be disposed when the particle system is disposed
  15413. */
  15414. _disposeEmitterOnDispose: boolean;
  15415. /**
  15416. * The current active Sub-systems, this property is used by the root particle system only.
  15417. */
  15418. activeSubSystems: Array<ParticleSystem>;
  15419. private _rootParticleSystem;
  15420. /**
  15421. * Gets the current list of active particles
  15422. */
  15423. readonly particles: Particle[];
  15424. /**
  15425. * Returns the string "ParticleSystem"
  15426. * @returns a string containing the class name
  15427. */
  15428. getClassName(): string;
  15429. /**
  15430. * Instantiates a particle system.
  15431. * 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.
  15432. * @param name The name of the particle system
  15433. * @param capacity The max number of particles alive at the same time
  15434. * @param scene The scene the particle system belongs to
  15435. * @param customEffect a custom effect used to change the way particles are rendered by default
  15436. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15437. * @param epsilon Offset used to render the particles
  15438. */
  15439. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15440. private _addFactorGradient;
  15441. private _removeFactorGradient;
  15442. /**
  15443. * Adds a new life time gradient
  15444. * @param gradient defines the gradient to use (between 0 and 1)
  15445. * @param factor defines the life time factor to affect to the specified gradient
  15446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15447. * @returns the current particle system
  15448. */
  15449. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15450. /**
  15451. * Remove a specific life time gradient
  15452. * @param gradient defines the gradient to remove
  15453. * @returns the current particle system
  15454. */
  15455. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15456. /**
  15457. * Adds a new size gradient
  15458. * @param gradient defines the gradient to use (between 0 and 1)
  15459. * @param factor defines the size factor to affect to the specified gradient
  15460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15461. * @returns the current particle system
  15462. */
  15463. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15464. /**
  15465. * Remove a specific size gradient
  15466. * @param gradient defines the gradient to remove
  15467. * @returns the current particle system
  15468. */
  15469. removeSizeGradient(gradient: number): IParticleSystem;
  15470. /**
  15471. * Adds a new color remap gradient
  15472. * @param gradient defines the gradient to use (between 0 and 1)
  15473. * @param min defines the color remap minimal range
  15474. * @param max defines the color remap maximal range
  15475. * @returns the current particle system
  15476. */
  15477. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15478. /**
  15479. * Remove a specific color remap gradient
  15480. * @param gradient defines the gradient to remove
  15481. * @returns the current particle system
  15482. */
  15483. removeColorRemapGradient(gradient: number): IParticleSystem;
  15484. /**
  15485. * Adds a new alpha remap gradient
  15486. * @param gradient defines the gradient to use (between 0 and 1)
  15487. * @param min defines the alpha remap minimal range
  15488. * @param max defines the alpha remap maximal range
  15489. * @returns the current particle system
  15490. */
  15491. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15492. /**
  15493. * Remove a specific alpha remap gradient
  15494. * @param gradient defines the gradient to remove
  15495. * @returns the current particle system
  15496. */
  15497. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15498. /**
  15499. * Adds a new angular speed gradient
  15500. * @param gradient defines the gradient to use (between 0 and 1)
  15501. * @param factor defines the angular speed to affect to the specified gradient
  15502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15503. * @returns the current particle system
  15504. */
  15505. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15506. /**
  15507. * Remove a specific angular speed gradient
  15508. * @param gradient defines the gradient to remove
  15509. * @returns the current particle system
  15510. */
  15511. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15512. /**
  15513. * Adds a new velocity gradient
  15514. * @param gradient defines the gradient to use (between 0 and 1)
  15515. * @param factor defines the velocity to affect to the specified gradient
  15516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15517. * @returns the current particle system
  15518. */
  15519. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15520. /**
  15521. * Remove a specific velocity gradient
  15522. * @param gradient defines the gradient to remove
  15523. * @returns the current particle system
  15524. */
  15525. removeVelocityGradient(gradient: number): IParticleSystem;
  15526. /**
  15527. * Adds a new limit velocity gradient
  15528. * @param gradient defines the gradient to use (between 0 and 1)
  15529. * @param factor defines the limit velocity value to affect to the specified gradient
  15530. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15531. * @returns the current particle system
  15532. */
  15533. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15534. /**
  15535. * Remove a specific limit velocity gradient
  15536. * @param gradient defines the gradient to remove
  15537. * @returns the current particle system
  15538. */
  15539. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15540. /**
  15541. * Adds a new drag gradient
  15542. * @param gradient defines the gradient to use (between 0 and 1)
  15543. * @param factor defines the drag value to affect to the specified gradient
  15544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15545. * @returns the current particle system
  15546. */
  15547. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15548. /**
  15549. * Remove a specific drag gradient
  15550. * @param gradient defines the gradient to remove
  15551. * @returns the current particle system
  15552. */
  15553. removeDragGradient(gradient: number): IParticleSystem;
  15554. /**
  15555. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15556. * @param gradient defines the gradient to use (between 0 and 1)
  15557. * @param factor defines the emit rate value to affect to the specified gradient
  15558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15559. * @returns the current particle system
  15560. */
  15561. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15562. /**
  15563. * Remove a specific emit rate gradient
  15564. * @param gradient defines the gradient to remove
  15565. * @returns the current particle system
  15566. */
  15567. removeEmitRateGradient(gradient: number): IParticleSystem;
  15568. /**
  15569. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15570. * @param gradient defines the gradient to use (between 0 and 1)
  15571. * @param factor defines the start size value to affect to the specified gradient
  15572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15573. * @returns the current particle system
  15574. */
  15575. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15576. /**
  15577. * Remove a specific start size gradient
  15578. * @param gradient defines the gradient to remove
  15579. * @returns the current particle system
  15580. */
  15581. removeStartSizeGradient(gradient: number): IParticleSystem;
  15582. private _createRampGradientTexture;
  15583. /**
  15584. * Gets the current list of ramp gradients.
  15585. * You must use addRampGradient and removeRampGradient to udpate this list
  15586. * @returns the list of ramp gradients
  15587. */
  15588. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15589. /**
  15590. * Adds a new ramp gradient used to remap particle colors
  15591. * @param gradient defines the gradient to use (between 0 and 1)
  15592. * @param color defines the color to affect to the specified gradient
  15593. * @returns the current particle system
  15594. */
  15595. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15596. /**
  15597. * Remove a specific ramp gradient
  15598. * @param gradient defines the gradient to remove
  15599. * @returns the current particle system
  15600. */
  15601. removeRampGradient(gradient: number): ParticleSystem;
  15602. /**
  15603. * Adds a new color gradient
  15604. * @param gradient defines the gradient to use (between 0 and 1)
  15605. * @param color1 defines the color to affect to the specified gradient
  15606. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15607. * @returns this particle system
  15608. */
  15609. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15610. /**
  15611. * Remove a specific color gradient
  15612. * @param gradient defines the gradient to remove
  15613. * @returns this particle system
  15614. */
  15615. removeColorGradient(gradient: number): IParticleSystem;
  15616. private _fetchR;
  15617. protected _reset(): void;
  15618. private _resetEffect;
  15619. private _createVertexBuffers;
  15620. private _createIndexBuffer;
  15621. /**
  15622. * Gets the maximum number of particles active at the same time.
  15623. * @returns The max number of active particles.
  15624. */
  15625. getCapacity(): number;
  15626. /**
  15627. * Gets whether there are still active particles in the system.
  15628. * @returns True if it is alive, otherwise false.
  15629. */
  15630. isAlive(): boolean;
  15631. /**
  15632. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15633. * @returns True if it has been started, otherwise false.
  15634. */
  15635. isStarted(): boolean;
  15636. private _prepareSubEmitterInternalArray;
  15637. /**
  15638. * Starts the particle system and begins to emit
  15639. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15640. */
  15641. start(delay?: number): void;
  15642. /**
  15643. * Stops the particle system.
  15644. * @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.
  15645. */
  15646. stop(stopSubEmitters?: boolean): void;
  15647. /**
  15648. * Remove all active particles
  15649. */
  15650. reset(): void;
  15651. /**
  15652. * @hidden (for internal use only)
  15653. */
  15654. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15655. /**
  15656. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15657. * Its lifetime will start back at 0.
  15658. */
  15659. recycleParticle: (particle: Particle) => void;
  15660. private _stopSubEmitters;
  15661. private _createParticle;
  15662. private _removeFromRoot;
  15663. private _emitFromParticle;
  15664. private _update;
  15665. /** @hidden */
  15666. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15667. /** @hidden */
  15668. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15669. /** @hidden */
  15670. private _getEffect;
  15671. /**
  15672. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15673. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15674. */
  15675. animate(preWarmOnly?: boolean): void;
  15676. private _appendParticleVertices;
  15677. /**
  15678. * Rebuilds the particle system.
  15679. */
  15680. rebuild(): void;
  15681. /**
  15682. * Is this system ready to be used/rendered
  15683. * @return true if the system is ready
  15684. */
  15685. isReady(): boolean;
  15686. private _render;
  15687. /**
  15688. * Renders the particle system in its current state.
  15689. * @returns the current number of particles
  15690. */
  15691. render(): number;
  15692. /**
  15693. * Disposes the particle system and free the associated resources
  15694. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15695. */
  15696. dispose(disposeTexture?: boolean): void;
  15697. /**
  15698. * Clones the particle system.
  15699. * @param name The name of the cloned object
  15700. * @param newEmitter The new emitter to use
  15701. * @returns the cloned particle system
  15702. */
  15703. clone(name: string, newEmitter: any): ParticleSystem;
  15704. /**
  15705. * Serializes the particle system to a JSON object.
  15706. * @returns the JSON object
  15707. */
  15708. serialize(): any;
  15709. /** @hidden */
  15710. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15711. /** @hidden */
  15712. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15713. /**
  15714. * Parses a JSON object to create a particle system.
  15715. * @param parsedParticleSystem The JSON object to parse
  15716. * @param scene The scene to create the particle system in
  15717. * @param rootUrl The root url to use to load external dependencies like texture
  15718. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15719. * @returns the Parsed particle system
  15720. */
  15721. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15722. }
  15723. }
  15724. declare module "babylonjs/Particles/particle" {
  15725. import { Nullable } from "babylonjs/types";
  15726. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15727. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15728. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15729. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15730. /**
  15731. * A particle represents one of the element emitted by a particle system.
  15732. * This is mainly define by its coordinates, direction, velocity and age.
  15733. */
  15734. export class Particle {
  15735. /**
  15736. * The particle system the particle belongs to.
  15737. */
  15738. particleSystem: ParticleSystem;
  15739. private static _Count;
  15740. /**
  15741. * Unique ID of the particle
  15742. */
  15743. id: number;
  15744. /**
  15745. * The world position of the particle in the scene.
  15746. */
  15747. position: Vector3;
  15748. /**
  15749. * The world direction of the particle in the scene.
  15750. */
  15751. direction: Vector3;
  15752. /**
  15753. * The color of the particle.
  15754. */
  15755. color: Color4;
  15756. /**
  15757. * The color change of the particle per step.
  15758. */
  15759. colorStep: Color4;
  15760. /**
  15761. * Defines how long will the life of the particle be.
  15762. */
  15763. lifeTime: number;
  15764. /**
  15765. * The current age of the particle.
  15766. */
  15767. age: number;
  15768. /**
  15769. * The current size of the particle.
  15770. */
  15771. size: number;
  15772. /**
  15773. * The current scale of the particle.
  15774. */
  15775. scale: Vector2;
  15776. /**
  15777. * The current angle of the particle.
  15778. */
  15779. angle: number;
  15780. /**
  15781. * Defines how fast is the angle changing.
  15782. */
  15783. angularSpeed: number;
  15784. /**
  15785. * Defines the cell index used by the particle to be rendered from a sprite.
  15786. */
  15787. cellIndex: number;
  15788. /**
  15789. * The information required to support color remapping
  15790. */
  15791. remapData: Vector4;
  15792. /** @hidden */
  15793. _randomCellOffset?: number;
  15794. /** @hidden */
  15795. _initialDirection: Nullable<Vector3>;
  15796. /** @hidden */
  15797. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15798. /** @hidden */
  15799. _initialStartSpriteCellID: number;
  15800. /** @hidden */
  15801. _initialEndSpriteCellID: number;
  15802. /** @hidden */
  15803. _currentColorGradient: Nullable<ColorGradient>;
  15804. /** @hidden */
  15805. _currentColor1: Color4;
  15806. /** @hidden */
  15807. _currentColor2: Color4;
  15808. /** @hidden */
  15809. _currentSizeGradient: Nullable<FactorGradient>;
  15810. /** @hidden */
  15811. _currentSize1: number;
  15812. /** @hidden */
  15813. _currentSize2: number;
  15814. /** @hidden */
  15815. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15816. /** @hidden */
  15817. _currentAngularSpeed1: number;
  15818. /** @hidden */
  15819. _currentAngularSpeed2: number;
  15820. /** @hidden */
  15821. _currentVelocityGradient: Nullable<FactorGradient>;
  15822. /** @hidden */
  15823. _currentVelocity1: number;
  15824. /** @hidden */
  15825. _currentVelocity2: number;
  15826. /** @hidden */
  15827. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15828. /** @hidden */
  15829. _currentLimitVelocity1: number;
  15830. /** @hidden */
  15831. _currentLimitVelocity2: number;
  15832. /** @hidden */
  15833. _currentDragGradient: Nullable<FactorGradient>;
  15834. /** @hidden */
  15835. _currentDrag1: number;
  15836. /** @hidden */
  15837. _currentDrag2: number;
  15838. /** @hidden */
  15839. _randomNoiseCoordinates1: Vector3;
  15840. /** @hidden */
  15841. _randomNoiseCoordinates2: Vector3;
  15842. /**
  15843. * Creates a new instance Particle
  15844. * @param particleSystem the particle system the particle belongs to
  15845. */
  15846. constructor(
  15847. /**
  15848. * The particle system the particle belongs to.
  15849. */
  15850. particleSystem: ParticleSystem);
  15851. private updateCellInfoFromSystem;
  15852. /**
  15853. * Defines how the sprite cell index is updated for the particle
  15854. */
  15855. updateCellIndex(): void;
  15856. /** @hidden */
  15857. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15858. /** @hidden */
  15859. _inheritParticleInfoToSubEmitters(): void;
  15860. /** @hidden */
  15861. _reset(): void;
  15862. /**
  15863. * Copy the properties of particle to another one.
  15864. * @param other the particle to copy the information to.
  15865. */
  15866. copyTo(other: Particle): void;
  15867. }
  15868. }
  15869. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15870. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15871. import { Effect } from "babylonjs/Materials/effect";
  15872. import { Particle } from "babylonjs/Particles/particle";
  15873. /**
  15874. * Particle emitter represents a volume emitting particles.
  15875. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15876. */
  15877. export interface IParticleEmitterType {
  15878. /**
  15879. * Called by the particle System when the direction is computed for the created particle.
  15880. * @param worldMatrix is the world matrix of the particle system
  15881. * @param directionToUpdate is the direction vector to update with the result
  15882. * @param particle is the particle we are computed the direction for
  15883. */
  15884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15885. /**
  15886. * Called by the particle System when the position is computed for the created particle.
  15887. * @param worldMatrix is the world matrix of the particle system
  15888. * @param positionToUpdate is the position vector to update with the result
  15889. * @param particle is the particle we are computed the position for
  15890. */
  15891. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15892. /**
  15893. * Clones the current emitter and returns a copy of it
  15894. * @returns the new emitter
  15895. */
  15896. clone(): IParticleEmitterType;
  15897. /**
  15898. * Called by the GPUParticleSystem to setup the update shader
  15899. * @param effect defines the update shader
  15900. */
  15901. applyToShader(effect: Effect): void;
  15902. /**
  15903. * Returns a string to use to update the GPU particles update shader
  15904. * @returns the effect defines string
  15905. */
  15906. getEffectDefines(): string;
  15907. /**
  15908. * Returns a string representing the class name
  15909. * @returns a string containing the class name
  15910. */
  15911. getClassName(): string;
  15912. /**
  15913. * Serializes the particle system to a JSON object.
  15914. * @returns the JSON object
  15915. */
  15916. serialize(): any;
  15917. /**
  15918. * Parse properties from a JSON object
  15919. * @param serializationObject defines the JSON object
  15920. */
  15921. parse(serializationObject: any): void;
  15922. }
  15923. }
  15924. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15925. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15926. import { Effect } from "babylonjs/Materials/effect";
  15927. import { Particle } from "babylonjs/Particles/particle";
  15928. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15929. /**
  15930. * Particle emitter emitting particles from the inside of a box.
  15931. * It emits the particles randomly between 2 given directions.
  15932. */
  15933. export class BoxParticleEmitter implements IParticleEmitterType {
  15934. /**
  15935. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15936. */
  15937. direction1: Vector3;
  15938. /**
  15939. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15940. */
  15941. direction2: Vector3;
  15942. /**
  15943. * 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.
  15944. */
  15945. minEmitBox: Vector3;
  15946. /**
  15947. * 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.
  15948. */
  15949. maxEmitBox: Vector3;
  15950. /**
  15951. * Creates a new instance BoxParticleEmitter
  15952. */
  15953. constructor();
  15954. /**
  15955. * Called by the particle System when the direction is computed for the created particle.
  15956. * @param worldMatrix is the world matrix of the particle system
  15957. * @param directionToUpdate is the direction vector to update with the result
  15958. * @param particle is the particle we are computed the direction for
  15959. */
  15960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15961. /**
  15962. * Called by the particle System when the position is computed for the created particle.
  15963. * @param worldMatrix is the world matrix of the particle system
  15964. * @param positionToUpdate is the position vector to update with the result
  15965. * @param particle is the particle we are computed the position for
  15966. */
  15967. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15968. /**
  15969. * Clones the current emitter and returns a copy of it
  15970. * @returns the new emitter
  15971. */
  15972. clone(): BoxParticleEmitter;
  15973. /**
  15974. * Called by the GPUParticleSystem to setup the update shader
  15975. * @param effect defines the update shader
  15976. */
  15977. applyToShader(effect: Effect): void;
  15978. /**
  15979. * Returns a string to use to update the GPU particles update shader
  15980. * @returns a string containng the defines string
  15981. */
  15982. getEffectDefines(): string;
  15983. /**
  15984. * Returns the string "BoxParticleEmitter"
  15985. * @returns a string containing the class name
  15986. */
  15987. getClassName(): string;
  15988. /**
  15989. * Serializes the particle system to a JSON object.
  15990. * @returns the JSON object
  15991. */
  15992. serialize(): any;
  15993. /**
  15994. * Parse properties from a JSON object
  15995. * @param serializationObject defines the JSON object
  15996. */
  15997. parse(serializationObject: any): void;
  15998. }
  15999. }
  16000. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16001. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16002. import { Effect } from "babylonjs/Materials/effect";
  16003. import { Particle } from "babylonjs/Particles/particle";
  16004. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16005. /**
  16006. * Particle emitter emitting particles from the inside of a cone.
  16007. * It emits the particles alongside the cone volume from the base to the particle.
  16008. * The emission direction might be randomized.
  16009. */
  16010. export class ConeParticleEmitter implements IParticleEmitterType {
  16011. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16012. directionRandomizer: number;
  16013. private _radius;
  16014. private _angle;
  16015. private _height;
  16016. /**
  16017. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16018. */
  16019. radiusRange: number;
  16020. /**
  16021. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16022. */
  16023. heightRange: number;
  16024. /**
  16025. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16026. */
  16027. emitFromSpawnPointOnly: boolean;
  16028. /**
  16029. * Gets or sets the radius of the emission cone
  16030. */
  16031. radius: number;
  16032. /**
  16033. * Gets or sets the angle of the emission cone
  16034. */
  16035. angle: number;
  16036. private _buildHeight;
  16037. /**
  16038. * Creates a new instance ConeParticleEmitter
  16039. * @param radius the radius of the emission cone (1 by default)
  16040. * @param angle the cone base angle (PI by default)
  16041. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16042. */
  16043. constructor(radius?: number, angle?: number,
  16044. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16045. directionRandomizer?: number);
  16046. /**
  16047. * Called by the particle System when the direction is computed for the created particle.
  16048. * @param worldMatrix is the world matrix of the particle system
  16049. * @param directionToUpdate is the direction vector to update with the result
  16050. * @param particle is the particle we are computed the direction for
  16051. */
  16052. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16053. /**
  16054. * Called by the particle System when the position is computed for the created particle.
  16055. * @param worldMatrix is the world matrix of the particle system
  16056. * @param positionToUpdate is the position vector to update with the result
  16057. * @param particle is the particle we are computed the position for
  16058. */
  16059. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16060. /**
  16061. * Clones the current emitter and returns a copy of it
  16062. * @returns the new emitter
  16063. */
  16064. clone(): ConeParticleEmitter;
  16065. /**
  16066. * Called by the GPUParticleSystem to setup the update shader
  16067. * @param effect defines the update shader
  16068. */
  16069. applyToShader(effect: Effect): void;
  16070. /**
  16071. * Returns a string to use to update the GPU particles update shader
  16072. * @returns a string containng the defines string
  16073. */
  16074. getEffectDefines(): string;
  16075. /**
  16076. * Returns the string "ConeParticleEmitter"
  16077. * @returns a string containing the class name
  16078. */
  16079. getClassName(): string;
  16080. /**
  16081. * Serializes the particle system to a JSON object.
  16082. * @returns the JSON object
  16083. */
  16084. serialize(): any;
  16085. /**
  16086. * Parse properties from a JSON object
  16087. * @param serializationObject defines the JSON object
  16088. */
  16089. parse(serializationObject: any): void;
  16090. }
  16091. }
  16092. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16093. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16094. import { Effect } from "babylonjs/Materials/effect";
  16095. import { Particle } from "babylonjs/Particles/particle";
  16096. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16097. /**
  16098. * Particle emitter emitting particles from the inside of a cylinder.
  16099. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16100. */
  16101. export class CylinderParticleEmitter implements IParticleEmitterType {
  16102. /**
  16103. * The radius of the emission cylinder.
  16104. */
  16105. radius: number;
  16106. /**
  16107. * The height of the emission cylinder.
  16108. */
  16109. height: number;
  16110. /**
  16111. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16112. */
  16113. radiusRange: number;
  16114. /**
  16115. * How much to randomize the particle direction [0-1].
  16116. */
  16117. directionRandomizer: number;
  16118. /**
  16119. * Creates a new instance CylinderParticleEmitter
  16120. * @param radius the radius of the emission cylinder (1 by default)
  16121. * @param height the height of the emission cylinder (1 by default)
  16122. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16123. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16124. */
  16125. constructor(
  16126. /**
  16127. * The radius of the emission cylinder.
  16128. */
  16129. radius?: number,
  16130. /**
  16131. * The height of the emission cylinder.
  16132. */
  16133. height?: number,
  16134. /**
  16135. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16136. */
  16137. radiusRange?: number,
  16138. /**
  16139. * How much to randomize the particle direction [0-1].
  16140. */
  16141. directionRandomizer?: number);
  16142. /**
  16143. * Called by the particle System when the direction is computed for the created particle.
  16144. * @param worldMatrix is the world matrix of the particle system
  16145. * @param directionToUpdate is the direction vector to update with the result
  16146. * @param particle is the particle we are computed the direction for
  16147. */
  16148. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16149. /**
  16150. * Called by the particle System when the position is computed for the created particle.
  16151. * @param worldMatrix is the world matrix of the particle system
  16152. * @param positionToUpdate is the position vector to update with the result
  16153. * @param particle is the particle we are computed the position for
  16154. */
  16155. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16156. /**
  16157. * Clones the current emitter and returns a copy of it
  16158. * @returns the new emitter
  16159. */
  16160. clone(): CylinderParticleEmitter;
  16161. /**
  16162. * Called by the GPUParticleSystem to setup the update shader
  16163. * @param effect defines the update shader
  16164. */
  16165. applyToShader(effect: Effect): void;
  16166. /**
  16167. * Returns a string to use to update the GPU particles update shader
  16168. * @returns a string containng the defines string
  16169. */
  16170. getEffectDefines(): string;
  16171. /**
  16172. * Returns the string "CylinderParticleEmitter"
  16173. * @returns a string containing the class name
  16174. */
  16175. getClassName(): string;
  16176. /**
  16177. * Serializes the particle system to a JSON object.
  16178. * @returns the JSON object
  16179. */
  16180. serialize(): any;
  16181. /**
  16182. * Parse properties from a JSON object
  16183. * @param serializationObject defines the JSON object
  16184. */
  16185. parse(serializationObject: any): void;
  16186. }
  16187. /**
  16188. * Particle emitter emitting particles from the inside of a cylinder.
  16189. * It emits the particles randomly between two vectors.
  16190. */
  16191. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16192. /**
  16193. * The min limit of the emission direction.
  16194. */
  16195. direction1: Vector3;
  16196. /**
  16197. * The max limit of the emission direction.
  16198. */
  16199. direction2: Vector3;
  16200. /**
  16201. * Creates a new instance CylinderDirectedParticleEmitter
  16202. * @param radius the radius of the emission cylinder (1 by default)
  16203. * @param height the height of the emission cylinder (1 by default)
  16204. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16205. * @param direction1 the min limit of the emission direction (up vector by default)
  16206. * @param direction2 the max limit of the emission direction (up vector by default)
  16207. */
  16208. constructor(radius?: number, height?: number, radiusRange?: number,
  16209. /**
  16210. * The min limit of the emission direction.
  16211. */
  16212. direction1?: Vector3,
  16213. /**
  16214. * The max limit of the emission direction.
  16215. */
  16216. direction2?: Vector3);
  16217. /**
  16218. * Called by the particle System when the direction is computed for the created particle.
  16219. * @param worldMatrix is the world matrix of the particle system
  16220. * @param directionToUpdate is the direction vector to update with the result
  16221. * @param particle is the particle we are computed the direction for
  16222. */
  16223. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16224. /**
  16225. * Clones the current emitter and returns a copy of it
  16226. * @returns the new emitter
  16227. */
  16228. clone(): CylinderDirectedParticleEmitter;
  16229. /**
  16230. * Called by the GPUParticleSystem to setup the update shader
  16231. * @param effect defines the update shader
  16232. */
  16233. applyToShader(effect: Effect): void;
  16234. /**
  16235. * Returns a string to use to update the GPU particles update shader
  16236. * @returns a string containng the defines string
  16237. */
  16238. getEffectDefines(): string;
  16239. /**
  16240. * Returns the string "CylinderDirectedParticleEmitter"
  16241. * @returns a string containing the class name
  16242. */
  16243. getClassName(): string;
  16244. /**
  16245. * Serializes the particle system to a JSON object.
  16246. * @returns the JSON object
  16247. */
  16248. serialize(): any;
  16249. /**
  16250. * Parse properties from a JSON object
  16251. * @param serializationObject defines the JSON object
  16252. */
  16253. parse(serializationObject: any): void;
  16254. }
  16255. }
  16256. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16257. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16258. import { Effect } from "babylonjs/Materials/effect";
  16259. import { Particle } from "babylonjs/Particles/particle";
  16260. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16261. /**
  16262. * Particle emitter emitting particles from the inside of a hemisphere.
  16263. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16264. */
  16265. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16266. /**
  16267. * The radius of the emission hemisphere.
  16268. */
  16269. radius: number;
  16270. /**
  16271. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16272. */
  16273. radiusRange: number;
  16274. /**
  16275. * How much to randomize the particle direction [0-1].
  16276. */
  16277. directionRandomizer: number;
  16278. /**
  16279. * Creates a new instance HemisphericParticleEmitter
  16280. * @param radius the radius of the emission hemisphere (1 by default)
  16281. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16282. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16283. */
  16284. constructor(
  16285. /**
  16286. * The radius of the emission hemisphere.
  16287. */
  16288. radius?: number,
  16289. /**
  16290. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16291. */
  16292. radiusRange?: number,
  16293. /**
  16294. * How much to randomize the particle direction [0-1].
  16295. */
  16296. directionRandomizer?: number);
  16297. /**
  16298. * Called by the particle System when the direction is computed for the created particle.
  16299. * @param worldMatrix is the world matrix of the particle system
  16300. * @param directionToUpdate is the direction vector to update with the result
  16301. * @param particle is the particle we are computed the direction for
  16302. */
  16303. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16304. /**
  16305. * Called by the particle System when the position is computed for the created particle.
  16306. * @param worldMatrix is the world matrix of the particle system
  16307. * @param positionToUpdate is the position vector to update with the result
  16308. * @param particle is the particle we are computed the position for
  16309. */
  16310. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16311. /**
  16312. * Clones the current emitter and returns a copy of it
  16313. * @returns the new emitter
  16314. */
  16315. clone(): HemisphericParticleEmitter;
  16316. /**
  16317. * Called by the GPUParticleSystem to setup the update shader
  16318. * @param effect defines the update shader
  16319. */
  16320. applyToShader(effect: Effect): void;
  16321. /**
  16322. * Returns a string to use to update the GPU particles update shader
  16323. * @returns a string containng the defines string
  16324. */
  16325. getEffectDefines(): string;
  16326. /**
  16327. * Returns the string "HemisphericParticleEmitter"
  16328. * @returns a string containing the class name
  16329. */
  16330. getClassName(): string;
  16331. /**
  16332. * Serializes the particle system to a JSON object.
  16333. * @returns the JSON object
  16334. */
  16335. serialize(): any;
  16336. /**
  16337. * Parse properties from a JSON object
  16338. * @param serializationObject defines the JSON object
  16339. */
  16340. parse(serializationObject: any): void;
  16341. }
  16342. }
  16343. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16344. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16345. import { Effect } from "babylonjs/Materials/effect";
  16346. import { Particle } from "babylonjs/Particles/particle";
  16347. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16348. /**
  16349. * Particle emitter emitting particles from a point.
  16350. * It emits the particles randomly between 2 given directions.
  16351. */
  16352. export class PointParticleEmitter implements IParticleEmitterType {
  16353. /**
  16354. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16355. */
  16356. direction1: Vector3;
  16357. /**
  16358. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16359. */
  16360. direction2: Vector3;
  16361. /**
  16362. * Creates a new instance PointParticleEmitter
  16363. */
  16364. constructor();
  16365. /**
  16366. * Called by the particle System when the direction is computed for the created particle.
  16367. * @param worldMatrix is the world matrix of the particle system
  16368. * @param directionToUpdate is the direction vector to update with the result
  16369. * @param particle is the particle we are computed the direction for
  16370. */
  16371. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16372. /**
  16373. * Called by the particle System when the position is computed for the created particle.
  16374. * @param worldMatrix is the world matrix of the particle system
  16375. * @param positionToUpdate is the position vector to update with the result
  16376. * @param particle is the particle we are computed the position for
  16377. */
  16378. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16379. /**
  16380. * Clones the current emitter and returns a copy of it
  16381. * @returns the new emitter
  16382. */
  16383. clone(): PointParticleEmitter;
  16384. /**
  16385. * Called by the GPUParticleSystem to setup the update shader
  16386. * @param effect defines the update shader
  16387. */
  16388. applyToShader(effect: Effect): void;
  16389. /**
  16390. * Returns a string to use to update the GPU particles update shader
  16391. * @returns a string containng the defines string
  16392. */
  16393. getEffectDefines(): string;
  16394. /**
  16395. * Returns the string "PointParticleEmitter"
  16396. * @returns a string containing the class name
  16397. */
  16398. getClassName(): string;
  16399. /**
  16400. * Serializes the particle system to a JSON object.
  16401. * @returns the JSON object
  16402. */
  16403. serialize(): any;
  16404. /**
  16405. * Parse properties from a JSON object
  16406. * @param serializationObject defines the JSON object
  16407. */
  16408. parse(serializationObject: any): void;
  16409. }
  16410. }
  16411. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16412. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16413. import { Effect } from "babylonjs/Materials/effect";
  16414. import { Particle } from "babylonjs/Particles/particle";
  16415. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16416. /**
  16417. * Particle emitter emitting particles from the inside of a sphere.
  16418. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16419. */
  16420. export class SphereParticleEmitter implements IParticleEmitterType {
  16421. /**
  16422. * The radius of the emission sphere.
  16423. */
  16424. radius: number;
  16425. /**
  16426. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16427. */
  16428. radiusRange: number;
  16429. /**
  16430. * How much to randomize the particle direction [0-1].
  16431. */
  16432. directionRandomizer: number;
  16433. /**
  16434. * Creates a new instance SphereParticleEmitter
  16435. * @param radius the radius of the emission sphere (1 by default)
  16436. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16437. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16438. */
  16439. constructor(
  16440. /**
  16441. * The radius of the emission sphere.
  16442. */
  16443. radius?: number,
  16444. /**
  16445. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16446. */
  16447. radiusRange?: number,
  16448. /**
  16449. * How much to randomize the particle direction [0-1].
  16450. */
  16451. directionRandomizer?: number);
  16452. /**
  16453. * Called by the particle System when the direction is computed for the created particle.
  16454. * @param worldMatrix is the world matrix of the particle system
  16455. * @param directionToUpdate is the direction vector to update with the result
  16456. * @param particle is the particle we are computed the direction for
  16457. */
  16458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16459. /**
  16460. * Called by the particle System when the position is computed for the created particle.
  16461. * @param worldMatrix is the world matrix of the particle system
  16462. * @param positionToUpdate is the position vector to update with the result
  16463. * @param particle is the particle we are computed the position for
  16464. */
  16465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16466. /**
  16467. * Clones the current emitter and returns a copy of it
  16468. * @returns the new emitter
  16469. */
  16470. clone(): SphereParticleEmitter;
  16471. /**
  16472. * Called by the GPUParticleSystem to setup the update shader
  16473. * @param effect defines the update shader
  16474. */
  16475. applyToShader(effect: Effect): void;
  16476. /**
  16477. * Returns a string to use to update the GPU particles update shader
  16478. * @returns a string containng the defines string
  16479. */
  16480. getEffectDefines(): string;
  16481. /**
  16482. * Returns the string "SphereParticleEmitter"
  16483. * @returns a string containing the class name
  16484. */
  16485. getClassName(): string;
  16486. /**
  16487. * Serializes the particle system to a JSON object.
  16488. * @returns the JSON object
  16489. */
  16490. serialize(): any;
  16491. /**
  16492. * Parse properties from a JSON object
  16493. * @param serializationObject defines the JSON object
  16494. */
  16495. parse(serializationObject: any): void;
  16496. }
  16497. /**
  16498. * Particle emitter emitting particles from the inside of a sphere.
  16499. * It emits the particles randomly between two vectors.
  16500. */
  16501. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16502. /**
  16503. * The min limit of the emission direction.
  16504. */
  16505. direction1: Vector3;
  16506. /**
  16507. * The max limit of the emission direction.
  16508. */
  16509. direction2: Vector3;
  16510. /**
  16511. * Creates a new instance SphereDirectedParticleEmitter
  16512. * @param radius the radius of the emission sphere (1 by default)
  16513. * @param direction1 the min limit of the emission direction (up vector by default)
  16514. * @param direction2 the max limit of the emission direction (up vector by default)
  16515. */
  16516. constructor(radius?: number,
  16517. /**
  16518. * The min limit of the emission direction.
  16519. */
  16520. direction1?: Vector3,
  16521. /**
  16522. * The max limit of the emission direction.
  16523. */
  16524. direction2?: Vector3);
  16525. /**
  16526. * Called by the particle System when the direction is computed for the created particle.
  16527. * @param worldMatrix is the world matrix of the particle system
  16528. * @param directionToUpdate is the direction vector to update with the result
  16529. * @param particle is the particle we are computed the direction for
  16530. */
  16531. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16532. /**
  16533. * Clones the current emitter and returns a copy of it
  16534. * @returns the new emitter
  16535. */
  16536. clone(): SphereDirectedParticleEmitter;
  16537. /**
  16538. * Called by the GPUParticleSystem to setup the update shader
  16539. * @param effect defines the update shader
  16540. */
  16541. applyToShader(effect: Effect): void;
  16542. /**
  16543. * Returns a string to use to update the GPU particles update shader
  16544. * @returns a string containng the defines string
  16545. */
  16546. getEffectDefines(): string;
  16547. /**
  16548. * Returns the string "SphereDirectedParticleEmitter"
  16549. * @returns a string containing the class name
  16550. */
  16551. getClassName(): string;
  16552. /**
  16553. * Serializes the particle system to a JSON object.
  16554. * @returns the JSON object
  16555. */
  16556. serialize(): any;
  16557. /**
  16558. * Parse properties from a JSON object
  16559. * @param serializationObject defines the JSON object
  16560. */
  16561. parse(serializationObject: any): void;
  16562. }
  16563. }
  16564. declare module "babylonjs/Particles/EmitterTypes/index" {
  16565. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16566. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16567. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16568. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16569. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16570. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16571. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16572. }
  16573. declare module "babylonjs/Particles/IParticleSystem" {
  16574. import { Nullable } from "babylonjs/types";
  16575. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16578. import { Texture } from "babylonjs/Materials/Textures/texture";
  16579. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16580. import { Scene } from "babylonjs/scene";
  16581. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16582. import { Animation } from "babylonjs/Animations/animation";
  16583. /**
  16584. * Interface representing a particle system in Babylon.js.
  16585. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16586. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16587. */
  16588. export interface IParticleSystem {
  16589. /**
  16590. * List of animations used by the particle system.
  16591. */
  16592. animations: Animation[];
  16593. /**
  16594. * The id of the Particle system.
  16595. */
  16596. id: string;
  16597. /**
  16598. * The name of the Particle system.
  16599. */
  16600. name: string;
  16601. /**
  16602. * The emitter represents the Mesh or position we are attaching the particle system to.
  16603. */
  16604. emitter: Nullable<AbstractMesh | Vector3>;
  16605. /**
  16606. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16607. */
  16608. isBillboardBased: boolean;
  16609. /**
  16610. * The rendering group used by the Particle system to chose when to render.
  16611. */
  16612. renderingGroupId: number;
  16613. /**
  16614. * The layer mask we are rendering the particles through.
  16615. */
  16616. layerMask: number;
  16617. /**
  16618. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16619. */
  16620. updateSpeed: number;
  16621. /**
  16622. * The amount of time the particle system is running (depends of the overall update speed).
  16623. */
  16624. targetStopDuration: number;
  16625. /**
  16626. * The texture used to render each particle. (this can be a spritesheet)
  16627. */
  16628. particleTexture: Nullable<Texture>;
  16629. /**
  16630. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16631. */
  16632. blendMode: number;
  16633. /**
  16634. * Minimum life time of emitting particles.
  16635. */
  16636. minLifeTime: number;
  16637. /**
  16638. * Maximum life time of emitting particles.
  16639. */
  16640. maxLifeTime: number;
  16641. /**
  16642. * Minimum Size of emitting particles.
  16643. */
  16644. minSize: number;
  16645. /**
  16646. * Maximum Size of emitting particles.
  16647. */
  16648. maxSize: number;
  16649. /**
  16650. * Minimum scale of emitting particles on X axis.
  16651. */
  16652. minScaleX: number;
  16653. /**
  16654. * Maximum scale of emitting particles on X axis.
  16655. */
  16656. maxScaleX: number;
  16657. /**
  16658. * Minimum scale of emitting particles on Y axis.
  16659. */
  16660. minScaleY: number;
  16661. /**
  16662. * Maximum scale of emitting particles on Y axis.
  16663. */
  16664. maxScaleY: number;
  16665. /**
  16666. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16667. */
  16668. color1: Color4;
  16669. /**
  16670. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16671. */
  16672. color2: Color4;
  16673. /**
  16674. * Color the particle will have at the end of its lifetime.
  16675. */
  16676. colorDead: Color4;
  16677. /**
  16678. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16679. */
  16680. emitRate: number;
  16681. /**
  16682. * You can use gravity if you want to give an orientation to your particles.
  16683. */
  16684. gravity: Vector3;
  16685. /**
  16686. * Minimum power of emitting particles.
  16687. */
  16688. minEmitPower: number;
  16689. /**
  16690. * Maximum power of emitting particles.
  16691. */
  16692. maxEmitPower: number;
  16693. /**
  16694. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16695. */
  16696. minAngularSpeed: number;
  16697. /**
  16698. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16699. */
  16700. maxAngularSpeed: number;
  16701. /**
  16702. * Gets or sets the minimal initial rotation in radians.
  16703. */
  16704. minInitialRotation: number;
  16705. /**
  16706. * Gets or sets the maximal initial rotation in radians.
  16707. */
  16708. maxInitialRotation: number;
  16709. /**
  16710. * The particle emitter type defines the emitter used by the particle system.
  16711. * It can be for example box, sphere, or cone...
  16712. */
  16713. particleEmitterType: Nullable<IParticleEmitterType>;
  16714. /**
  16715. * Defines the delay in milliseconds before starting the system (0 by default)
  16716. */
  16717. startDelay: number;
  16718. /**
  16719. * 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
  16720. */
  16721. preWarmCycles: number;
  16722. /**
  16723. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16724. */
  16725. preWarmStepOffset: number;
  16726. /**
  16727. * 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)
  16728. */
  16729. spriteCellChangeSpeed: number;
  16730. /**
  16731. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16732. */
  16733. startSpriteCellID: number;
  16734. /**
  16735. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16736. */
  16737. endSpriteCellID: number;
  16738. /**
  16739. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16740. */
  16741. spriteCellWidth: number;
  16742. /**
  16743. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16744. */
  16745. spriteCellHeight: number;
  16746. /**
  16747. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16748. */
  16749. spriteRandomStartCell: boolean;
  16750. /**
  16751. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16752. */
  16753. isAnimationSheetEnabled: boolean;
  16754. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16755. translationPivot: Vector2;
  16756. /**
  16757. * Gets or sets a texture used to add random noise to particle positions
  16758. */
  16759. noiseTexture: Nullable<BaseTexture>;
  16760. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16761. noiseStrength: Vector3;
  16762. /**
  16763. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16764. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16765. */
  16766. billboardMode: number;
  16767. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16768. limitVelocityDamping: number;
  16769. /**
  16770. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16771. */
  16772. beginAnimationOnStart: boolean;
  16773. /**
  16774. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16775. */
  16776. beginAnimationFrom: number;
  16777. /**
  16778. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16779. */
  16780. beginAnimationTo: number;
  16781. /**
  16782. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16783. */
  16784. beginAnimationLoop: boolean;
  16785. /**
  16786. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16787. */
  16788. disposeOnStop: boolean;
  16789. /**
  16790. * Gets the maximum number of particles active at the same time.
  16791. * @returns The max number of active particles.
  16792. */
  16793. getCapacity(): number;
  16794. /**
  16795. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16796. * @returns True if it has been started, otherwise false.
  16797. */
  16798. isStarted(): boolean;
  16799. /**
  16800. * Animates the particle system for this frame.
  16801. */
  16802. animate(): void;
  16803. /**
  16804. * Renders the particle system in its current state.
  16805. * @returns the current number of particles
  16806. */
  16807. render(): number;
  16808. /**
  16809. * Dispose the particle system and frees its associated resources.
  16810. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16811. */
  16812. dispose(disposeTexture?: boolean): void;
  16813. /**
  16814. * Clones the particle system.
  16815. * @param name The name of the cloned object
  16816. * @param newEmitter The new emitter to use
  16817. * @returns the cloned particle system
  16818. */
  16819. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16820. /**
  16821. * Serializes the particle system to a JSON object.
  16822. * @returns the JSON object
  16823. */
  16824. serialize(): any;
  16825. /**
  16826. * Rebuild the particle system
  16827. */
  16828. rebuild(): void;
  16829. /**
  16830. * Starts the particle system and begins to emit
  16831. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16832. */
  16833. start(delay?: number): void;
  16834. /**
  16835. * Stops the particle system.
  16836. */
  16837. stop(): void;
  16838. /**
  16839. * Remove all active particles
  16840. */
  16841. reset(): void;
  16842. /**
  16843. * Is this system ready to be used/rendered
  16844. * @return true if the system is ready
  16845. */
  16846. isReady(): boolean;
  16847. /**
  16848. * Adds a new color gradient
  16849. * @param gradient defines the gradient to use (between 0 and 1)
  16850. * @param color1 defines the color to affect to the specified gradient
  16851. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16852. * @returns the current particle system
  16853. */
  16854. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16855. /**
  16856. * Remove a specific color gradient
  16857. * @param gradient defines the gradient to remove
  16858. * @returns the current particle system
  16859. */
  16860. removeColorGradient(gradient: number): IParticleSystem;
  16861. /**
  16862. * Adds a new size gradient
  16863. * @param gradient defines the gradient to use (between 0 and 1)
  16864. * @param factor defines the size factor to affect to the specified gradient
  16865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16866. * @returns the current particle system
  16867. */
  16868. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16869. /**
  16870. * Remove a specific size gradient
  16871. * @param gradient defines the gradient to remove
  16872. * @returns the current particle system
  16873. */
  16874. removeSizeGradient(gradient: number): IParticleSystem;
  16875. /**
  16876. * Gets the current list of color gradients.
  16877. * You must use addColorGradient and removeColorGradient to udpate this list
  16878. * @returns the list of color gradients
  16879. */
  16880. getColorGradients(): Nullable<Array<ColorGradient>>;
  16881. /**
  16882. * Gets the current list of size gradients.
  16883. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16884. * @returns the list of size gradients
  16885. */
  16886. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16887. /**
  16888. * Gets the current list of angular speed gradients.
  16889. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16890. * @returns the list of angular speed gradients
  16891. */
  16892. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16893. /**
  16894. * Adds a new angular speed gradient
  16895. * @param gradient defines the gradient to use (between 0 and 1)
  16896. * @param factor defines the angular speed to affect to the specified gradient
  16897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16898. * @returns the current particle system
  16899. */
  16900. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16901. /**
  16902. * Remove a specific angular speed gradient
  16903. * @param gradient defines the gradient to remove
  16904. * @returns the current particle system
  16905. */
  16906. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16907. /**
  16908. * Gets the current list of velocity gradients.
  16909. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16910. * @returns the list of velocity gradients
  16911. */
  16912. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16913. /**
  16914. * Adds a new velocity gradient
  16915. * @param gradient defines the gradient to use (between 0 and 1)
  16916. * @param factor defines the velocity to affect to the specified gradient
  16917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16918. * @returns the current particle system
  16919. */
  16920. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16921. /**
  16922. * Remove a specific velocity gradient
  16923. * @param gradient defines the gradient to remove
  16924. * @returns the current particle system
  16925. */
  16926. removeVelocityGradient(gradient: number): IParticleSystem;
  16927. /**
  16928. * Gets the current list of limit velocity gradients.
  16929. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16930. * @returns the list of limit velocity gradients
  16931. */
  16932. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16933. /**
  16934. * Adds a new limit velocity gradient
  16935. * @param gradient defines the gradient to use (between 0 and 1)
  16936. * @param factor defines the limit velocity to affect to the specified gradient
  16937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16938. * @returns the current particle system
  16939. */
  16940. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16941. /**
  16942. * Remove a specific limit velocity gradient
  16943. * @param gradient defines the gradient to remove
  16944. * @returns the current particle system
  16945. */
  16946. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16947. /**
  16948. * Adds a new drag gradient
  16949. * @param gradient defines the gradient to use (between 0 and 1)
  16950. * @param factor defines the drag to affect to the specified gradient
  16951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16952. * @returns the current particle system
  16953. */
  16954. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16955. /**
  16956. * Remove a specific drag gradient
  16957. * @param gradient defines the gradient to remove
  16958. * @returns the current particle system
  16959. */
  16960. removeDragGradient(gradient: number): IParticleSystem;
  16961. /**
  16962. * Gets the current list of drag gradients.
  16963. * You must use addDragGradient and removeDragGradient to udpate this list
  16964. * @returns the list of drag gradients
  16965. */
  16966. getDragGradients(): Nullable<Array<FactorGradient>>;
  16967. /**
  16968. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16969. * @param gradient defines the gradient to use (between 0 and 1)
  16970. * @param factor defines the emit rate to affect to the specified gradient
  16971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16972. * @returns the current particle system
  16973. */
  16974. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16975. /**
  16976. * Remove a specific emit rate gradient
  16977. * @param gradient defines the gradient to remove
  16978. * @returns the current particle system
  16979. */
  16980. removeEmitRateGradient(gradient: number): IParticleSystem;
  16981. /**
  16982. * Gets the current list of emit rate gradients.
  16983. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16984. * @returns the list of emit rate gradients
  16985. */
  16986. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16987. /**
  16988. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16989. * @param gradient defines the gradient to use (between 0 and 1)
  16990. * @param factor defines the start size to affect to the specified gradient
  16991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16992. * @returns the current particle system
  16993. */
  16994. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16995. /**
  16996. * Remove a specific start size gradient
  16997. * @param gradient defines the gradient to remove
  16998. * @returns the current particle system
  16999. */
  17000. removeStartSizeGradient(gradient: number): IParticleSystem;
  17001. /**
  17002. * Gets the current list of start size gradients.
  17003. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17004. * @returns the list of start size gradients
  17005. */
  17006. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17007. /**
  17008. * Adds a new life time gradient
  17009. * @param gradient defines the gradient to use (between 0 and 1)
  17010. * @param factor defines the life time factor to affect to the specified gradient
  17011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17012. * @returns the current particle system
  17013. */
  17014. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17015. /**
  17016. * Remove a specific life time gradient
  17017. * @param gradient defines the gradient to remove
  17018. * @returns the current particle system
  17019. */
  17020. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17021. /**
  17022. * Gets the current list of life time gradients.
  17023. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17024. * @returns the list of life time gradients
  17025. */
  17026. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17027. /**
  17028. * Gets the current list of color gradients.
  17029. * You must use addColorGradient and removeColorGradient to udpate this list
  17030. * @returns the list of color gradients
  17031. */
  17032. getColorGradients(): Nullable<Array<ColorGradient>>;
  17033. /**
  17034. * Adds a new ramp gradient used to remap particle colors
  17035. * @param gradient defines the gradient to use (between 0 and 1)
  17036. * @param color defines the color to affect to the specified gradient
  17037. * @returns the current particle system
  17038. */
  17039. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17040. /**
  17041. * Gets the current list of ramp gradients.
  17042. * You must use addRampGradient and removeRampGradient to udpate this list
  17043. * @returns the list of ramp gradients
  17044. */
  17045. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17046. /** Gets or sets a boolean indicating that ramp gradients must be used
  17047. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17048. */
  17049. useRampGradients: boolean;
  17050. /**
  17051. * Adds a new color remap gradient
  17052. * @param gradient defines the gradient to use (between 0 and 1)
  17053. * @param min defines the color remap minimal range
  17054. * @param max defines the color remap maximal range
  17055. * @returns the current particle system
  17056. */
  17057. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17058. /**
  17059. * Gets the current list of color remap gradients.
  17060. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17061. * @returns the list of color remap gradients
  17062. */
  17063. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17064. /**
  17065. * Adds a new alpha remap gradient
  17066. * @param gradient defines the gradient to use (between 0 and 1)
  17067. * @param min defines the alpha remap minimal range
  17068. * @param max defines the alpha remap maximal range
  17069. * @returns the current particle system
  17070. */
  17071. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17072. /**
  17073. * Gets the current list of alpha remap gradients.
  17074. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17075. * @returns the list of alpha remap gradients
  17076. */
  17077. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17078. /**
  17079. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17080. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17082. * @returns the emitter
  17083. */
  17084. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17085. /**
  17086. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17087. * @param radius The radius of the hemisphere to emit from
  17088. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17089. * @returns the emitter
  17090. */
  17091. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17092. /**
  17093. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17094. * @param radius The radius of the sphere to emit from
  17095. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17096. * @returns the emitter
  17097. */
  17098. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17099. /**
  17100. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17101. * @param radius The radius of the sphere to emit from
  17102. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17103. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17104. * @returns the emitter
  17105. */
  17106. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17107. /**
  17108. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17109. * @param radius The radius of the emission cylinder
  17110. * @param height The height of the emission cylinder
  17111. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17112. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17113. * @returns the emitter
  17114. */
  17115. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17116. /**
  17117. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17118. * @param radius The radius of the cylinder to emit from
  17119. * @param height The height of the emission cylinder
  17120. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17121. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17122. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17123. * @returns the emitter
  17124. */
  17125. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17126. /**
  17127. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17128. * @param radius The radius of the cone to emit from
  17129. * @param angle The base angle of the cone
  17130. * @returns the emitter
  17131. */
  17132. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17133. /**
  17134. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17135. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17136. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17137. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17138. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17139. * @returns the emitter
  17140. */
  17141. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17142. /**
  17143. * Get hosting scene
  17144. * @returns the scene
  17145. */
  17146. getScene(): Scene;
  17147. }
  17148. }
  17149. declare module "babylonjs/Meshes/instancedMesh" {
  17150. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17151. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17152. import { Camera } from "babylonjs/Cameras/camera";
  17153. import { Node } from "babylonjs/node";
  17154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17155. import { Mesh } from "babylonjs/Meshes/mesh";
  17156. import { Material } from "babylonjs/Materials/material";
  17157. import { Skeleton } from "babylonjs/Bones/skeleton";
  17158. import { Light } from "babylonjs/Lights/light";
  17159. /**
  17160. * Creates an instance based on a source mesh.
  17161. */
  17162. export class InstancedMesh extends AbstractMesh {
  17163. private _sourceMesh;
  17164. private _currentLOD;
  17165. /** @hidden */
  17166. _indexInSourceMeshInstanceArray: number;
  17167. constructor(name: string, source: Mesh);
  17168. /**
  17169. * Returns the string "InstancedMesh".
  17170. */
  17171. getClassName(): string;
  17172. /** Gets the list of lights affecting that mesh */
  17173. readonly lightSources: Light[];
  17174. _resyncLightSources(): void;
  17175. _resyncLighSource(light: Light): void;
  17176. _removeLightSource(light: Light): void;
  17177. /**
  17178. * If the source mesh receives shadows
  17179. */
  17180. readonly receiveShadows: boolean;
  17181. /**
  17182. * The material of the source mesh
  17183. */
  17184. readonly material: Nullable<Material>;
  17185. /**
  17186. * Visibility of the source mesh
  17187. */
  17188. readonly visibility: number;
  17189. /**
  17190. * Skeleton of the source mesh
  17191. */
  17192. readonly skeleton: Nullable<Skeleton>;
  17193. /**
  17194. * Rendering ground id of the source mesh
  17195. */
  17196. renderingGroupId: number;
  17197. /**
  17198. * Returns the total number of vertices (integer).
  17199. */
  17200. getTotalVertices(): number;
  17201. /**
  17202. * Returns a positive integer : the total number of indices in this mesh geometry.
  17203. * @returns the numner of indices or zero if the mesh has no geometry.
  17204. */
  17205. getTotalIndices(): number;
  17206. /**
  17207. * The source mesh of the instance
  17208. */
  17209. readonly sourceMesh: Mesh;
  17210. /**
  17211. * Is this node ready to be used/rendered
  17212. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17213. * @return {boolean} is it ready
  17214. */
  17215. isReady(completeCheck?: boolean): boolean;
  17216. /**
  17217. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17218. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17219. * @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.
  17220. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17221. */
  17222. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17223. /**
  17224. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17225. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17226. * The `data` are either a numeric array either a Float32Array.
  17227. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17228. * 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).
  17229. * Note that a new underlying VertexBuffer object is created each call.
  17230. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17231. *
  17232. * Possible `kind` values :
  17233. * - VertexBuffer.PositionKind
  17234. * - VertexBuffer.UVKind
  17235. * - VertexBuffer.UV2Kind
  17236. * - VertexBuffer.UV3Kind
  17237. * - VertexBuffer.UV4Kind
  17238. * - VertexBuffer.UV5Kind
  17239. * - VertexBuffer.UV6Kind
  17240. * - VertexBuffer.ColorKind
  17241. * - VertexBuffer.MatricesIndicesKind
  17242. * - VertexBuffer.MatricesIndicesExtraKind
  17243. * - VertexBuffer.MatricesWeightsKind
  17244. * - VertexBuffer.MatricesWeightsExtraKind
  17245. *
  17246. * Returns the Mesh.
  17247. */
  17248. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17249. /**
  17250. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17251. * If the mesh has no geometry, it is simply returned as it is.
  17252. * The `data` are either a numeric array either a Float32Array.
  17253. * No new underlying VertexBuffer object is created.
  17254. * 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.
  17255. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17256. *
  17257. * Possible `kind` values :
  17258. * - VertexBuffer.PositionKind
  17259. * - VertexBuffer.UVKind
  17260. * - VertexBuffer.UV2Kind
  17261. * - VertexBuffer.UV3Kind
  17262. * - VertexBuffer.UV4Kind
  17263. * - VertexBuffer.UV5Kind
  17264. * - VertexBuffer.UV6Kind
  17265. * - VertexBuffer.ColorKind
  17266. * - VertexBuffer.MatricesIndicesKind
  17267. * - VertexBuffer.MatricesIndicesExtraKind
  17268. * - VertexBuffer.MatricesWeightsKind
  17269. * - VertexBuffer.MatricesWeightsExtraKind
  17270. *
  17271. * Returns the Mesh.
  17272. */
  17273. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17274. /**
  17275. * Sets the mesh indices.
  17276. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17277. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17278. * This method creates a new index buffer each call.
  17279. * Returns the Mesh.
  17280. */
  17281. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17282. /**
  17283. * Boolean : True if the mesh owns the requested kind of data.
  17284. */
  17285. isVerticesDataPresent(kind: string): boolean;
  17286. /**
  17287. * Returns an array of indices (IndicesArray).
  17288. */
  17289. getIndices(): Nullable<IndicesArray>;
  17290. readonly _positions: Nullable<Vector3[]>;
  17291. /**
  17292. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17293. * This means the mesh underlying bounding box and sphere are recomputed.
  17294. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17295. * @returns the current mesh
  17296. */
  17297. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17298. /** @hidden */
  17299. _preActivate(): InstancedMesh;
  17300. /** @hidden */
  17301. _activate(renderId: number): boolean;
  17302. /** @hidden */
  17303. _postActivate(): void;
  17304. getWorldMatrix(): Matrix;
  17305. readonly isAnInstance: boolean;
  17306. /**
  17307. * Returns the current associated LOD AbstractMesh.
  17308. */
  17309. getLOD(camera: Camera): AbstractMesh;
  17310. /** @hidden */
  17311. _syncSubMeshes(): InstancedMesh;
  17312. /** @hidden */
  17313. _generatePointsArray(): boolean;
  17314. /**
  17315. * Creates a new InstancedMesh from the current mesh.
  17316. * - name (string) : the cloned mesh name
  17317. * - newParent (optional Node) : the optional Node to parent the clone to.
  17318. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17319. *
  17320. * Returns the clone.
  17321. */
  17322. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17323. /**
  17324. * Disposes the InstancedMesh.
  17325. * Returns nothing.
  17326. */
  17327. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17328. }
  17329. }
  17330. declare module "babylonjs/Materials/shaderMaterial" {
  17331. import { Scene } from "babylonjs/scene";
  17332. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17334. import { Mesh } from "babylonjs/Meshes/mesh";
  17335. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17336. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17337. import { Texture } from "babylonjs/Materials/Textures/texture";
  17338. import { Material } from "babylonjs/Materials/material";
  17339. /**
  17340. * Defines the options associated with the creation of a shader material.
  17341. */
  17342. export interface IShaderMaterialOptions {
  17343. /**
  17344. * Does the material work in alpha blend mode
  17345. */
  17346. needAlphaBlending: boolean;
  17347. /**
  17348. * Does the material work in alpha test mode
  17349. */
  17350. needAlphaTesting: boolean;
  17351. /**
  17352. * The list of attribute names used in the shader
  17353. */
  17354. attributes: string[];
  17355. /**
  17356. * The list of unifrom names used in the shader
  17357. */
  17358. uniforms: string[];
  17359. /**
  17360. * The list of UBO names used in the shader
  17361. */
  17362. uniformBuffers: string[];
  17363. /**
  17364. * The list of sampler names used in the shader
  17365. */
  17366. samplers: string[];
  17367. /**
  17368. * The list of defines used in the shader
  17369. */
  17370. defines: string[];
  17371. }
  17372. /**
  17373. * 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.
  17374. *
  17375. * This returned material effects how the mesh will look based on the code in the shaders.
  17376. *
  17377. * @see http://doc.babylonjs.com/how_to/shader_material
  17378. */
  17379. export class ShaderMaterial extends Material {
  17380. private _shaderPath;
  17381. private _options;
  17382. private _textures;
  17383. private _textureArrays;
  17384. private _floats;
  17385. private _ints;
  17386. private _floatsArrays;
  17387. private _colors3;
  17388. private _colors3Arrays;
  17389. private _colors4;
  17390. private _vectors2;
  17391. private _vectors3;
  17392. private _vectors4;
  17393. private _matrices;
  17394. private _matrices3x3;
  17395. private _matrices2x2;
  17396. private _vectors2Arrays;
  17397. private _vectors3Arrays;
  17398. private _cachedWorldViewMatrix;
  17399. private _renderId;
  17400. /**
  17401. * Instantiate a new shader material.
  17402. * 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.
  17403. * This returned material effects how the mesh will look based on the code in the shaders.
  17404. * @see http://doc.babylonjs.com/how_to/shader_material
  17405. * @param name Define the name of the material in the scene
  17406. * @param scene Define the scene the material belongs to
  17407. * @param shaderPath Defines the route to the shader code in one of three ways:
  17408. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17409. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17410. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17411. * @param options Define the options used to create the shader
  17412. */
  17413. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17414. /**
  17415. * Gets the options used to compile the shader.
  17416. * They can be modified to trigger a new compilation
  17417. */
  17418. readonly options: IShaderMaterialOptions;
  17419. /**
  17420. * Gets the current class name of the material e.g. "ShaderMaterial"
  17421. * Mainly use in serialization.
  17422. * @returns the class name
  17423. */
  17424. getClassName(): string;
  17425. /**
  17426. * Specifies if the material will require alpha blending
  17427. * @returns a boolean specifying if alpha blending is needed
  17428. */
  17429. needAlphaBlending(): boolean;
  17430. /**
  17431. * Specifies if this material should be rendered in alpha test mode
  17432. * @returns a boolean specifying if an alpha test is needed.
  17433. */
  17434. needAlphaTesting(): boolean;
  17435. private _checkUniform;
  17436. /**
  17437. * Set a texture in the shader.
  17438. * @param name Define the name of the uniform samplers as defined in the shader
  17439. * @param texture Define the texture to bind to this sampler
  17440. * @return the material itself allowing "fluent" like uniform updates
  17441. */
  17442. setTexture(name: string, texture: Texture): ShaderMaterial;
  17443. /**
  17444. * Set a texture array in the shader.
  17445. * @param name Define the name of the uniform sampler array as defined in the shader
  17446. * @param textures Define the list of textures to bind to this sampler
  17447. * @return the material itself allowing "fluent" like uniform updates
  17448. */
  17449. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17450. /**
  17451. * Set a float in the shader.
  17452. * @param name Define the name of the uniform as defined in the shader
  17453. * @param value Define the value to give to the uniform
  17454. * @return the material itself allowing "fluent" like uniform updates
  17455. */
  17456. setFloat(name: string, value: number): ShaderMaterial;
  17457. /**
  17458. * Set a int in the shader.
  17459. * @param name Define the name of the uniform as defined in the shader
  17460. * @param value Define the value to give to the uniform
  17461. * @return the material itself allowing "fluent" like uniform updates
  17462. */
  17463. setInt(name: string, value: number): ShaderMaterial;
  17464. /**
  17465. * Set an array of floats in the shader.
  17466. * @param name Define the name of the uniform as defined in the shader
  17467. * @param value Define the value to give to the uniform
  17468. * @return the material itself allowing "fluent" like uniform updates
  17469. */
  17470. setFloats(name: string, value: number[]): ShaderMaterial;
  17471. /**
  17472. * Set a vec3 in the shader from a Color3.
  17473. * @param name Define the name of the uniform as defined in the shader
  17474. * @param value Define the value to give to the uniform
  17475. * @return the material itself allowing "fluent" like uniform updates
  17476. */
  17477. setColor3(name: string, value: Color3): ShaderMaterial;
  17478. /**
  17479. * Set a vec3 array in the shader from a Color3 array.
  17480. * @param name Define the name of the uniform as defined in the shader
  17481. * @param value Define the value to give to the uniform
  17482. * @return the material itself allowing "fluent" like uniform updates
  17483. */
  17484. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17485. /**
  17486. * Set a vec4 in the shader from a Color4.
  17487. * @param name Define the name of the uniform as defined in the shader
  17488. * @param value Define the value to give to the uniform
  17489. * @return the material itself allowing "fluent" like uniform updates
  17490. */
  17491. setColor4(name: string, value: Color4): ShaderMaterial;
  17492. /**
  17493. * Set a vec2 in the shader from a Vector2.
  17494. * @param name Define the name of the uniform as defined in the shader
  17495. * @param value Define the value to give to the uniform
  17496. * @return the material itself allowing "fluent" like uniform updates
  17497. */
  17498. setVector2(name: string, value: Vector2): ShaderMaterial;
  17499. /**
  17500. * Set a vec3 in the shader from a Vector3.
  17501. * @param name Define the name of the uniform as defined in the shader
  17502. * @param value Define the value to give to the uniform
  17503. * @return the material itself allowing "fluent" like uniform updates
  17504. */
  17505. setVector3(name: string, value: Vector3): ShaderMaterial;
  17506. /**
  17507. * Set a vec4 in the shader from a Vector4.
  17508. * @param name Define the name of the uniform as defined in the shader
  17509. * @param value Define the value to give to the uniform
  17510. * @return the material itself allowing "fluent" like uniform updates
  17511. */
  17512. setVector4(name: string, value: Vector4): ShaderMaterial;
  17513. /**
  17514. * Set a mat4 in the shader from a Matrix.
  17515. * @param name Define the name of the uniform as defined in the shader
  17516. * @param value Define the value to give to the uniform
  17517. * @return the material itself allowing "fluent" like uniform updates
  17518. */
  17519. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17520. /**
  17521. * Set a mat3 in the shader from a Float32Array.
  17522. * @param name Define the name of the uniform as defined in the shader
  17523. * @param value Define the value to give to the uniform
  17524. * @return the material itself allowing "fluent" like uniform updates
  17525. */
  17526. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17527. /**
  17528. * Set a mat2 in the shader from a Float32Array.
  17529. * @param name Define the name of the uniform as defined in the shader
  17530. * @param value Define the value to give to the uniform
  17531. * @return the material itself allowing "fluent" like uniform updates
  17532. */
  17533. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17534. /**
  17535. * Set a vec2 array in the shader from a number array.
  17536. * @param name Define the name of the uniform as defined in the shader
  17537. * @param value Define the value to give to the uniform
  17538. * @return the material itself allowing "fluent" like uniform updates
  17539. */
  17540. setArray2(name: string, value: number[]): ShaderMaterial;
  17541. /**
  17542. * Set a vec3 array in the shader from a number array.
  17543. * @param name Define the name of the uniform as defined in the shader
  17544. * @param value Define the value to give to the uniform
  17545. * @return the material itself allowing "fluent" like uniform updates
  17546. */
  17547. setArray3(name: string, value: number[]): ShaderMaterial;
  17548. private _checkCache;
  17549. /**
  17550. * Specifies that the submesh is ready to be used
  17551. * @param mesh defines the mesh to check
  17552. * @param subMesh defines which submesh to check
  17553. * @param useInstances specifies that instances should be used
  17554. * @returns a boolean indicating that the submesh is ready or not
  17555. */
  17556. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17557. /**
  17558. * Checks if the material is ready to render the requested mesh
  17559. * @param mesh Define the mesh to render
  17560. * @param useInstances Define whether or not the material is used with instances
  17561. * @returns true if ready, otherwise false
  17562. */
  17563. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17564. /**
  17565. * Binds the world matrix to the material
  17566. * @param world defines the world transformation matrix
  17567. */
  17568. bindOnlyWorldMatrix(world: Matrix): void;
  17569. /**
  17570. * Binds the material to the mesh
  17571. * @param world defines the world transformation matrix
  17572. * @param mesh defines the mesh to bind the material to
  17573. */
  17574. bind(world: Matrix, mesh?: Mesh): void;
  17575. /**
  17576. * Gets the active textures from the material
  17577. * @returns an array of textures
  17578. */
  17579. getActiveTextures(): BaseTexture[];
  17580. /**
  17581. * Specifies if the material uses a texture
  17582. * @param texture defines the texture to check against the material
  17583. * @returns a boolean specifying if the material uses the texture
  17584. */
  17585. hasTexture(texture: BaseTexture): boolean;
  17586. /**
  17587. * Makes a duplicate of the material, and gives it a new name
  17588. * @param name defines the new name for the duplicated material
  17589. * @returns the cloned material
  17590. */
  17591. clone(name: string): ShaderMaterial;
  17592. /**
  17593. * Disposes the material
  17594. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17595. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17596. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17597. */
  17598. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17599. /**
  17600. * Serializes this material in a JSON representation
  17601. * @returns the serialized material object
  17602. */
  17603. serialize(): any;
  17604. /**
  17605. * Creates a shader material from parsed shader material data
  17606. * @param source defines the JSON represnetation of the material
  17607. * @param scene defines the hosting scene
  17608. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17609. * @returns a new material
  17610. */
  17611. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17612. }
  17613. }
  17614. declare module "babylonjs/Shaders/color.fragment" {
  17615. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17616. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17617. /** @hidden */
  17618. export var colorPixelShader: {
  17619. name: string;
  17620. shader: string;
  17621. };
  17622. }
  17623. declare module "babylonjs/Shaders/color.vertex" {
  17624. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17625. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17626. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17627. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17628. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17629. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17630. /** @hidden */
  17631. export var colorVertexShader: {
  17632. name: string;
  17633. shader: string;
  17634. };
  17635. }
  17636. declare module "babylonjs/Meshes/linesMesh" {
  17637. import { Nullable } from "babylonjs/types";
  17638. import { Scene } from "babylonjs/scene";
  17639. import { Color3 } from "babylonjs/Maths/math";
  17640. import { Node } from "babylonjs/node";
  17641. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17642. import { Mesh } from "babylonjs/Meshes/mesh";
  17643. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17644. import { Effect } from "babylonjs/Materials/effect";
  17645. import { Material } from "babylonjs/Materials/material";
  17646. import "babylonjs/Shaders/color.fragment";
  17647. import "babylonjs/Shaders/color.vertex";
  17648. /**
  17649. * Line mesh
  17650. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17651. */
  17652. export class LinesMesh extends Mesh {
  17653. /**
  17654. * If vertex color should be applied to the mesh
  17655. */
  17656. useVertexColor?: boolean | undefined;
  17657. /**
  17658. * If vertex alpha should be applied to the mesh
  17659. */
  17660. useVertexAlpha?: boolean | undefined;
  17661. /**
  17662. * Color of the line (Default: White)
  17663. */
  17664. color: Color3;
  17665. /**
  17666. * Alpha of the line (Default: 1)
  17667. */
  17668. alpha: number;
  17669. /**
  17670. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17671. * This margin is expressed in world space coordinates, so its value may vary.
  17672. * Default value is 0.1
  17673. */
  17674. intersectionThreshold: number;
  17675. private _colorShader;
  17676. /**
  17677. * Creates a new LinesMesh
  17678. * @param name defines the name
  17679. * @param scene defines the hosting scene
  17680. * @param parent defines the parent mesh if any
  17681. * @param source defines the optional source LinesMesh used to clone data from
  17682. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17683. * When false, achieved by calling a clone(), also passing False.
  17684. * This will make creation of children, recursive.
  17685. * @param useVertexColor defines if this LinesMesh supports vertex color
  17686. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17687. */
  17688. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17689. /**
  17690. * If vertex color should be applied to the mesh
  17691. */
  17692. useVertexColor?: boolean | undefined,
  17693. /**
  17694. * If vertex alpha should be applied to the mesh
  17695. */
  17696. useVertexAlpha?: boolean | undefined);
  17697. private _addClipPlaneDefine;
  17698. private _removeClipPlaneDefine;
  17699. isReady(): boolean;
  17700. /**
  17701. * Returns the string "LineMesh"
  17702. */
  17703. getClassName(): string;
  17704. /**
  17705. * @hidden
  17706. */
  17707. /**
  17708. * @hidden
  17709. */
  17710. material: Material;
  17711. /**
  17712. * @hidden
  17713. */
  17714. readonly checkCollisions: boolean;
  17715. /** @hidden */
  17716. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17717. /** @hidden */
  17718. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17719. /**
  17720. * Disposes of the line mesh
  17721. * @param doNotRecurse If children should be disposed
  17722. */
  17723. dispose(doNotRecurse?: boolean): void;
  17724. /**
  17725. * Returns a new LineMesh object cloned from the current one.
  17726. */
  17727. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17728. /**
  17729. * Creates a new InstancedLinesMesh object from the mesh model.
  17730. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17731. * @param name defines the name of the new instance
  17732. * @returns a new InstancedLinesMesh
  17733. */
  17734. createInstance(name: string): InstancedLinesMesh;
  17735. }
  17736. /**
  17737. * Creates an instance based on a source LinesMesh
  17738. */
  17739. export class InstancedLinesMesh extends InstancedMesh {
  17740. /**
  17741. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17742. * This margin is expressed in world space coordinates, so its value may vary.
  17743. * Initilized with the intersectionThreshold value of the source LinesMesh
  17744. */
  17745. intersectionThreshold: number;
  17746. constructor(name: string, source: LinesMesh);
  17747. /**
  17748. * Returns the string "InstancedLinesMesh".
  17749. */
  17750. getClassName(): string;
  17751. }
  17752. }
  17753. declare module "babylonjs/Shaders/line.fragment" {
  17754. /** @hidden */
  17755. export var linePixelShader: {
  17756. name: string;
  17757. shader: string;
  17758. };
  17759. }
  17760. declare module "babylonjs/Shaders/line.vertex" {
  17761. /** @hidden */
  17762. export var lineVertexShader: {
  17763. name: string;
  17764. shader: string;
  17765. };
  17766. }
  17767. declare module "babylonjs/Rendering/edgesRenderer" {
  17768. import { Nullable } from "babylonjs/types";
  17769. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17771. import { Vector3 } from "babylonjs/Maths/math";
  17772. import { IDisposable } from "babylonjs/scene";
  17773. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17774. import "babylonjs/Shaders/line.fragment";
  17775. import "babylonjs/Shaders/line.vertex";
  17776. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17777. module "babylonjs/Meshes/abstractMesh" {
  17778. interface AbstractMesh {
  17779. /**
  17780. * Disables the mesh edge rendering mode
  17781. * @returns the currentAbstractMesh
  17782. */
  17783. disableEdgesRendering(): AbstractMesh;
  17784. /**
  17785. * Enables the edge rendering mode on the mesh.
  17786. * This mode makes the mesh edges visible
  17787. * @param epsilon defines the maximal distance between two angles to detect a face
  17788. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17789. * @returns the currentAbstractMesh
  17790. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17791. */
  17792. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17793. /**
  17794. * Gets the edgesRenderer associated with the mesh
  17795. */
  17796. edgesRenderer: Nullable<EdgesRenderer>;
  17797. }
  17798. }
  17799. module "babylonjs/Meshes/linesMesh" {
  17800. interface LinesMesh {
  17801. /**
  17802. * Enables the edge rendering mode on the mesh.
  17803. * This mode makes the mesh edges visible
  17804. * @param epsilon defines the maximal distance between two angles to detect a face
  17805. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17806. * @returns the currentAbstractMesh
  17807. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17808. */
  17809. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17810. }
  17811. }
  17812. module "babylonjs/Meshes/linesMesh" {
  17813. interface InstancedLinesMesh {
  17814. /**
  17815. * Enables the edge rendering mode on the mesh.
  17816. * This mode makes the mesh edges visible
  17817. * @param epsilon defines the maximal distance between two angles to detect a face
  17818. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17819. * @returns the current InstancedLinesMesh
  17820. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17821. */
  17822. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17823. }
  17824. }
  17825. /**
  17826. * Defines the minimum contract an Edges renderer should follow.
  17827. */
  17828. export interface IEdgesRenderer extends IDisposable {
  17829. /**
  17830. * Gets or sets a boolean indicating if the edgesRenderer is active
  17831. */
  17832. isEnabled: boolean;
  17833. /**
  17834. * Renders the edges of the attached mesh,
  17835. */
  17836. render(): void;
  17837. /**
  17838. * Checks wether or not the edges renderer is ready to render.
  17839. * @return true if ready, otherwise false.
  17840. */
  17841. isReady(): boolean;
  17842. }
  17843. /**
  17844. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17845. */
  17846. export class EdgesRenderer implements IEdgesRenderer {
  17847. /**
  17848. * Define the size of the edges with an orthographic camera
  17849. */
  17850. edgesWidthScalerForOrthographic: number;
  17851. /**
  17852. * Define the size of the edges with a perspective camera
  17853. */
  17854. edgesWidthScalerForPerspective: number;
  17855. protected _source: AbstractMesh;
  17856. protected _linesPositions: number[];
  17857. protected _linesNormals: number[];
  17858. protected _linesIndices: number[];
  17859. protected _epsilon: number;
  17860. protected _indicesCount: number;
  17861. protected _lineShader: ShaderMaterial;
  17862. protected _ib: DataBuffer;
  17863. protected _buffers: {
  17864. [key: string]: Nullable<VertexBuffer>;
  17865. };
  17866. protected _checkVerticesInsteadOfIndices: boolean;
  17867. private _meshRebuildObserver;
  17868. private _meshDisposeObserver;
  17869. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17870. isEnabled: boolean;
  17871. /**
  17872. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17873. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17874. * @param source Mesh used to create edges
  17875. * @param epsilon sum of angles in adjacency to check for edge
  17876. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17877. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17878. */
  17879. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17880. protected _prepareRessources(): void;
  17881. /** @hidden */
  17882. _rebuild(): void;
  17883. /**
  17884. * Releases the required resources for the edges renderer
  17885. */
  17886. dispose(): void;
  17887. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17888. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17889. /**
  17890. * Checks if the pair of p0 and p1 is en edge
  17891. * @param faceIndex
  17892. * @param edge
  17893. * @param faceNormals
  17894. * @param p0
  17895. * @param p1
  17896. * @private
  17897. */
  17898. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17899. /**
  17900. * push line into the position, normal and index buffer
  17901. * @protected
  17902. */
  17903. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17904. /**
  17905. * Generates lines edges from adjacencjes
  17906. * @private
  17907. */
  17908. _generateEdgesLines(): void;
  17909. /**
  17910. * Checks wether or not the edges renderer is ready to render.
  17911. * @return true if ready, otherwise false.
  17912. */
  17913. isReady(): boolean;
  17914. /**
  17915. * Renders the edges of the attached mesh,
  17916. */
  17917. render(): void;
  17918. }
  17919. /**
  17920. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17921. */
  17922. export class LineEdgesRenderer extends EdgesRenderer {
  17923. /**
  17924. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17925. * @param source LineMesh used to generate edges
  17926. * @param epsilon not important (specified angle for edge detection)
  17927. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17928. */
  17929. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17930. /**
  17931. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17932. */
  17933. _generateEdgesLines(): void;
  17934. }
  17935. }
  17936. declare module "babylonjs/Rendering/renderingGroup" {
  17937. import { SmartArray } from "babylonjs/Misc/smartArray";
  17938. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17940. import { Nullable } from "babylonjs/types";
  17941. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17942. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17943. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17944. import { Material } from "babylonjs/Materials/material";
  17945. import { Scene } from "babylonjs/scene";
  17946. /**
  17947. * This represents the object necessary to create a rendering group.
  17948. * This is exclusively used and created by the rendering manager.
  17949. * To modify the behavior, you use the available helpers in your scene or meshes.
  17950. * @hidden
  17951. */
  17952. export class RenderingGroup {
  17953. index: number;
  17954. private _scene;
  17955. private _opaqueSubMeshes;
  17956. private _transparentSubMeshes;
  17957. private _alphaTestSubMeshes;
  17958. private _depthOnlySubMeshes;
  17959. private _particleSystems;
  17960. private _spriteManagers;
  17961. private _opaqueSortCompareFn;
  17962. private _alphaTestSortCompareFn;
  17963. private _transparentSortCompareFn;
  17964. private _renderOpaque;
  17965. private _renderAlphaTest;
  17966. private _renderTransparent;
  17967. /** @hidden */
  17968. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17969. onBeforeTransparentRendering: () => void;
  17970. /**
  17971. * Set the opaque sort comparison function.
  17972. * If null the sub meshes will be render in the order they were created
  17973. */
  17974. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17975. /**
  17976. * Set the alpha test sort comparison function.
  17977. * If null the sub meshes will be render in the order they were created
  17978. */
  17979. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17980. /**
  17981. * Set the transparent sort comparison function.
  17982. * If null the sub meshes will be render in the order they were created
  17983. */
  17984. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17985. /**
  17986. * Creates a new rendering group.
  17987. * @param index The rendering group index
  17988. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17989. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17990. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17991. */
  17992. 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>);
  17993. /**
  17994. * Render all the sub meshes contained in the group.
  17995. * @param customRenderFunction Used to override the default render behaviour of the group.
  17996. * @returns true if rendered some submeshes.
  17997. */
  17998. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17999. /**
  18000. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  18001. * @param subMeshes The submeshes to render
  18002. */
  18003. private renderOpaqueSorted;
  18004. /**
  18005. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  18006. * @param subMeshes The submeshes to render
  18007. */
  18008. private renderAlphaTestSorted;
  18009. /**
  18010. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  18011. * @param subMeshes The submeshes to render
  18012. */
  18013. private renderTransparentSorted;
  18014. /**
  18015. * Renders the submeshes in a specified order.
  18016. * @param subMeshes The submeshes to sort before render
  18017. * @param sortCompareFn The comparison function use to sort
  18018. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18019. * @param transparent Specifies to activate blending if true
  18020. */
  18021. private static renderSorted;
  18022. /**
  18023. * Renders the submeshes in the order they were dispatched (no sort applied).
  18024. * @param subMeshes The submeshes to render
  18025. */
  18026. private static renderUnsorted;
  18027. /**
  18028. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18029. * are rendered back to front if in the same alpha index.
  18030. *
  18031. * @param a The first submesh
  18032. * @param b The second submesh
  18033. * @returns The result of the comparison
  18034. */
  18035. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18036. /**
  18037. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18038. * are rendered back to front.
  18039. *
  18040. * @param a The first submesh
  18041. * @param b The second submesh
  18042. * @returns The result of the comparison
  18043. */
  18044. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18045. /**
  18046. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18047. * are rendered front to back (prevent overdraw).
  18048. *
  18049. * @param a The first submesh
  18050. * @param b The second submesh
  18051. * @returns The result of the comparison
  18052. */
  18053. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18054. /**
  18055. * Resets the different lists of submeshes to prepare a new frame.
  18056. */
  18057. prepare(): void;
  18058. dispose(): void;
  18059. /**
  18060. * Inserts the submesh in its correct queue depending on its material.
  18061. * @param subMesh The submesh to dispatch
  18062. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18063. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18064. */
  18065. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18066. dispatchSprites(spriteManager: ISpriteManager): void;
  18067. dispatchParticles(particleSystem: IParticleSystem): void;
  18068. private _renderParticles;
  18069. private _renderSprites;
  18070. }
  18071. }
  18072. declare module "babylonjs/Rendering/renderingManager" {
  18073. import { Nullable } from "babylonjs/types";
  18074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18075. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18076. import { SmartArray } from "babylonjs/Misc/smartArray";
  18077. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18078. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18079. import { Material } from "babylonjs/Materials/material";
  18080. import { Scene } from "babylonjs/scene";
  18081. import { Camera } from "babylonjs/Cameras/camera";
  18082. /**
  18083. * Interface describing the different options available in the rendering manager
  18084. * regarding Auto Clear between groups.
  18085. */
  18086. export interface IRenderingManagerAutoClearSetup {
  18087. /**
  18088. * Defines whether or not autoclear is enable.
  18089. */
  18090. autoClear: boolean;
  18091. /**
  18092. * Defines whether or not to autoclear the depth buffer.
  18093. */
  18094. depth: boolean;
  18095. /**
  18096. * Defines whether or not to autoclear the stencil buffer.
  18097. */
  18098. stencil: boolean;
  18099. }
  18100. /**
  18101. * This class is used by the onRenderingGroupObservable
  18102. */
  18103. export class RenderingGroupInfo {
  18104. /**
  18105. * The Scene that being rendered
  18106. */
  18107. scene: Scene;
  18108. /**
  18109. * The camera currently used for the rendering pass
  18110. */
  18111. camera: Nullable<Camera>;
  18112. /**
  18113. * The ID of the renderingGroup being processed
  18114. */
  18115. renderingGroupId: number;
  18116. }
  18117. /**
  18118. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18119. * It is enable to manage the different groups as well as the different necessary sort functions.
  18120. * This should not be used directly aside of the few static configurations
  18121. */
  18122. export class RenderingManager {
  18123. /**
  18124. * The max id used for rendering groups (not included)
  18125. */
  18126. static MAX_RENDERINGGROUPS: number;
  18127. /**
  18128. * The min id used for rendering groups (included)
  18129. */
  18130. static MIN_RENDERINGGROUPS: number;
  18131. /**
  18132. * Used to globally prevent autoclearing scenes.
  18133. */
  18134. static AUTOCLEAR: boolean;
  18135. /**
  18136. * @hidden
  18137. */
  18138. _useSceneAutoClearSetup: boolean;
  18139. private _scene;
  18140. private _renderingGroups;
  18141. private _depthStencilBufferAlreadyCleaned;
  18142. private _autoClearDepthStencil;
  18143. private _customOpaqueSortCompareFn;
  18144. private _customAlphaTestSortCompareFn;
  18145. private _customTransparentSortCompareFn;
  18146. private _renderingGroupInfo;
  18147. /**
  18148. * Instantiates a new rendering group for a particular scene
  18149. * @param scene Defines the scene the groups belongs to
  18150. */
  18151. constructor(scene: Scene);
  18152. private _clearDepthStencilBuffer;
  18153. /**
  18154. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18155. * @hidden
  18156. */
  18157. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18158. /**
  18159. * Resets the different information of the group to prepare a new frame
  18160. * @hidden
  18161. */
  18162. reset(): void;
  18163. /**
  18164. * Dispose and release the group and its associated resources.
  18165. * @hidden
  18166. */
  18167. dispose(): void;
  18168. /**
  18169. * Clear the info related to rendering groups preventing retention points during dispose.
  18170. */
  18171. freeRenderingGroups(): void;
  18172. private _prepareRenderingGroup;
  18173. /**
  18174. * Add a sprite manager to the rendering manager in order to render it this frame.
  18175. * @param spriteManager Define the sprite manager to render
  18176. */
  18177. dispatchSprites(spriteManager: ISpriteManager): void;
  18178. /**
  18179. * Add a particle system to the rendering manager in order to render it this frame.
  18180. * @param particleSystem Define the particle system to render
  18181. */
  18182. dispatchParticles(particleSystem: IParticleSystem): void;
  18183. /**
  18184. * Add a submesh to the manager in order to render it this frame
  18185. * @param subMesh The submesh to dispatch
  18186. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18187. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18188. */
  18189. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18190. /**
  18191. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18192. * This allowed control for front to back rendering or reversly depending of the special needs.
  18193. *
  18194. * @param renderingGroupId The rendering group id corresponding to its index
  18195. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18196. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18197. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18198. */
  18199. 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;
  18200. /**
  18201. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18202. *
  18203. * @param renderingGroupId The rendering group id corresponding to its index
  18204. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18205. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18206. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18207. */
  18208. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18209. /**
  18210. * Gets the current auto clear configuration for one rendering group of the rendering
  18211. * manager.
  18212. * @param index the rendering group index to get the information for
  18213. * @returns The auto clear setup for the requested rendering group
  18214. */
  18215. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18216. }
  18217. }
  18218. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18219. import { Observable } from "babylonjs/Misc/observable";
  18220. import { SmartArray } from "babylonjs/Misc/smartArray";
  18221. import { Nullable } from "babylonjs/types";
  18222. import { Camera } from "babylonjs/Cameras/camera";
  18223. import { Scene } from "babylonjs/scene";
  18224. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18225. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18227. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18228. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18229. import { Texture } from "babylonjs/Materials/Textures/texture";
  18230. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18231. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18232. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18233. import { Engine } from "babylonjs/Engines/engine";
  18234. /**
  18235. * This Helps creating a texture that will be created from a camera in your scene.
  18236. * It is basically a dynamic texture that could be used to create special effects for instance.
  18237. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18238. */
  18239. export class RenderTargetTexture extends Texture {
  18240. isCube: boolean;
  18241. /**
  18242. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18243. */
  18244. static readonly REFRESHRATE_RENDER_ONCE: number;
  18245. /**
  18246. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18247. */
  18248. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18249. /**
  18250. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18251. * the central point of your effect and can save a lot of performances.
  18252. */
  18253. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18254. /**
  18255. * Use this predicate to dynamically define the list of mesh you want to render.
  18256. * If set, the renderList property will be overwritten.
  18257. */
  18258. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18259. private _renderList;
  18260. /**
  18261. * Use this list to define the list of mesh you want to render.
  18262. */
  18263. renderList: Nullable<Array<AbstractMesh>>;
  18264. private _hookArray;
  18265. /**
  18266. * Define if particles should be rendered in your texture.
  18267. */
  18268. renderParticles: boolean;
  18269. /**
  18270. * Define if sprites should be rendered in your texture.
  18271. */
  18272. renderSprites: boolean;
  18273. /**
  18274. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18275. */
  18276. coordinatesMode: number;
  18277. /**
  18278. * Define the camera used to render the texture.
  18279. */
  18280. activeCamera: Nullable<Camera>;
  18281. /**
  18282. * Override the render function of the texture with your own one.
  18283. */
  18284. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18285. /**
  18286. * Define if camera post processes should be use while rendering the texture.
  18287. */
  18288. useCameraPostProcesses: boolean;
  18289. /**
  18290. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18291. */
  18292. ignoreCameraViewport: boolean;
  18293. private _postProcessManager;
  18294. private _postProcesses;
  18295. private _resizeObserver;
  18296. /**
  18297. * An event triggered when the texture is unbind.
  18298. */
  18299. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18300. /**
  18301. * An event triggered when the texture is unbind.
  18302. */
  18303. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18304. private _onAfterUnbindObserver;
  18305. /**
  18306. * Set a after unbind callback in the texture.
  18307. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18308. */
  18309. onAfterUnbind: () => void;
  18310. /**
  18311. * An event triggered before rendering the texture
  18312. */
  18313. onBeforeRenderObservable: Observable<number>;
  18314. private _onBeforeRenderObserver;
  18315. /**
  18316. * Set a before render callback in the texture.
  18317. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18318. */
  18319. onBeforeRender: (faceIndex: number) => void;
  18320. /**
  18321. * An event triggered after rendering the texture
  18322. */
  18323. onAfterRenderObservable: Observable<number>;
  18324. private _onAfterRenderObserver;
  18325. /**
  18326. * Set a after render callback in the texture.
  18327. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18328. */
  18329. onAfterRender: (faceIndex: number) => void;
  18330. /**
  18331. * An event triggered after the texture clear
  18332. */
  18333. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18334. private _onClearObserver;
  18335. /**
  18336. * Set a clear callback in the texture.
  18337. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18338. */
  18339. onClear: (Engine: Engine) => void;
  18340. /**
  18341. * Define the clear color of the Render Target if it should be different from the scene.
  18342. */
  18343. clearColor: Color4;
  18344. protected _size: number | {
  18345. width: number;
  18346. height: number;
  18347. };
  18348. protected _initialSizeParameter: number | {
  18349. width: number;
  18350. height: number;
  18351. } | {
  18352. ratio: number;
  18353. };
  18354. protected _sizeRatio: Nullable<number>;
  18355. /** @hidden */
  18356. _generateMipMaps: boolean;
  18357. protected _renderingManager: RenderingManager;
  18358. /** @hidden */
  18359. _waitingRenderList: string[];
  18360. protected _doNotChangeAspectRatio: boolean;
  18361. protected _currentRefreshId: number;
  18362. protected _refreshRate: number;
  18363. protected _textureMatrix: Matrix;
  18364. protected _samples: number;
  18365. protected _renderTargetOptions: RenderTargetCreationOptions;
  18366. /**
  18367. * Gets render target creation options that were used.
  18368. */
  18369. readonly renderTargetOptions: RenderTargetCreationOptions;
  18370. protected _engine: Engine;
  18371. protected _onRatioRescale(): void;
  18372. /**
  18373. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18374. * It must define where the camera used to render the texture is set
  18375. */
  18376. boundingBoxPosition: Vector3;
  18377. private _boundingBoxSize;
  18378. /**
  18379. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18380. * When defined, the cubemap will switch to local mode
  18381. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18382. * @example https://www.babylonjs-playground.com/#RNASML
  18383. */
  18384. boundingBoxSize: Vector3;
  18385. /**
  18386. * In case the RTT has been created with a depth texture, get the associated
  18387. * depth texture.
  18388. * Otherwise, return null.
  18389. */
  18390. depthStencilTexture: Nullable<InternalTexture>;
  18391. /**
  18392. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18393. * or used a shadow, depth texture...
  18394. * @param name The friendly name of the texture
  18395. * @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)
  18396. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18397. * @param generateMipMaps True if mip maps need to be generated after render.
  18398. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18399. * @param type The type of the buffer in the RTT (int, half float, float...)
  18400. * @param isCube True if a cube texture needs to be created
  18401. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18402. * @param generateDepthBuffer True to generate a depth buffer
  18403. * @param generateStencilBuffer True to generate a stencil buffer
  18404. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18405. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18406. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18407. */
  18408. constructor(name: string, size: number | {
  18409. width: number;
  18410. height: number;
  18411. } | {
  18412. ratio: number;
  18413. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18414. /**
  18415. * Creates a depth stencil texture.
  18416. * This is only available in WebGL 2 or with the depth texture extension available.
  18417. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18418. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18419. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18420. */
  18421. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18422. private _processSizeParameter;
  18423. /**
  18424. * Define the number of samples to use in case of MSAA.
  18425. * It defaults to one meaning no MSAA has been enabled.
  18426. */
  18427. samples: number;
  18428. /**
  18429. * Resets the refresh counter of the texture and start bak from scratch.
  18430. * Could be useful to regenerate the texture if it is setup to render only once.
  18431. */
  18432. resetRefreshCounter(): void;
  18433. /**
  18434. * Define the refresh rate of the texture or the rendering frequency.
  18435. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18436. */
  18437. refreshRate: number;
  18438. /**
  18439. * Adds a post process to the render target rendering passes.
  18440. * @param postProcess define the post process to add
  18441. */
  18442. addPostProcess(postProcess: PostProcess): void;
  18443. /**
  18444. * Clear all the post processes attached to the render target
  18445. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18446. */
  18447. clearPostProcesses(dispose?: boolean): void;
  18448. /**
  18449. * Remove one of the post process from the list of attached post processes to the texture
  18450. * @param postProcess define the post process to remove from the list
  18451. */
  18452. removePostProcess(postProcess: PostProcess): void;
  18453. /** @hidden */
  18454. _shouldRender(): boolean;
  18455. /**
  18456. * Gets the actual render size of the texture.
  18457. * @returns the width of the render size
  18458. */
  18459. getRenderSize(): number;
  18460. /**
  18461. * Gets the actual render width of the texture.
  18462. * @returns the width of the render size
  18463. */
  18464. getRenderWidth(): number;
  18465. /**
  18466. * Gets the actual render height of the texture.
  18467. * @returns the height of the render size
  18468. */
  18469. getRenderHeight(): number;
  18470. /**
  18471. * Get if the texture can be rescaled or not.
  18472. */
  18473. readonly canRescale: boolean;
  18474. /**
  18475. * Resize the texture using a ratio.
  18476. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18477. */
  18478. scale(ratio: number): void;
  18479. /**
  18480. * Get the texture reflection matrix used to rotate/transform the reflection.
  18481. * @returns the reflection matrix
  18482. */
  18483. getReflectionTextureMatrix(): Matrix;
  18484. /**
  18485. * Resize the texture to a new desired size.
  18486. * Be carrefull as it will recreate all the data in the new texture.
  18487. * @param size Define the new size. It can be:
  18488. * - a number for squared texture,
  18489. * - an object containing { width: number, height: number }
  18490. * - or an object containing a ratio { ratio: number }
  18491. */
  18492. resize(size: number | {
  18493. width: number;
  18494. height: number;
  18495. } | {
  18496. ratio: number;
  18497. }): void;
  18498. /**
  18499. * Renders all the objects from the render list into the texture.
  18500. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18501. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18502. */
  18503. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18504. private _bestReflectionRenderTargetDimension;
  18505. /**
  18506. * @hidden
  18507. * @param faceIndex face index to bind to if this is a cubetexture
  18508. */
  18509. _bindFrameBuffer(faceIndex?: number): void;
  18510. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18511. private renderToTarget;
  18512. /**
  18513. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18514. * This allowed control for front to back rendering or reversly depending of the special needs.
  18515. *
  18516. * @param renderingGroupId The rendering group id corresponding to its index
  18517. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18518. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18519. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18520. */
  18521. 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;
  18522. /**
  18523. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18524. *
  18525. * @param renderingGroupId The rendering group id corresponding to its index
  18526. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18527. */
  18528. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18529. /**
  18530. * Clones the texture.
  18531. * @returns the cloned texture
  18532. */
  18533. clone(): RenderTargetTexture;
  18534. /**
  18535. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18536. * @returns The JSON representation of the texture
  18537. */
  18538. serialize(): any;
  18539. /**
  18540. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18541. */
  18542. disposeFramebufferObjects(): void;
  18543. /**
  18544. * Dispose the texture and release its associated resources.
  18545. */
  18546. dispose(): void;
  18547. /** @hidden */
  18548. _rebuild(): void;
  18549. /**
  18550. * Clear the info related to rendering groups preventing retention point in material dispose.
  18551. */
  18552. freeRenderingGroups(): void;
  18553. /**
  18554. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18555. * @returns the view count
  18556. */
  18557. getViewCount(): number;
  18558. }
  18559. }
  18560. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18561. import { Scene } from "babylonjs/scene";
  18562. import { Plane } from "babylonjs/Maths/math";
  18563. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18564. /**
  18565. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18566. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18567. * You can then easily use it as a reflectionTexture on a flat surface.
  18568. * In case the surface is not a plane, please consider relying on reflection probes.
  18569. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18570. */
  18571. export class MirrorTexture extends RenderTargetTexture {
  18572. private scene;
  18573. /**
  18574. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18575. * 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.
  18576. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18577. */
  18578. mirrorPlane: Plane;
  18579. /**
  18580. * Define the blur ratio used to blur the reflection if needed.
  18581. */
  18582. blurRatio: number;
  18583. /**
  18584. * Define the adaptive blur kernel used to blur the reflection if needed.
  18585. * This will autocompute the closest best match for the `blurKernel`
  18586. */
  18587. adaptiveBlurKernel: number;
  18588. /**
  18589. * Define the blur kernel used to blur the reflection if needed.
  18590. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18591. */
  18592. blurKernel: number;
  18593. /**
  18594. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18595. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18596. */
  18597. blurKernelX: number;
  18598. /**
  18599. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18600. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18601. */
  18602. blurKernelY: number;
  18603. private _autoComputeBlurKernel;
  18604. protected _onRatioRescale(): void;
  18605. private _updateGammaSpace;
  18606. private _imageProcessingConfigChangeObserver;
  18607. private _transformMatrix;
  18608. private _mirrorMatrix;
  18609. private _savedViewMatrix;
  18610. private _blurX;
  18611. private _blurY;
  18612. private _adaptiveBlurKernel;
  18613. private _blurKernelX;
  18614. private _blurKernelY;
  18615. private _blurRatio;
  18616. /**
  18617. * Instantiates a Mirror Texture.
  18618. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18619. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18620. * You can then easily use it as a reflectionTexture on a flat surface.
  18621. * In case the surface is not a plane, please consider relying on reflection probes.
  18622. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18623. * @param name
  18624. * @param size
  18625. * @param scene
  18626. * @param generateMipMaps
  18627. * @param type
  18628. * @param samplingMode
  18629. * @param generateDepthBuffer
  18630. */
  18631. constructor(name: string, size: number | {
  18632. width: number;
  18633. height: number;
  18634. } | {
  18635. ratio: number;
  18636. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18637. private _preparePostProcesses;
  18638. /**
  18639. * Clone the mirror texture.
  18640. * @returns the cloned texture
  18641. */
  18642. clone(): MirrorTexture;
  18643. /**
  18644. * Serialize the texture to a JSON representation you could use in Parse later on
  18645. * @returns the serialized JSON representation
  18646. */
  18647. serialize(): any;
  18648. /**
  18649. * Dispose the texture and release its associated resources.
  18650. */
  18651. dispose(): void;
  18652. }
  18653. }
  18654. declare module "babylonjs/Materials/Textures/texture" {
  18655. import { Observable } from "babylonjs/Misc/observable";
  18656. import { Nullable } from "babylonjs/types";
  18657. import { Scene } from "babylonjs/scene";
  18658. import { Matrix } from "babylonjs/Maths/math";
  18659. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18660. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18661. /**
  18662. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18663. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18664. */
  18665. export class Texture extends BaseTexture {
  18666. /** @hidden */
  18667. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18668. /** @hidden */
  18669. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18670. /** @hidden */
  18671. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18672. /** nearest is mag = nearest and min = nearest and mip = linear */
  18673. static readonly NEAREST_SAMPLINGMODE: number;
  18674. /** nearest is mag = nearest and min = nearest and mip = linear */
  18675. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18676. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18677. static readonly BILINEAR_SAMPLINGMODE: number;
  18678. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18679. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18680. /** Trilinear is mag = linear and min = linear and mip = linear */
  18681. static readonly TRILINEAR_SAMPLINGMODE: number;
  18682. /** Trilinear is mag = linear and min = linear and mip = linear */
  18683. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18684. /** mag = nearest and min = nearest and mip = nearest */
  18685. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18686. /** mag = nearest and min = linear and mip = nearest */
  18687. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18688. /** mag = nearest and min = linear and mip = linear */
  18689. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18690. /** mag = nearest and min = linear and mip = none */
  18691. static readonly NEAREST_LINEAR: number;
  18692. /** mag = nearest and min = nearest and mip = none */
  18693. static readonly NEAREST_NEAREST: number;
  18694. /** mag = linear and min = nearest and mip = nearest */
  18695. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18696. /** mag = linear and min = nearest and mip = linear */
  18697. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18698. /** mag = linear and min = linear and mip = none */
  18699. static readonly LINEAR_LINEAR: number;
  18700. /** mag = linear and min = nearest and mip = none */
  18701. static readonly LINEAR_NEAREST: number;
  18702. /** Explicit coordinates mode */
  18703. static readonly EXPLICIT_MODE: number;
  18704. /** Spherical coordinates mode */
  18705. static readonly SPHERICAL_MODE: number;
  18706. /** Planar coordinates mode */
  18707. static readonly PLANAR_MODE: number;
  18708. /** Cubic coordinates mode */
  18709. static readonly CUBIC_MODE: number;
  18710. /** Projection coordinates mode */
  18711. static readonly PROJECTION_MODE: number;
  18712. /** Inverse Cubic coordinates mode */
  18713. static readonly SKYBOX_MODE: number;
  18714. /** Inverse Cubic coordinates mode */
  18715. static readonly INVCUBIC_MODE: number;
  18716. /** Equirectangular coordinates mode */
  18717. static readonly EQUIRECTANGULAR_MODE: number;
  18718. /** Equirectangular Fixed coordinates mode */
  18719. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18720. /** Equirectangular Fixed Mirrored coordinates mode */
  18721. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18722. /** Texture is not repeating outside of 0..1 UVs */
  18723. static readonly CLAMP_ADDRESSMODE: number;
  18724. /** Texture is repeating outside of 0..1 UVs */
  18725. static readonly WRAP_ADDRESSMODE: number;
  18726. /** Texture is repeating and mirrored */
  18727. static readonly MIRROR_ADDRESSMODE: number;
  18728. /**
  18729. * 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
  18730. */
  18731. static UseSerializedUrlIfAny: boolean;
  18732. /**
  18733. * Define the url of the texture.
  18734. */
  18735. url: Nullable<string>;
  18736. /**
  18737. * Define an offset on the texture to offset the u coordinates of the UVs
  18738. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18739. */
  18740. uOffset: number;
  18741. /**
  18742. * Define an offset on the texture to offset the v coordinates of the UVs
  18743. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18744. */
  18745. vOffset: number;
  18746. /**
  18747. * Define an offset on the texture to scale the u coordinates of the UVs
  18748. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18749. */
  18750. uScale: number;
  18751. /**
  18752. * Define an offset on the texture to scale the v coordinates of the UVs
  18753. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18754. */
  18755. vScale: number;
  18756. /**
  18757. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18758. * @see http://doc.babylonjs.com/how_to/more_materials
  18759. */
  18760. uAng: number;
  18761. /**
  18762. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18763. * @see http://doc.babylonjs.com/how_to/more_materials
  18764. */
  18765. vAng: number;
  18766. /**
  18767. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18768. * @see http://doc.babylonjs.com/how_to/more_materials
  18769. */
  18770. wAng: number;
  18771. /**
  18772. * Defines the center of rotation (U)
  18773. */
  18774. uRotationCenter: number;
  18775. /**
  18776. * Defines the center of rotation (V)
  18777. */
  18778. vRotationCenter: number;
  18779. /**
  18780. * Defines the center of rotation (W)
  18781. */
  18782. wRotationCenter: number;
  18783. /**
  18784. * Are mip maps generated for this texture or not.
  18785. */
  18786. readonly noMipmap: boolean;
  18787. /**
  18788. * List of inspectable custom properties (used by the Inspector)
  18789. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18790. */
  18791. inspectableCustomProperties: Nullable<IInspectable[]>;
  18792. private _noMipmap;
  18793. /** @hidden */
  18794. _invertY: boolean;
  18795. private _rowGenerationMatrix;
  18796. private _cachedTextureMatrix;
  18797. private _projectionModeMatrix;
  18798. private _t0;
  18799. private _t1;
  18800. private _t2;
  18801. private _cachedUOffset;
  18802. private _cachedVOffset;
  18803. private _cachedUScale;
  18804. private _cachedVScale;
  18805. private _cachedUAng;
  18806. private _cachedVAng;
  18807. private _cachedWAng;
  18808. private _cachedProjectionMatrixId;
  18809. private _cachedCoordinatesMode;
  18810. /** @hidden */
  18811. protected _initialSamplingMode: number;
  18812. /** @hidden */
  18813. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18814. private _deleteBuffer;
  18815. protected _format: Nullable<number>;
  18816. private _delayedOnLoad;
  18817. private _delayedOnError;
  18818. /**
  18819. * Observable triggered once the texture has been loaded.
  18820. */
  18821. onLoadObservable: Observable<Texture>;
  18822. protected _isBlocking: boolean;
  18823. /**
  18824. * Is the texture preventing material to render while loading.
  18825. * If false, a default texture will be used instead of the loading one during the preparation step.
  18826. */
  18827. isBlocking: boolean;
  18828. /**
  18829. * Get the current sampling mode associated with the texture.
  18830. */
  18831. readonly samplingMode: number;
  18832. /**
  18833. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18834. */
  18835. readonly invertY: boolean;
  18836. /**
  18837. * Instantiates a new texture.
  18838. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18839. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18840. * @param url define the url of the picture to load as a texture
  18841. * @param scene define the scene the texture will belong to
  18842. * @param noMipmap define if the texture will require mip maps or not
  18843. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18844. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18845. * @param onLoad define a callback triggered when the texture has been loaded
  18846. * @param onError define a callback triggered when an error occurred during the loading session
  18847. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18848. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18849. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18850. */
  18851. 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);
  18852. /**
  18853. * Update the url (and optional buffer) of this texture if url was null during construction.
  18854. * @param url the url of the texture
  18855. * @param buffer the buffer of the texture (defaults to null)
  18856. * @param onLoad callback called when the texture is loaded (defaults to null)
  18857. */
  18858. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18859. /**
  18860. * Finish the loading sequence of a texture flagged as delayed load.
  18861. * @hidden
  18862. */
  18863. delayLoad(): void;
  18864. private _prepareRowForTextureGeneration;
  18865. /**
  18866. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18867. * @returns the transform matrix of the texture.
  18868. */
  18869. getTextureMatrix(): Matrix;
  18870. /**
  18871. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18872. * @returns The reflection texture transform
  18873. */
  18874. getReflectionTextureMatrix(): Matrix;
  18875. /**
  18876. * Clones the texture.
  18877. * @returns the cloned texture
  18878. */
  18879. clone(): Texture;
  18880. /**
  18881. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18882. * @returns The JSON representation of the texture
  18883. */
  18884. serialize(): any;
  18885. /**
  18886. * Get the current class name of the texture useful for serialization or dynamic coding.
  18887. * @returns "Texture"
  18888. */
  18889. getClassName(): string;
  18890. /**
  18891. * Dispose the texture and release its associated resources.
  18892. */
  18893. dispose(): void;
  18894. /**
  18895. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18896. * @param parsedTexture Define the JSON representation of the texture
  18897. * @param scene Define the scene the parsed texture should be instantiated in
  18898. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18899. * @returns The parsed texture if successful
  18900. */
  18901. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18902. /**
  18903. * Creates a texture from its base 64 representation.
  18904. * @param data Define the base64 payload without the data: prefix
  18905. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18906. * @param scene Define the scene the texture should belong to
  18907. * @param noMipmap Forces the texture to not create mip map information if true
  18908. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18909. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18910. * @param onLoad define a callback triggered when the texture has been loaded
  18911. * @param onError define a callback triggered when an error occurred during the loading session
  18912. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18913. * @returns the created texture
  18914. */
  18915. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18916. /**
  18917. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18918. * @param data Define the base64 payload without the data: prefix
  18919. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18920. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18921. * @param scene Define the scene the texture should belong to
  18922. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18923. * @param noMipmap Forces the texture to not create mip map information if true
  18924. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18925. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18926. * @param onLoad define a callback triggered when the texture has been loaded
  18927. * @param onError define a callback triggered when an error occurred during the loading session
  18928. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18929. * @returns the created texture
  18930. */
  18931. 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;
  18932. }
  18933. }
  18934. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18935. import { Nullable } from "babylonjs/types";
  18936. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18937. import { Scene } from "babylonjs/scene";
  18938. module "babylonjs/Engines/engine" {
  18939. interface Engine {
  18940. /**
  18941. * Creates a raw texture
  18942. * @param data defines the data to store in the texture
  18943. * @param width defines the width of the texture
  18944. * @param height defines the height of the texture
  18945. * @param format defines the format of the data
  18946. * @param generateMipMaps defines if the engine should generate the mip levels
  18947. * @param invertY defines if data must be stored with Y axis inverted
  18948. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18949. * @param compression defines the compression used (null by default)
  18950. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18951. * @returns the raw texture inside an InternalTexture
  18952. */
  18953. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18954. /**
  18955. * Update a raw texture
  18956. * @param texture defines the texture to update
  18957. * @param data defines the data to store in the texture
  18958. * @param format defines the format of the data
  18959. * @param invertY defines if data must be stored with Y axis inverted
  18960. */
  18961. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18962. /**
  18963. * Update a raw texture
  18964. * @param texture defines the texture to update
  18965. * @param data defines the data to store in the texture
  18966. * @param format defines the format of the data
  18967. * @param invertY defines if data must be stored with Y axis inverted
  18968. * @param compression defines the compression used (null by default)
  18969. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18970. */
  18971. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18972. /**
  18973. * Creates a new raw cube texture
  18974. * @param data defines the array of data to use to create each face
  18975. * @param size defines the size of the textures
  18976. * @param format defines the format of the data
  18977. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18978. * @param generateMipMaps defines if the engine should generate the mip levels
  18979. * @param invertY defines if data must be stored with Y axis inverted
  18980. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18981. * @param compression defines the compression used (null by default)
  18982. * @returns the cube texture as an InternalTexture
  18983. */
  18984. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18985. /**
  18986. * Update a raw cube texture
  18987. * @param texture defines the texture to udpdate
  18988. * @param data defines the data to store
  18989. * @param format defines the data format
  18990. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18991. * @param invertY defines if data must be stored with Y axis inverted
  18992. */
  18993. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18994. /**
  18995. * Update a raw cube texture
  18996. * @param texture defines the texture to udpdate
  18997. * @param data defines the data to store
  18998. * @param format defines the data format
  18999. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19000. * @param invertY defines if data must be stored with Y axis inverted
  19001. * @param compression defines the compression used (null by default)
  19002. */
  19003. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  19004. /**
  19005. * Update a raw cube texture
  19006. * @param texture defines the texture to udpdate
  19007. * @param data defines the data to store
  19008. * @param format defines the data format
  19009. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19010. * @param invertY defines if data must be stored with Y axis inverted
  19011. * @param compression defines the compression used (null by default)
  19012. * @param level defines which level of the texture to update
  19013. */
  19014. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  19015. /**
  19016. * Creates a new raw cube texture from a specified url
  19017. * @param url defines the url where the data is located
  19018. * @param scene defines the current scene
  19019. * @param size defines the size of the textures
  19020. * @param format defines the format of the data
  19021. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19022. * @param noMipmap defines if the engine should avoid generating the mip levels
  19023. * @param callback defines a callback used to extract texture data from loaded data
  19024. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19025. * @param onLoad defines a callback called when texture is loaded
  19026. * @param onError defines a callback called if there is an error
  19027. * @returns the cube texture as an InternalTexture
  19028. */
  19029. 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;
  19030. /**
  19031. * Creates a new raw cube texture from a specified url
  19032. * @param url defines the url where the data is located
  19033. * @param scene defines the current scene
  19034. * @param size defines the size of the textures
  19035. * @param format defines the format of the data
  19036. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19037. * @param noMipmap defines if the engine should avoid generating the mip levels
  19038. * @param callback defines a callback used to extract texture data from loaded data
  19039. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19040. * @param onLoad defines a callback called when texture is loaded
  19041. * @param onError defines a callback called if there is an error
  19042. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19043. * @param invertY defines if data must be stored with Y axis inverted
  19044. * @returns the cube texture as an InternalTexture
  19045. */
  19046. 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;
  19047. /**
  19048. * Creates a new raw 3D texture
  19049. * @param data defines the data used to create the texture
  19050. * @param width defines the width of the texture
  19051. * @param height defines the height of the texture
  19052. * @param depth defines the depth of the texture
  19053. * @param format defines the format of the texture
  19054. * @param generateMipMaps defines if the engine must generate mip levels
  19055. * @param invertY defines if data must be stored with Y axis inverted
  19056. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19057. * @param compression defines the compressed used (can be null)
  19058. * @param textureType defines the compressed used (can be null)
  19059. * @returns a new raw 3D texture (stored in an InternalTexture)
  19060. */
  19061. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19062. /**
  19063. * Update a raw 3D texture
  19064. * @param texture defines the texture to update
  19065. * @param data defines the data to store
  19066. * @param format defines the data format
  19067. * @param invertY defines if data must be stored with Y axis inverted
  19068. */
  19069. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19070. /**
  19071. * Update a raw 3D texture
  19072. * @param texture defines the texture to update
  19073. * @param data defines the data to store
  19074. * @param format defines the data format
  19075. * @param invertY defines if data must be stored with Y axis inverted
  19076. * @param compression defines the used compression (can be null)
  19077. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19078. */
  19079. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19080. }
  19081. }
  19082. }
  19083. declare module "babylonjs/Materials/Textures/rawTexture" {
  19084. import { Scene } from "babylonjs/scene";
  19085. import { Texture } from "babylonjs/Materials/Textures/texture";
  19086. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19087. /**
  19088. * Raw texture can help creating a texture directly from an array of data.
  19089. * This can be super useful if you either get the data from an uncompressed source or
  19090. * if you wish to create your texture pixel by pixel.
  19091. */
  19092. export class RawTexture extends Texture {
  19093. /**
  19094. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19095. */
  19096. format: number;
  19097. private _engine;
  19098. /**
  19099. * Instantiates a new RawTexture.
  19100. * Raw texture can help creating a texture directly from an array of data.
  19101. * This can be super useful if you either get the data from an uncompressed source or
  19102. * if you wish to create your texture pixel by pixel.
  19103. * @param data define the array of data to use to create the texture
  19104. * @param width define the width of the texture
  19105. * @param height define the height of the texture
  19106. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19107. * @param scene define the scene the texture belongs to
  19108. * @param generateMipMaps define whether mip maps should be generated or not
  19109. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19110. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19111. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19112. */
  19113. constructor(data: ArrayBufferView, width: number, height: number,
  19114. /**
  19115. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19116. */
  19117. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19118. /**
  19119. * Updates the texture underlying data.
  19120. * @param data Define the new data of the texture
  19121. */
  19122. update(data: ArrayBufferView): void;
  19123. /**
  19124. * Creates a luminance texture from some data.
  19125. * @param data Define the texture data
  19126. * @param width Define the width of the texture
  19127. * @param height Define the height of the texture
  19128. * @param scene Define the scene the texture belongs to
  19129. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19130. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19131. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19132. * @returns the luminance texture
  19133. */
  19134. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19135. /**
  19136. * Creates a luminance alpha texture from some data.
  19137. * @param data Define the texture data
  19138. * @param width Define the width of the texture
  19139. * @param height Define the height of the texture
  19140. * @param scene Define the scene the texture belongs to
  19141. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19142. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19143. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19144. * @returns the luminance alpha texture
  19145. */
  19146. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19147. /**
  19148. * Creates an alpha texture from some data.
  19149. * @param data Define the texture data
  19150. * @param width Define the width of the texture
  19151. * @param height Define the height of the texture
  19152. * @param scene Define the scene the texture belongs to
  19153. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19154. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19155. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19156. * @returns the alpha texture
  19157. */
  19158. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19159. /**
  19160. * Creates a RGB texture from some data.
  19161. * @param data Define the texture data
  19162. * @param width Define the width of the texture
  19163. * @param height Define the height of the texture
  19164. * @param scene Define the scene the texture belongs to
  19165. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19166. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19167. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19168. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19169. * @returns the RGB alpha texture
  19170. */
  19171. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19172. /**
  19173. * Creates a RGBA texture from some data.
  19174. * @param data Define the texture data
  19175. * @param width Define the width of the texture
  19176. * @param height Define the height of the texture
  19177. * @param scene Define the scene the texture belongs to
  19178. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19179. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19180. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19181. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19182. * @returns the RGBA texture
  19183. */
  19184. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19185. /**
  19186. * Creates a R texture from some data.
  19187. * @param data Define the texture data
  19188. * @param width Define the width of the texture
  19189. * @param height Define the height of the texture
  19190. * @param scene Define the scene the texture belongs to
  19191. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19192. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19193. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19194. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19195. * @returns the R texture
  19196. */
  19197. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19198. }
  19199. }
  19200. declare module "babylonjs/Animations/runtimeAnimation" {
  19201. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19202. import { Animatable } from "babylonjs/Animations/animatable";
  19203. import { Scene } from "babylonjs/scene";
  19204. /**
  19205. * Defines a runtime animation
  19206. */
  19207. export class RuntimeAnimation {
  19208. private _events;
  19209. /**
  19210. * The current frame of the runtime animation
  19211. */
  19212. private _currentFrame;
  19213. /**
  19214. * The animation used by the runtime animation
  19215. */
  19216. private _animation;
  19217. /**
  19218. * The target of the runtime animation
  19219. */
  19220. private _target;
  19221. /**
  19222. * The initiating animatable
  19223. */
  19224. private _host;
  19225. /**
  19226. * The original value of the runtime animation
  19227. */
  19228. private _originalValue;
  19229. /**
  19230. * The original blend value of the runtime animation
  19231. */
  19232. private _originalBlendValue;
  19233. /**
  19234. * The offsets cache of the runtime animation
  19235. */
  19236. private _offsetsCache;
  19237. /**
  19238. * The high limits cache of the runtime animation
  19239. */
  19240. private _highLimitsCache;
  19241. /**
  19242. * Specifies if the runtime animation has been stopped
  19243. */
  19244. private _stopped;
  19245. /**
  19246. * The blending factor of the runtime animation
  19247. */
  19248. private _blendingFactor;
  19249. /**
  19250. * The BabylonJS scene
  19251. */
  19252. private _scene;
  19253. /**
  19254. * The current value of the runtime animation
  19255. */
  19256. private _currentValue;
  19257. /** @hidden */
  19258. _animationState: _IAnimationState;
  19259. /**
  19260. * The active target of the runtime animation
  19261. */
  19262. private _activeTargets;
  19263. private _currentActiveTarget;
  19264. private _directTarget;
  19265. /**
  19266. * The target path of the runtime animation
  19267. */
  19268. private _targetPath;
  19269. /**
  19270. * The weight of the runtime animation
  19271. */
  19272. private _weight;
  19273. /**
  19274. * The ratio offset of the runtime animation
  19275. */
  19276. private _ratioOffset;
  19277. /**
  19278. * The previous delay of the runtime animation
  19279. */
  19280. private _previousDelay;
  19281. /**
  19282. * The previous ratio of the runtime animation
  19283. */
  19284. private _previousRatio;
  19285. private _enableBlending;
  19286. private _keys;
  19287. private _minFrame;
  19288. private _maxFrame;
  19289. private _minValue;
  19290. private _maxValue;
  19291. private _targetIsArray;
  19292. /**
  19293. * Gets the current frame of the runtime animation
  19294. */
  19295. readonly currentFrame: number;
  19296. /**
  19297. * Gets the weight of the runtime animation
  19298. */
  19299. readonly weight: number;
  19300. /**
  19301. * Gets the current value of the runtime animation
  19302. */
  19303. readonly currentValue: any;
  19304. /**
  19305. * Gets the target path of the runtime animation
  19306. */
  19307. readonly targetPath: string;
  19308. /**
  19309. * Gets the actual target of the runtime animation
  19310. */
  19311. readonly target: any;
  19312. /** @hidden */
  19313. _onLoop: () => void;
  19314. /**
  19315. * Create a new RuntimeAnimation object
  19316. * @param target defines the target of the animation
  19317. * @param animation defines the source animation object
  19318. * @param scene defines the hosting scene
  19319. * @param host defines the initiating Animatable
  19320. */
  19321. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19322. private _preparePath;
  19323. /**
  19324. * Gets the animation from the runtime animation
  19325. */
  19326. readonly animation: Animation;
  19327. /**
  19328. * Resets the runtime animation to the beginning
  19329. * @param restoreOriginal defines whether to restore the target property to the original value
  19330. */
  19331. reset(restoreOriginal?: boolean): void;
  19332. /**
  19333. * Specifies if the runtime animation is stopped
  19334. * @returns Boolean specifying if the runtime animation is stopped
  19335. */
  19336. isStopped(): boolean;
  19337. /**
  19338. * Disposes of the runtime animation
  19339. */
  19340. dispose(): void;
  19341. /**
  19342. * Apply the interpolated value to the target
  19343. * @param currentValue defines the value computed by the animation
  19344. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19345. */
  19346. setValue(currentValue: any, weight: number): void;
  19347. private _getOriginalValues;
  19348. private _setValue;
  19349. /**
  19350. * Gets the loop pmode of the runtime animation
  19351. * @returns Loop Mode
  19352. */
  19353. private _getCorrectLoopMode;
  19354. /**
  19355. * Move the current animation to a given frame
  19356. * @param frame defines the frame to move to
  19357. */
  19358. goToFrame(frame: number): void;
  19359. /**
  19360. * @hidden Internal use only
  19361. */
  19362. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19363. /**
  19364. * Execute the current animation
  19365. * @param delay defines the delay to add to the current frame
  19366. * @param from defines the lower bound of the animation range
  19367. * @param to defines the upper bound of the animation range
  19368. * @param loop defines if the current animation must loop
  19369. * @param speedRatio defines the current speed ratio
  19370. * @param weight defines the weight of the animation (default is -1 so no weight)
  19371. * @param onLoop optional callback called when animation loops
  19372. * @returns a boolean indicating if the animation is running
  19373. */
  19374. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19375. }
  19376. }
  19377. declare module "babylonjs/Animations/animatable" {
  19378. import { Animation } from "babylonjs/Animations/animation";
  19379. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19380. import { Nullable } from "babylonjs/types";
  19381. import { Observable } from "babylonjs/Misc/observable";
  19382. import { Scene } from "babylonjs/scene";
  19383. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19384. import { Node } from "babylonjs/node";
  19385. /**
  19386. * Class used to store an actual running animation
  19387. */
  19388. export class Animatable {
  19389. /** defines the target object */
  19390. target: any;
  19391. /** defines the starting frame number (default is 0) */
  19392. fromFrame: number;
  19393. /** defines the ending frame number (default is 100) */
  19394. toFrame: number;
  19395. /** defines if the animation must loop (default is false) */
  19396. loopAnimation: boolean;
  19397. /** defines a callback to call when animation ends if it is not looping */
  19398. onAnimationEnd?: (() => void) | null | undefined;
  19399. /** defines a callback to call when animation loops */
  19400. onAnimationLoop?: (() => void) | null | undefined;
  19401. private _localDelayOffset;
  19402. private _pausedDelay;
  19403. private _runtimeAnimations;
  19404. private _paused;
  19405. private _scene;
  19406. private _speedRatio;
  19407. private _weight;
  19408. private _syncRoot;
  19409. /**
  19410. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19411. * This will only apply for non looping animation (default is true)
  19412. */
  19413. disposeOnEnd: boolean;
  19414. /**
  19415. * Gets a boolean indicating if the animation has started
  19416. */
  19417. animationStarted: boolean;
  19418. /**
  19419. * Observer raised when the animation ends
  19420. */
  19421. onAnimationEndObservable: Observable<Animatable>;
  19422. /**
  19423. * Observer raised when the animation loops
  19424. */
  19425. onAnimationLoopObservable: Observable<Animatable>;
  19426. /**
  19427. * Gets the root Animatable used to synchronize and normalize animations
  19428. */
  19429. readonly syncRoot: Nullable<Animatable>;
  19430. /**
  19431. * Gets the current frame of the first RuntimeAnimation
  19432. * Used to synchronize Animatables
  19433. */
  19434. readonly masterFrame: number;
  19435. /**
  19436. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19437. */
  19438. weight: number;
  19439. /**
  19440. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19441. */
  19442. speedRatio: number;
  19443. /**
  19444. * Creates a new Animatable
  19445. * @param scene defines the hosting scene
  19446. * @param target defines the target object
  19447. * @param fromFrame defines the starting frame number (default is 0)
  19448. * @param toFrame defines the ending frame number (default is 100)
  19449. * @param loopAnimation defines if the animation must loop (default is false)
  19450. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19451. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19452. * @param animations defines a group of animation to add to the new Animatable
  19453. * @param onAnimationLoop defines a callback to call when animation loops
  19454. */
  19455. constructor(scene: Scene,
  19456. /** defines the target object */
  19457. target: any,
  19458. /** defines the starting frame number (default is 0) */
  19459. fromFrame?: number,
  19460. /** defines the ending frame number (default is 100) */
  19461. toFrame?: number,
  19462. /** defines if the animation must loop (default is false) */
  19463. loopAnimation?: boolean, speedRatio?: number,
  19464. /** defines a callback to call when animation ends if it is not looping */
  19465. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19466. /** defines a callback to call when animation loops */
  19467. onAnimationLoop?: (() => void) | null | undefined);
  19468. /**
  19469. * Synchronize and normalize current Animatable with a source Animatable
  19470. * This is useful when using animation weights and when animations are not of the same length
  19471. * @param root defines the root Animatable to synchronize with
  19472. * @returns the current Animatable
  19473. */
  19474. syncWith(root: Animatable): Animatable;
  19475. /**
  19476. * Gets the list of runtime animations
  19477. * @returns an array of RuntimeAnimation
  19478. */
  19479. getAnimations(): RuntimeAnimation[];
  19480. /**
  19481. * Adds more animations to the current animatable
  19482. * @param target defines the target of the animations
  19483. * @param animations defines the new animations to add
  19484. */
  19485. appendAnimations(target: any, animations: Animation[]): void;
  19486. /**
  19487. * Gets the source animation for a specific property
  19488. * @param property defines the propertyu to look for
  19489. * @returns null or the source animation for the given property
  19490. */
  19491. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19492. /**
  19493. * Gets the runtime animation for a specific property
  19494. * @param property defines the propertyu to look for
  19495. * @returns null or the runtime animation for the given property
  19496. */
  19497. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19498. /**
  19499. * Resets the animatable to its original state
  19500. */
  19501. reset(): void;
  19502. /**
  19503. * Allows the animatable to blend with current running animations
  19504. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19505. * @param blendingSpeed defines the blending speed to use
  19506. */
  19507. enableBlending(blendingSpeed: number): void;
  19508. /**
  19509. * Disable animation blending
  19510. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19511. */
  19512. disableBlending(): void;
  19513. /**
  19514. * Jump directly to a given frame
  19515. * @param frame defines the frame to jump to
  19516. */
  19517. goToFrame(frame: number): void;
  19518. /**
  19519. * Pause the animation
  19520. */
  19521. pause(): void;
  19522. /**
  19523. * Restart the animation
  19524. */
  19525. restart(): void;
  19526. private _raiseOnAnimationEnd;
  19527. /**
  19528. * Stop and delete the current animation
  19529. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19530. * @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)
  19531. */
  19532. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19533. /**
  19534. * Wait asynchronously for the animation to end
  19535. * @returns a promise which will be fullfilled when the animation ends
  19536. */
  19537. waitAsync(): Promise<Animatable>;
  19538. /** @hidden */
  19539. _animate(delay: number): boolean;
  19540. }
  19541. module "babylonjs/scene" {
  19542. interface Scene {
  19543. /** @hidden */
  19544. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19545. /** @hidden */
  19546. _processLateAnimationBindingsForMatrices(holder: {
  19547. totalWeight: number;
  19548. animations: RuntimeAnimation[];
  19549. originalValue: Matrix;
  19550. }): any;
  19551. /** @hidden */
  19552. _processLateAnimationBindingsForQuaternions(holder: {
  19553. totalWeight: number;
  19554. animations: RuntimeAnimation[];
  19555. originalValue: Quaternion;
  19556. }, refQuaternion: Quaternion): Quaternion;
  19557. /** @hidden */
  19558. _processLateAnimationBindings(): void;
  19559. /**
  19560. * Will start the animation sequence of a given target
  19561. * @param target defines the target
  19562. * @param from defines from which frame should animation start
  19563. * @param to defines until which frame should animation run.
  19564. * @param weight defines the weight to apply to the animation (1.0 by default)
  19565. * @param loop defines if the animation loops
  19566. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19567. * @param onAnimationEnd defines the function to be executed when the animation ends
  19568. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19569. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19570. * @param onAnimationLoop defines the callback to call when an animation loops
  19571. * @returns the animatable object created for this animation
  19572. */
  19573. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19574. /**
  19575. * Will start the animation sequence of a given target
  19576. * @param target defines the target
  19577. * @param from defines from which frame should animation start
  19578. * @param to defines until which frame should animation run.
  19579. * @param loop defines if the animation loops
  19580. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19581. * @param onAnimationEnd defines the function to be executed when the animation ends
  19582. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19583. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19584. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19585. * @param onAnimationLoop defines the callback to call when an animation loops
  19586. * @returns the animatable object created for this animation
  19587. */
  19588. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19589. /**
  19590. * Will start the animation sequence of a given target and its hierarchy
  19591. * @param target defines the target
  19592. * @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.
  19593. * @param from defines from which frame should animation start
  19594. * @param to defines until which frame should animation run.
  19595. * @param loop defines if the animation loops
  19596. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19597. * @param onAnimationEnd defines the function to be executed when the animation ends
  19598. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19599. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19600. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19601. * @param onAnimationLoop defines the callback to call when an animation loops
  19602. * @returns the list of created animatables
  19603. */
  19604. 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[];
  19605. /**
  19606. * Begin a new animation on a given node
  19607. * @param target defines the target where the animation will take place
  19608. * @param animations defines the list of animations to start
  19609. * @param from defines the initial value
  19610. * @param to defines the final value
  19611. * @param loop defines if you want animation to loop (off by default)
  19612. * @param speedRatio defines the speed ratio to apply to all animations
  19613. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19614. * @param onAnimationLoop defines the callback to call when an animation loops
  19615. * @returns the list of created animatables
  19616. */
  19617. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19618. /**
  19619. * Begin a new animation on a given node and its hierarchy
  19620. * @param target defines the root node where the animation will take place
  19621. * @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.
  19622. * @param animations defines the list of animations to start
  19623. * @param from defines the initial value
  19624. * @param to defines the final value
  19625. * @param loop defines if you want animation to loop (off by default)
  19626. * @param speedRatio defines the speed ratio to apply to all animations
  19627. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19628. * @param onAnimationLoop defines the callback to call when an animation loops
  19629. * @returns the list of animatables created for all nodes
  19630. */
  19631. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19632. /**
  19633. * Gets the animatable associated with a specific target
  19634. * @param target defines the target of the animatable
  19635. * @returns the required animatable if found
  19636. */
  19637. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19638. /**
  19639. * Gets all animatables associated with a given target
  19640. * @param target defines the target to look animatables for
  19641. * @returns an array of Animatables
  19642. */
  19643. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19644. /**
  19645. * Stops and removes all animations that have been applied to the scene
  19646. */
  19647. stopAllAnimations(): void;
  19648. }
  19649. }
  19650. module "babylonjs/Bones/bone" {
  19651. interface Bone {
  19652. /**
  19653. * Copy an animation range from another bone
  19654. * @param source defines the source bone
  19655. * @param rangeName defines the range name to copy
  19656. * @param frameOffset defines the frame offset
  19657. * @param rescaleAsRequired defines if rescaling must be applied if required
  19658. * @param skelDimensionsRatio defines the scaling ratio
  19659. * @returns true if operation was successful
  19660. */
  19661. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19662. }
  19663. }
  19664. }
  19665. declare module "babylonjs/Bones/skeleton" {
  19666. import { Bone } from "babylonjs/Bones/bone";
  19667. import { IAnimatable } from "babylonjs/Misc/tools";
  19668. import { Observable } from "babylonjs/Misc/observable";
  19669. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19670. import { Scene } from "babylonjs/scene";
  19671. import { Nullable } from "babylonjs/types";
  19672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19673. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19674. import { Animatable } from "babylonjs/Animations/animatable";
  19675. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19676. import { Animation } from "babylonjs/Animations/animation";
  19677. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19678. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19679. /**
  19680. * Class used to handle skinning animations
  19681. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19682. */
  19683. export class Skeleton implements IAnimatable {
  19684. /** defines the skeleton name */
  19685. name: string;
  19686. /** defines the skeleton Id */
  19687. id: string;
  19688. /**
  19689. * Defines the list of child bones
  19690. */
  19691. bones: Bone[];
  19692. /**
  19693. * Defines an estimate of the dimension of the skeleton at rest
  19694. */
  19695. dimensionsAtRest: Vector3;
  19696. /**
  19697. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19698. */
  19699. needInitialSkinMatrix: boolean;
  19700. /**
  19701. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19702. */
  19703. overrideMesh: Nullable<AbstractMesh>;
  19704. /**
  19705. * Gets the list of animations attached to this skeleton
  19706. */
  19707. animations: Array<Animation>;
  19708. private _scene;
  19709. private _isDirty;
  19710. private _transformMatrices;
  19711. private _transformMatrixTexture;
  19712. private _meshesWithPoseMatrix;
  19713. private _animatables;
  19714. private _identity;
  19715. private _synchronizedWithMesh;
  19716. private _ranges;
  19717. private _lastAbsoluteTransformsUpdateId;
  19718. private _canUseTextureForBones;
  19719. private _uniqueId;
  19720. /** @hidden */
  19721. _numBonesWithLinkedTransformNode: number;
  19722. /** @hidden */
  19723. _hasWaitingData: Nullable<boolean>;
  19724. /**
  19725. * Specifies if the skeleton should be serialized
  19726. */
  19727. doNotSerialize: boolean;
  19728. private _useTextureToStoreBoneMatrices;
  19729. /**
  19730. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19731. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19732. */
  19733. useTextureToStoreBoneMatrices: boolean;
  19734. private _animationPropertiesOverride;
  19735. /**
  19736. * Gets or sets the animation properties override
  19737. */
  19738. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19739. /**
  19740. * List of inspectable custom properties (used by the Inspector)
  19741. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19742. */
  19743. inspectableCustomProperties: IInspectable[];
  19744. /**
  19745. * An observable triggered before computing the skeleton's matrices
  19746. */
  19747. onBeforeComputeObservable: Observable<Skeleton>;
  19748. /**
  19749. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19750. */
  19751. readonly isUsingTextureForMatrices: boolean;
  19752. /**
  19753. * Gets the unique ID of this skeleton
  19754. */
  19755. readonly uniqueId: number;
  19756. /**
  19757. * Creates a new skeleton
  19758. * @param name defines the skeleton name
  19759. * @param id defines the skeleton Id
  19760. * @param scene defines the hosting scene
  19761. */
  19762. constructor(
  19763. /** defines the skeleton name */
  19764. name: string,
  19765. /** defines the skeleton Id */
  19766. id: string, scene: Scene);
  19767. /**
  19768. * Gets the current object class name.
  19769. * @return the class name
  19770. */
  19771. getClassName(): string;
  19772. /**
  19773. * Returns an array containing the root bones
  19774. * @returns an array containing the root bones
  19775. */
  19776. getChildren(): Array<Bone>;
  19777. /**
  19778. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19779. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19780. * @returns a Float32Array containing matrices data
  19781. */
  19782. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19783. /**
  19784. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19785. * @returns a raw texture containing the data
  19786. */
  19787. getTransformMatrixTexture(): Nullable<RawTexture>;
  19788. /**
  19789. * Gets the current hosting scene
  19790. * @returns a scene object
  19791. */
  19792. getScene(): Scene;
  19793. /**
  19794. * Gets a string representing the current skeleton data
  19795. * @param fullDetails defines a boolean indicating if we want a verbose version
  19796. * @returns a string representing the current skeleton data
  19797. */
  19798. toString(fullDetails?: boolean): string;
  19799. /**
  19800. * Get bone's index searching by name
  19801. * @param name defines bone's name to search for
  19802. * @return the indice of the bone. Returns -1 if not found
  19803. */
  19804. getBoneIndexByName(name: string): number;
  19805. /**
  19806. * Creater a new animation range
  19807. * @param name defines the name of the range
  19808. * @param from defines the start key
  19809. * @param to defines the end key
  19810. */
  19811. createAnimationRange(name: string, from: number, to: number): void;
  19812. /**
  19813. * Delete a specific animation range
  19814. * @param name defines the name of the range
  19815. * @param deleteFrames defines if frames must be removed as well
  19816. */
  19817. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19818. /**
  19819. * Gets a specific animation range
  19820. * @param name defines the name of the range to look for
  19821. * @returns the requested animation range or null if not found
  19822. */
  19823. getAnimationRange(name: string): Nullable<AnimationRange>;
  19824. /**
  19825. * Gets the list of all animation ranges defined on this skeleton
  19826. * @returns an array
  19827. */
  19828. getAnimationRanges(): Nullable<AnimationRange>[];
  19829. /**
  19830. * Copy animation range from a source skeleton.
  19831. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19832. * @param source defines the source skeleton
  19833. * @param name defines the name of the range to copy
  19834. * @param rescaleAsRequired defines if rescaling must be applied if required
  19835. * @returns true if operation was successful
  19836. */
  19837. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19838. /**
  19839. * Forces the skeleton to go to rest pose
  19840. */
  19841. returnToRest(): void;
  19842. private _getHighestAnimationFrame;
  19843. /**
  19844. * Begin a specific animation range
  19845. * @param name defines the name of the range to start
  19846. * @param loop defines if looping must be turned on (false by default)
  19847. * @param speedRatio defines the speed ratio to apply (1 by default)
  19848. * @param onAnimationEnd defines a callback which will be called when animation will end
  19849. * @returns a new animatable
  19850. */
  19851. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19852. /** @hidden */
  19853. _markAsDirty(): void;
  19854. /** @hidden */
  19855. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19856. /** @hidden */
  19857. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19858. private _computeTransformMatrices;
  19859. /**
  19860. * Build all resources required to render a skeleton
  19861. */
  19862. prepare(): void;
  19863. /**
  19864. * Gets the list of animatables currently running for this skeleton
  19865. * @returns an array of animatables
  19866. */
  19867. getAnimatables(): IAnimatable[];
  19868. /**
  19869. * Clone the current skeleton
  19870. * @param name defines the name of the new skeleton
  19871. * @param id defines the id of the new skeleton
  19872. * @returns the new skeleton
  19873. */
  19874. clone(name: string, id: string): Skeleton;
  19875. /**
  19876. * Enable animation blending for this skeleton
  19877. * @param blendingSpeed defines the blending speed to apply
  19878. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19879. */
  19880. enableBlending(blendingSpeed?: number): void;
  19881. /**
  19882. * Releases all resources associated with the current skeleton
  19883. */
  19884. dispose(): void;
  19885. /**
  19886. * Serialize the skeleton in a JSON object
  19887. * @returns a JSON object
  19888. */
  19889. serialize(): any;
  19890. /**
  19891. * Creates a new skeleton from serialized data
  19892. * @param parsedSkeleton defines the serialized data
  19893. * @param scene defines the hosting scene
  19894. * @returns a new skeleton
  19895. */
  19896. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19897. /**
  19898. * Compute all node absolute transforms
  19899. * @param forceUpdate defines if computation must be done even if cache is up to date
  19900. */
  19901. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19902. /**
  19903. * Gets the root pose matrix
  19904. * @returns a matrix
  19905. */
  19906. getPoseMatrix(): Nullable<Matrix>;
  19907. /**
  19908. * Sorts bones per internal index
  19909. */
  19910. sortBones(): void;
  19911. private _sortBones;
  19912. }
  19913. }
  19914. declare module "babylonjs/Morph/morphTarget" {
  19915. import { IAnimatable } from "babylonjs/Misc/tools";
  19916. import { Observable } from "babylonjs/Misc/observable";
  19917. import { Nullable, FloatArray } from "babylonjs/types";
  19918. import { Scene } from "babylonjs/scene";
  19919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19920. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19921. /**
  19922. * Defines a target to use with MorphTargetManager
  19923. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19924. */
  19925. export class MorphTarget implements IAnimatable {
  19926. /** defines the name of the target */
  19927. name: string;
  19928. /**
  19929. * Gets or sets the list of animations
  19930. */
  19931. animations: import("babylonjs/Animations/animation").Animation[];
  19932. private _scene;
  19933. private _positions;
  19934. private _normals;
  19935. private _tangents;
  19936. private _influence;
  19937. /**
  19938. * Observable raised when the influence changes
  19939. */
  19940. onInfluenceChanged: Observable<boolean>;
  19941. /** @hidden */
  19942. _onDataLayoutChanged: Observable<void>;
  19943. /**
  19944. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19945. */
  19946. influence: number;
  19947. /**
  19948. * Gets or sets the id of the morph Target
  19949. */
  19950. id: string;
  19951. private _animationPropertiesOverride;
  19952. /**
  19953. * Gets or sets the animation properties override
  19954. */
  19955. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19956. /**
  19957. * Creates a new MorphTarget
  19958. * @param name defines the name of the target
  19959. * @param influence defines the influence to use
  19960. * @param scene defines the scene the morphtarget belongs to
  19961. */
  19962. constructor(
  19963. /** defines the name of the target */
  19964. name: string, influence?: number, scene?: Nullable<Scene>);
  19965. /**
  19966. * Gets a boolean defining if the target contains position data
  19967. */
  19968. readonly hasPositions: boolean;
  19969. /**
  19970. * Gets a boolean defining if the target contains normal data
  19971. */
  19972. readonly hasNormals: boolean;
  19973. /**
  19974. * Gets a boolean defining if the target contains tangent data
  19975. */
  19976. readonly hasTangents: boolean;
  19977. /**
  19978. * Affects position data to this target
  19979. * @param data defines the position data to use
  19980. */
  19981. setPositions(data: Nullable<FloatArray>): void;
  19982. /**
  19983. * Gets the position data stored in this target
  19984. * @returns a FloatArray containing the position data (or null if not present)
  19985. */
  19986. getPositions(): Nullable<FloatArray>;
  19987. /**
  19988. * Affects normal data to this target
  19989. * @param data defines the normal data to use
  19990. */
  19991. setNormals(data: Nullable<FloatArray>): void;
  19992. /**
  19993. * Gets the normal data stored in this target
  19994. * @returns a FloatArray containing the normal data (or null if not present)
  19995. */
  19996. getNormals(): Nullable<FloatArray>;
  19997. /**
  19998. * Affects tangent data to this target
  19999. * @param data defines the tangent data to use
  20000. */
  20001. setTangents(data: Nullable<FloatArray>): void;
  20002. /**
  20003. * Gets the tangent data stored in this target
  20004. * @returns a FloatArray containing the tangent data (or null if not present)
  20005. */
  20006. getTangents(): Nullable<FloatArray>;
  20007. /**
  20008. * Serializes the current target into a Serialization object
  20009. * @returns the serialized object
  20010. */
  20011. serialize(): any;
  20012. /**
  20013. * Returns the string "MorphTarget"
  20014. * @returns "MorphTarget"
  20015. */
  20016. getClassName(): string;
  20017. /**
  20018. * Creates a new target from serialized data
  20019. * @param serializationObject defines the serialized data to use
  20020. * @returns a new MorphTarget
  20021. */
  20022. static Parse(serializationObject: any): MorphTarget;
  20023. /**
  20024. * Creates a MorphTarget from mesh data
  20025. * @param mesh defines the source mesh
  20026. * @param name defines the name to use for the new target
  20027. * @param influence defines the influence to attach to the target
  20028. * @returns a new MorphTarget
  20029. */
  20030. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20031. }
  20032. }
  20033. declare module "babylonjs/Morph/morphTargetManager" {
  20034. import { Nullable } from "babylonjs/types";
  20035. import { Scene } from "babylonjs/scene";
  20036. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20037. /**
  20038. * This class is used to deform meshes using morphing between different targets
  20039. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20040. */
  20041. export class MorphTargetManager {
  20042. private _targets;
  20043. private _targetInfluenceChangedObservers;
  20044. private _targetDataLayoutChangedObservers;
  20045. private _activeTargets;
  20046. private _scene;
  20047. private _influences;
  20048. private _supportsNormals;
  20049. private _supportsTangents;
  20050. private _vertexCount;
  20051. private _uniqueId;
  20052. private _tempInfluences;
  20053. /**
  20054. * Creates a new MorphTargetManager
  20055. * @param scene defines the current scene
  20056. */
  20057. constructor(scene?: Nullable<Scene>);
  20058. /**
  20059. * Gets the unique ID of this manager
  20060. */
  20061. readonly uniqueId: number;
  20062. /**
  20063. * Gets the number of vertices handled by this manager
  20064. */
  20065. readonly vertexCount: number;
  20066. /**
  20067. * Gets a boolean indicating if this manager supports morphing of normals
  20068. */
  20069. readonly supportsNormals: boolean;
  20070. /**
  20071. * Gets a boolean indicating if this manager supports morphing of tangents
  20072. */
  20073. readonly supportsTangents: boolean;
  20074. /**
  20075. * Gets the number of targets stored in this manager
  20076. */
  20077. readonly numTargets: number;
  20078. /**
  20079. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20080. */
  20081. readonly numInfluencers: number;
  20082. /**
  20083. * Gets the list of influences (one per target)
  20084. */
  20085. readonly influences: Float32Array;
  20086. /**
  20087. * Gets the active target at specified index. An active target is a target with an influence > 0
  20088. * @param index defines the index to check
  20089. * @returns the requested target
  20090. */
  20091. getActiveTarget(index: number): MorphTarget;
  20092. /**
  20093. * Gets the target at specified index
  20094. * @param index defines the index to check
  20095. * @returns the requested target
  20096. */
  20097. getTarget(index: number): MorphTarget;
  20098. /**
  20099. * Add a new target to this manager
  20100. * @param target defines the target to add
  20101. */
  20102. addTarget(target: MorphTarget): void;
  20103. /**
  20104. * Removes a target from the manager
  20105. * @param target defines the target to remove
  20106. */
  20107. removeTarget(target: MorphTarget): void;
  20108. /**
  20109. * Serializes the current manager into a Serialization object
  20110. * @returns the serialized object
  20111. */
  20112. serialize(): any;
  20113. private _syncActiveTargets;
  20114. /**
  20115. * Syncrhonize the targets with all the meshes using this morph target manager
  20116. */
  20117. synchronize(): void;
  20118. /**
  20119. * Creates a new MorphTargetManager from serialized data
  20120. * @param serializationObject defines the serialized data
  20121. * @param scene defines the hosting scene
  20122. * @returns the new MorphTargetManager
  20123. */
  20124. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20125. }
  20126. }
  20127. declare module "babylonjs/Meshes/meshLODLevel" {
  20128. import { Mesh } from "babylonjs/Meshes/mesh";
  20129. import { Nullable } from "babylonjs/types";
  20130. /**
  20131. * Class used to represent a specific level of detail of a mesh
  20132. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20133. */
  20134. export class MeshLODLevel {
  20135. /** Defines the distance where this level should star being displayed */
  20136. distance: number;
  20137. /** Defines the mesh to use to render this level */
  20138. mesh: Nullable<Mesh>;
  20139. /**
  20140. * Creates a new LOD level
  20141. * @param distance defines the distance where this level should star being displayed
  20142. * @param mesh defines the mesh to use to render this level
  20143. */
  20144. constructor(
  20145. /** Defines the distance where this level should star being displayed */
  20146. distance: number,
  20147. /** Defines the mesh to use to render this level */
  20148. mesh: Nullable<Mesh>);
  20149. }
  20150. }
  20151. declare module "babylonjs/Meshes/groundMesh" {
  20152. import { Scene } from "babylonjs/scene";
  20153. import { Vector3 } from "babylonjs/Maths/math";
  20154. import { Mesh } from "babylonjs/Meshes/mesh";
  20155. /**
  20156. * Mesh representing the gorund
  20157. */
  20158. export class GroundMesh extends Mesh {
  20159. /** If octree should be generated */
  20160. generateOctree: boolean;
  20161. private _heightQuads;
  20162. /** @hidden */
  20163. _subdivisionsX: number;
  20164. /** @hidden */
  20165. _subdivisionsY: number;
  20166. /** @hidden */
  20167. _width: number;
  20168. /** @hidden */
  20169. _height: number;
  20170. /** @hidden */
  20171. _minX: number;
  20172. /** @hidden */
  20173. _maxX: number;
  20174. /** @hidden */
  20175. _minZ: number;
  20176. /** @hidden */
  20177. _maxZ: number;
  20178. constructor(name: string, scene: Scene);
  20179. /**
  20180. * "GroundMesh"
  20181. * @returns "GroundMesh"
  20182. */
  20183. getClassName(): string;
  20184. /**
  20185. * The minimum of x and y subdivisions
  20186. */
  20187. readonly subdivisions: number;
  20188. /**
  20189. * X subdivisions
  20190. */
  20191. readonly subdivisionsX: number;
  20192. /**
  20193. * Y subdivisions
  20194. */
  20195. readonly subdivisionsY: number;
  20196. /**
  20197. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20198. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20199. * @param chunksCount the number of subdivisions for x and y
  20200. * @param octreeBlocksSize (Default: 32)
  20201. */
  20202. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20203. /**
  20204. * Returns a height (y) value in the Worl system :
  20205. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20206. * @param x x coordinate
  20207. * @param z z coordinate
  20208. * @returns the ground y position if (x, z) are outside the ground surface.
  20209. */
  20210. getHeightAtCoordinates(x: number, z: number): number;
  20211. /**
  20212. * Returns a normalized vector (Vector3) orthogonal to the ground
  20213. * at the ground coordinates (x, z) expressed in the World system.
  20214. * @param x x coordinate
  20215. * @param z z coordinate
  20216. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20217. */
  20218. getNormalAtCoordinates(x: number, z: number): Vector3;
  20219. /**
  20220. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20221. * at the ground coordinates (x, z) expressed in the World system.
  20222. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20223. * @param x x coordinate
  20224. * @param z z coordinate
  20225. * @param ref vector to store the result
  20226. * @returns the GroundMesh.
  20227. */
  20228. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20229. /**
  20230. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20231. * if the ground has been updated.
  20232. * This can be used in the render loop.
  20233. * @returns the GroundMesh.
  20234. */
  20235. updateCoordinateHeights(): GroundMesh;
  20236. private _getFacetAt;
  20237. private _initHeightQuads;
  20238. private _computeHeightQuads;
  20239. /**
  20240. * Serializes this ground mesh
  20241. * @param serializationObject object to write serialization to
  20242. */
  20243. serialize(serializationObject: any): void;
  20244. /**
  20245. * Parses a serialized ground mesh
  20246. * @param parsedMesh the serialized mesh
  20247. * @param scene the scene to create the ground mesh in
  20248. * @returns the created ground mesh
  20249. */
  20250. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20251. }
  20252. }
  20253. declare module "babylonjs/Physics/physicsJoint" {
  20254. import { Vector3 } from "babylonjs/Maths/math";
  20255. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20256. /**
  20257. * Interface for Physics-Joint data
  20258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20259. */
  20260. export interface PhysicsJointData {
  20261. /**
  20262. * The main pivot of the joint
  20263. */
  20264. mainPivot?: Vector3;
  20265. /**
  20266. * The connected pivot of the joint
  20267. */
  20268. connectedPivot?: Vector3;
  20269. /**
  20270. * The main axis of the joint
  20271. */
  20272. mainAxis?: Vector3;
  20273. /**
  20274. * The connected axis of the joint
  20275. */
  20276. connectedAxis?: Vector3;
  20277. /**
  20278. * The collision of the joint
  20279. */
  20280. collision?: boolean;
  20281. /**
  20282. * Native Oimo/Cannon/Energy data
  20283. */
  20284. nativeParams?: any;
  20285. }
  20286. /**
  20287. * This is a holder class for the physics joint created by the physics plugin
  20288. * It holds a set of functions to control the underlying joint
  20289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20290. */
  20291. export class PhysicsJoint {
  20292. /**
  20293. * The type of the physics joint
  20294. */
  20295. type: number;
  20296. /**
  20297. * The data for the physics joint
  20298. */
  20299. jointData: PhysicsJointData;
  20300. private _physicsJoint;
  20301. protected _physicsPlugin: IPhysicsEnginePlugin;
  20302. /**
  20303. * Initializes the physics joint
  20304. * @param type The type of the physics joint
  20305. * @param jointData The data for the physics joint
  20306. */
  20307. constructor(
  20308. /**
  20309. * The type of the physics joint
  20310. */
  20311. type: number,
  20312. /**
  20313. * The data for the physics joint
  20314. */
  20315. jointData: PhysicsJointData);
  20316. /**
  20317. * Gets the physics joint
  20318. */
  20319. /**
  20320. * Sets the physics joint
  20321. */
  20322. physicsJoint: any;
  20323. /**
  20324. * Sets the physics plugin
  20325. */
  20326. physicsPlugin: IPhysicsEnginePlugin;
  20327. /**
  20328. * Execute a function that is physics-plugin specific.
  20329. * @param {Function} func the function that will be executed.
  20330. * It accepts two parameters: the physics world and the physics joint
  20331. */
  20332. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20333. /**
  20334. * Distance-Joint type
  20335. */
  20336. static DistanceJoint: number;
  20337. /**
  20338. * Hinge-Joint type
  20339. */
  20340. static HingeJoint: number;
  20341. /**
  20342. * Ball-and-Socket joint type
  20343. */
  20344. static BallAndSocketJoint: number;
  20345. /**
  20346. * Wheel-Joint type
  20347. */
  20348. static WheelJoint: number;
  20349. /**
  20350. * Slider-Joint type
  20351. */
  20352. static SliderJoint: number;
  20353. /**
  20354. * Prismatic-Joint type
  20355. */
  20356. static PrismaticJoint: number;
  20357. /**
  20358. * Universal-Joint type
  20359. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20360. */
  20361. static UniversalJoint: number;
  20362. /**
  20363. * Hinge-Joint 2 type
  20364. */
  20365. static Hinge2Joint: number;
  20366. /**
  20367. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20368. */
  20369. static PointToPointJoint: number;
  20370. /**
  20371. * Spring-Joint type
  20372. */
  20373. static SpringJoint: number;
  20374. /**
  20375. * Lock-Joint type
  20376. */
  20377. static LockJoint: number;
  20378. }
  20379. /**
  20380. * A class representing a physics distance joint
  20381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20382. */
  20383. export class DistanceJoint extends PhysicsJoint {
  20384. /**
  20385. *
  20386. * @param jointData The data for the Distance-Joint
  20387. */
  20388. constructor(jointData: DistanceJointData);
  20389. /**
  20390. * Update the predefined distance.
  20391. * @param maxDistance The maximum preferred distance
  20392. * @param minDistance The minimum preferred distance
  20393. */
  20394. updateDistance(maxDistance: number, minDistance?: number): void;
  20395. }
  20396. /**
  20397. * Represents a Motor-Enabled Joint
  20398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20399. */
  20400. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20401. /**
  20402. * Initializes the Motor-Enabled Joint
  20403. * @param type The type of the joint
  20404. * @param jointData The physica joint data for the joint
  20405. */
  20406. constructor(type: number, jointData: PhysicsJointData);
  20407. /**
  20408. * Set the motor values.
  20409. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20410. * @param force the force to apply
  20411. * @param maxForce max force for this motor.
  20412. */
  20413. setMotor(force?: number, maxForce?: number): void;
  20414. /**
  20415. * Set the motor's limits.
  20416. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20417. * @param upperLimit The upper limit of the motor
  20418. * @param lowerLimit The lower limit of the motor
  20419. */
  20420. setLimit(upperLimit: number, lowerLimit?: number): void;
  20421. }
  20422. /**
  20423. * This class represents a single physics Hinge-Joint
  20424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20425. */
  20426. export class HingeJoint extends MotorEnabledJoint {
  20427. /**
  20428. * Initializes the Hinge-Joint
  20429. * @param jointData The joint data for the Hinge-Joint
  20430. */
  20431. constructor(jointData: PhysicsJointData);
  20432. /**
  20433. * Set the motor values.
  20434. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20435. * @param {number} force the force to apply
  20436. * @param {number} maxForce max force for this motor.
  20437. */
  20438. setMotor(force?: number, maxForce?: number): void;
  20439. /**
  20440. * Set the motor's limits.
  20441. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20442. * @param upperLimit The upper limit of the motor
  20443. * @param lowerLimit The lower limit of the motor
  20444. */
  20445. setLimit(upperLimit: number, lowerLimit?: number): void;
  20446. }
  20447. /**
  20448. * This class represents a dual hinge physics joint (same as wheel joint)
  20449. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20450. */
  20451. export class Hinge2Joint extends MotorEnabledJoint {
  20452. /**
  20453. * Initializes the Hinge2-Joint
  20454. * @param jointData The joint data for the Hinge2-Joint
  20455. */
  20456. constructor(jointData: PhysicsJointData);
  20457. /**
  20458. * Set the motor values.
  20459. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20460. * @param {number} targetSpeed the speed the motor is to reach
  20461. * @param {number} maxForce max force for this motor.
  20462. * @param {motorIndex} the motor's index, 0 or 1.
  20463. */
  20464. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20465. /**
  20466. * Set the motor limits.
  20467. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20468. * @param {number} upperLimit the upper limit
  20469. * @param {number} lowerLimit lower limit
  20470. * @param {motorIndex} the motor's index, 0 or 1.
  20471. */
  20472. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20473. }
  20474. /**
  20475. * Interface for a motor enabled joint
  20476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20477. */
  20478. export interface IMotorEnabledJoint {
  20479. /**
  20480. * Physics joint
  20481. */
  20482. physicsJoint: any;
  20483. /**
  20484. * Sets the motor of the motor-enabled joint
  20485. * @param force The force of the motor
  20486. * @param maxForce The maximum force of the motor
  20487. * @param motorIndex The index of the motor
  20488. */
  20489. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20490. /**
  20491. * Sets the limit of the motor
  20492. * @param upperLimit The upper limit of the motor
  20493. * @param lowerLimit The lower limit of the motor
  20494. * @param motorIndex The index of the motor
  20495. */
  20496. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20497. }
  20498. /**
  20499. * Joint data for a Distance-Joint
  20500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20501. */
  20502. export interface DistanceJointData extends PhysicsJointData {
  20503. /**
  20504. * Max distance the 2 joint objects can be apart
  20505. */
  20506. maxDistance: number;
  20507. }
  20508. /**
  20509. * Joint data from a spring joint
  20510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20511. */
  20512. export interface SpringJointData extends PhysicsJointData {
  20513. /**
  20514. * Length of the spring
  20515. */
  20516. length: number;
  20517. /**
  20518. * Stiffness of the spring
  20519. */
  20520. stiffness: number;
  20521. /**
  20522. * Damping of the spring
  20523. */
  20524. damping: number;
  20525. /** this callback will be called when applying the force to the impostors. */
  20526. forceApplicationCallback: () => void;
  20527. }
  20528. }
  20529. declare module "babylonjs/Physics/physicsRaycastResult" {
  20530. import { Vector3 } from "babylonjs/Maths/math";
  20531. /**
  20532. * Holds the data for the raycast result
  20533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20534. */
  20535. export class PhysicsRaycastResult {
  20536. private _hasHit;
  20537. private _hitDistance;
  20538. private _hitNormalWorld;
  20539. private _hitPointWorld;
  20540. private _rayFromWorld;
  20541. private _rayToWorld;
  20542. /**
  20543. * Gets if there was a hit
  20544. */
  20545. readonly hasHit: boolean;
  20546. /**
  20547. * Gets the distance from the hit
  20548. */
  20549. readonly hitDistance: number;
  20550. /**
  20551. * Gets the hit normal/direction in the world
  20552. */
  20553. readonly hitNormalWorld: Vector3;
  20554. /**
  20555. * Gets the hit point in the world
  20556. */
  20557. readonly hitPointWorld: Vector3;
  20558. /**
  20559. * Gets the ray "start point" of the ray in the world
  20560. */
  20561. readonly rayFromWorld: Vector3;
  20562. /**
  20563. * Gets the ray "end point" of the ray in the world
  20564. */
  20565. readonly rayToWorld: Vector3;
  20566. /**
  20567. * Sets the hit data (normal & point in world space)
  20568. * @param hitNormalWorld defines the normal in world space
  20569. * @param hitPointWorld defines the point in world space
  20570. */
  20571. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20572. /**
  20573. * Sets the distance from the start point to the hit point
  20574. * @param distance
  20575. */
  20576. setHitDistance(distance: number): void;
  20577. /**
  20578. * Calculates the distance manually
  20579. */
  20580. calculateHitDistance(): void;
  20581. /**
  20582. * Resets all the values to default
  20583. * @param from The from point on world space
  20584. * @param to The to point on world space
  20585. */
  20586. reset(from?: Vector3, to?: Vector3): void;
  20587. }
  20588. /**
  20589. * Interface for the size containing width and height
  20590. */
  20591. interface IXYZ {
  20592. /**
  20593. * X
  20594. */
  20595. x: number;
  20596. /**
  20597. * Y
  20598. */
  20599. y: number;
  20600. /**
  20601. * Z
  20602. */
  20603. z: number;
  20604. }
  20605. }
  20606. declare module "babylonjs/Physics/IPhysicsEngine" {
  20607. import { Nullable } from "babylonjs/types";
  20608. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20610. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20611. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20612. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20613. /**
  20614. * Interface used to describe a physics joint
  20615. */
  20616. export interface PhysicsImpostorJoint {
  20617. /** Defines the main impostor to which the joint is linked */
  20618. mainImpostor: PhysicsImpostor;
  20619. /** Defines the impostor that is connected to the main impostor using this joint */
  20620. connectedImpostor: PhysicsImpostor;
  20621. /** Defines the joint itself */
  20622. joint: PhysicsJoint;
  20623. }
  20624. /** @hidden */
  20625. export interface IPhysicsEnginePlugin {
  20626. world: any;
  20627. name: string;
  20628. setGravity(gravity: Vector3): void;
  20629. setTimeStep(timeStep: number): void;
  20630. getTimeStep(): number;
  20631. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20632. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20633. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20634. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20635. removePhysicsBody(impostor: PhysicsImpostor): void;
  20636. generateJoint(joint: PhysicsImpostorJoint): void;
  20637. removeJoint(joint: PhysicsImpostorJoint): void;
  20638. isSupported(): boolean;
  20639. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20640. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20641. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20642. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20643. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20644. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20645. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20646. getBodyMass(impostor: PhysicsImpostor): number;
  20647. getBodyFriction(impostor: PhysicsImpostor): number;
  20648. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20649. getBodyRestitution(impostor: PhysicsImpostor): number;
  20650. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20651. getBodyPressure?(impostor: PhysicsImpostor): number;
  20652. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20653. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20654. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20655. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20656. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20657. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20658. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20659. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20660. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20661. sleepBody(impostor: PhysicsImpostor): void;
  20662. wakeUpBody(impostor: PhysicsImpostor): void;
  20663. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20664. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20665. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20666. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20667. getRadius(impostor: PhysicsImpostor): number;
  20668. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20669. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20670. dispose(): void;
  20671. }
  20672. /**
  20673. * Interface used to define a physics engine
  20674. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20675. */
  20676. export interface IPhysicsEngine {
  20677. /**
  20678. * Gets the gravity vector used by the simulation
  20679. */
  20680. gravity: Vector3;
  20681. /**
  20682. * Sets the gravity vector used by the simulation
  20683. * @param gravity defines the gravity vector to use
  20684. */
  20685. setGravity(gravity: Vector3): void;
  20686. /**
  20687. * Set the time step of the physics engine.
  20688. * Default is 1/60.
  20689. * To slow it down, enter 1/600 for example.
  20690. * To speed it up, 1/30
  20691. * @param newTimeStep the new timestep to apply to this world.
  20692. */
  20693. setTimeStep(newTimeStep: number): void;
  20694. /**
  20695. * Get the time step of the physics engine.
  20696. * @returns the current time step
  20697. */
  20698. getTimeStep(): number;
  20699. /**
  20700. * Release all resources
  20701. */
  20702. dispose(): void;
  20703. /**
  20704. * Gets the name of the current physics plugin
  20705. * @returns the name of the plugin
  20706. */
  20707. getPhysicsPluginName(): string;
  20708. /**
  20709. * Adding a new impostor for the impostor tracking.
  20710. * This will be done by the impostor itself.
  20711. * @param impostor the impostor to add
  20712. */
  20713. addImpostor(impostor: PhysicsImpostor): void;
  20714. /**
  20715. * Remove an impostor from the engine.
  20716. * This impostor and its mesh will not longer be updated by the physics engine.
  20717. * @param impostor the impostor to remove
  20718. */
  20719. removeImpostor(impostor: PhysicsImpostor): void;
  20720. /**
  20721. * Add a joint to the physics engine
  20722. * @param mainImpostor defines the main impostor to which the joint is added.
  20723. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20724. * @param joint defines the joint that will connect both impostors.
  20725. */
  20726. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20727. /**
  20728. * Removes a joint from the simulation
  20729. * @param mainImpostor defines the impostor used with the joint
  20730. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20731. * @param joint defines the joint to remove
  20732. */
  20733. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20734. /**
  20735. * Gets the current plugin used to run the simulation
  20736. * @returns current plugin
  20737. */
  20738. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20739. /**
  20740. * Gets the list of physic impostors
  20741. * @returns an array of PhysicsImpostor
  20742. */
  20743. getImpostors(): Array<PhysicsImpostor>;
  20744. /**
  20745. * Gets the impostor for a physics enabled object
  20746. * @param object defines the object impersonated by the impostor
  20747. * @returns the PhysicsImpostor or null if not found
  20748. */
  20749. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20750. /**
  20751. * Gets the impostor for a physics body object
  20752. * @param body defines physics body used by the impostor
  20753. * @returns the PhysicsImpostor or null if not found
  20754. */
  20755. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20756. /**
  20757. * Does a raycast in the physics world
  20758. * @param from when should the ray start?
  20759. * @param to when should the ray end?
  20760. * @returns PhysicsRaycastResult
  20761. */
  20762. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20763. /**
  20764. * Called by the scene. No need to call it.
  20765. * @param delta defines the timespam between frames
  20766. */
  20767. _step(delta: number): void;
  20768. }
  20769. }
  20770. declare module "babylonjs/Physics/physicsImpostor" {
  20771. import { Nullable, IndicesArray } from "babylonjs/types";
  20772. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20773. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20775. import { Scene } from "babylonjs/scene";
  20776. import { Bone } from "babylonjs/Bones/bone";
  20777. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20778. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20779. /**
  20780. * The interface for the physics imposter parameters
  20781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20782. */
  20783. export interface PhysicsImpostorParameters {
  20784. /**
  20785. * The mass of the physics imposter
  20786. */
  20787. mass: number;
  20788. /**
  20789. * The friction of the physics imposter
  20790. */
  20791. friction?: number;
  20792. /**
  20793. * The coefficient of restitution of the physics imposter
  20794. */
  20795. restitution?: number;
  20796. /**
  20797. * The native options of the physics imposter
  20798. */
  20799. nativeOptions?: any;
  20800. /**
  20801. * Specifies if the parent should be ignored
  20802. */
  20803. ignoreParent?: boolean;
  20804. /**
  20805. * Specifies if bi-directional transformations should be disabled
  20806. */
  20807. disableBidirectionalTransformation?: boolean;
  20808. /**
  20809. * The pressure inside the physics imposter, soft object only
  20810. */
  20811. pressure?: number;
  20812. /**
  20813. * The stiffness the physics imposter, soft object only
  20814. */
  20815. stiffness?: number;
  20816. /**
  20817. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20818. */
  20819. velocityIterations?: number;
  20820. /**
  20821. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20822. */
  20823. positionIterations?: number;
  20824. /**
  20825. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20826. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20827. * Add to fix multiple points
  20828. */
  20829. fixedPoints?: number;
  20830. /**
  20831. * The collision margin around a soft object
  20832. */
  20833. margin?: number;
  20834. /**
  20835. * The collision margin around a soft object
  20836. */
  20837. damping?: number;
  20838. /**
  20839. * The path for a rope based on an extrusion
  20840. */
  20841. path?: any;
  20842. /**
  20843. * The shape of an extrusion used for a rope based on an extrusion
  20844. */
  20845. shape?: any;
  20846. }
  20847. /**
  20848. * Interface for a physics-enabled object
  20849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20850. */
  20851. export interface IPhysicsEnabledObject {
  20852. /**
  20853. * The position of the physics-enabled object
  20854. */
  20855. position: Vector3;
  20856. /**
  20857. * The rotation of the physics-enabled object
  20858. */
  20859. rotationQuaternion: Nullable<Quaternion>;
  20860. /**
  20861. * The scale of the physics-enabled object
  20862. */
  20863. scaling: Vector3;
  20864. /**
  20865. * The rotation of the physics-enabled object
  20866. */
  20867. rotation?: Vector3;
  20868. /**
  20869. * The parent of the physics-enabled object
  20870. */
  20871. parent?: any;
  20872. /**
  20873. * The bounding info of the physics-enabled object
  20874. * @returns The bounding info of the physics-enabled object
  20875. */
  20876. getBoundingInfo(): BoundingInfo;
  20877. /**
  20878. * Computes the world matrix
  20879. * @param force Specifies if the world matrix should be computed by force
  20880. * @returns A world matrix
  20881. */
  20882. computeWorldMatrix(force: boolean): Matrix;
  20883. /**
  20884. * Gets the world matrix
  20885. * @returns A world matrix
  20886. */
  20887. getWorldMatrix?(): Matrix;
  20888. /**
  20889. * Gets the child meshes
  20890. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20891. * @returns An array of abstract meshes
  20892. */
  20893. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20894. /**
  20895. * Gets the vertex data
  20896. * @param kind The type of vertex data
  20897. * @returns A nullable array of numbers, or a float32 array
  20898. */
  20899. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20900. /**
  20901. * Gets the indices from the mesh
  20902. * @returns A nullable array of index arrays
  20903. */
  20904. getIndices?(): Nullable<IndicesArray>;
  20905. /**
  20906. * Gets the scene from the mesh
  20907. * @returns the indices array or null
  20908. */
  20909. getScene?(): Scene;
  20910. /**
  20911. * Gets the absolute position from the mesh
  20912. * @returns the absolute position
  20913. */
  20914. getAbsolutePosition(): Vector3;
  20915. /**
  20916. * Gets the absolute pivot point from the mesh
  20917. * @returns the absolute pivot point
  20918. */
  20919. getAbsolutePivotPoint(): Vector3;
  20920. /**
  20921. * Rotates the mesh
  20922. * @param axis The axis of rotation
  20923. * @param amount The amount of rotation
  20924. * @param space The space of the rotation
  20925. * @returns The rotation transform node
  20926. */
  20927. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20928. /**
  20929. * Translates the mesh
  20930. * @param axis The axis of translation
  20931. * @param distance The distance of translation
  20932. * @param space The space of the translation
  20933. * @returns The transform node
  20934. */
  20935. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20936. /**
  20937. * Sets the absolute position of the mesh
  20938. * @param absolutePosition The absolute position of the mesh
  20939. * @returns The transform node
  20940. */
  20941. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20942. /**
  20943. * Gets the class name of the mesh
  20944. * @returns The class name
  20945. */
  20946. getClassName(): string;
  20947. }
  20948. /**
  20949. * Represents a physics imposter
  20950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20951. */
  20952. export class PhysicsImpostor {
  20953. /**
  20954. * The physics-enabled object used as the physics imposter
  20955. */
  20956. object: IPhysicsEnabledObject;
  20957. /**
  20958. * The type of the physics imposter
  20959. */
  20960. type: number;
  20961. private _options;
  20962. private _scene?;
  20963. /**
  20964. * The default object size of the imposter
  20965. */
  20966. static DEFAULT_OBJECT_SIZE: Vector3;
  20967. /**
  20968. * The identity quaternion of the imposter
  20969. */
  20970. static IDENTITY_QUATERNION: Quaternion;
  20971. /** @hidden */
  20972. _pluginData: any;
  20973. private _physicsEngine;
  20974. private _physicsBody;
  20975. private _bodyUpdateRequired;
  20976. private _onBeforePhysicsStepCallbacks;
  20977. private _onAfterPhysicsStepCallbacks;
  20978. /** @hidden */
  20979. _onPhysicsCollideCallbacks: Array<{
  20980. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20981. otherImpostors: Array<PhysicsImpostor>;
  20982. }>;
  20983. private _deltaPosition;
  20984. private _deltaRotation;
  20985. private _deltaRotationConjugated;
  20986. /** hidden */
  20987. _isFromLine: boolean;
  20988. private _parent;
  20989. private _isDisposed;
  20990. private static _tmpVecs;
  20991. private static _tmpQuat;
  20992. /**
  20993. * Specifies if the physics imposter is disposed
  20994. */
  20995. readonly isDisposed: boolean;
  20996. /**
  20997. * Gets the mass of the physics imposter
  20998. */
  20999. mass: number;
  21000. /**
  21001. * Gets the coefficient of friction
  21002. */
  21003. /**
  21004. * Sets the coefficient of friction
  21005. */
  21006. friction: number;
  21007. /**
  21008. * Gets the coefficient of restitution
  21009. */
  21010. /**
  21011. * Sets the coefficient of restitution
  21012. */
  21013. restitution: number;
  21014. /**
  21015. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  21016. */
  21017. /**
  21018. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21019. */
  21020. pressure: number;
  21021. /**
  21022. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21023. */
  21024. /**
  21025. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21026. */
  21027. stiffness: number;
  21028. /**
  21029. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21030. */
  21031. /**
  21032. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21033. */
  21034. velocityIterations: number;
  21035. /**
  21036. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21037. */
  21038. /**
  21039. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21040. */
  21041. positionIterations: number;
  21042. /**
  21043. * The unique id of the physics imposter
  21044. * set by the physics engine when adding this impostor to the array
  21045. */
  21046. uniqueId: number;
  21047. /**
  21048. * @hidden
  21049. */
  21050. soft: boolean;
  21051. /**
  21052. * @hidden
  21053. */
  21054. segments: number;
  21055. private _joints;
  21056. /**
  21057. * Initializes the physics imposter
  21058. * @param object The physics-enabled object used as the physics imposter
  21059. * @param type The type of the physics imposter
  21060. * @param _options The options for the physics imposter
  21061. * @param _scene The Babylon scene
  21062. */
  21063. constructor(
  21064. /**
  21065. * The physics-enabled object used as the physics imposter
  21066. */
  21067. object: IPhysicsEnabledObject,
  21068. /**
  21069. * The type of the physics imposter
  21070. */
  21071. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21072. /**
  21073. * This function will completly initialize this impostor.
  21074. * It will create a new body - but only if this mesh has no parent.
  21075. * If it has, this impostor will not be used other than to define the impostor
  21076. * of the child mesh.
  21077. * @hidden
  21078. */
  21079. _init(): void;
  21080. private _getPhysicsParent;
  21081. /**
  21082. * Should a new body be generated.
  21083. * @returns boolean specifying if body initialization is required
  21084. */
  21085. isBodyInitRequired(): boolean;
  21086. /**
  21087. * Sets the updated scaling
  21088. * @param updated Specifies if the scaling is updated
  21089. */
  21090. setScalingUpdated(): void;
  21091. /**
  21092. * Force a regeneration of this or the parent's impostor's body.
  21093. * Use under cautious - This will remove all joints already implemented.
  21094. */
  21095. forceUpdate(): void;
  21096. /**
  21097. * Gets the body that holds this impostor. Either its own, or its parent.
  21098. */
  21099. /**
  21100. * Set the physics body. Used mainly by the physics engine/plugin
  21101. */
  21102. physicsBody: any;
  21103. /**
  21104. * Get the parent of the physics imposter
  21105. * @returns Physics imposter or null
  21106. */
  21107. /**
  21108. * Sets the parent of the physics imposter
  21109. */
  21110. parent: Nullable<PhysicsImpostor>;
  21111. /**
  21112. * Resets the update flags
  21113. */
  21114. resetUpdateFlags(): void;
  21115. /**
  21116. * Gets the object extend size
  21117. * @returns the object extend size
  21118. */
  21119. getObjectExtendSize(): Vector3;
  21120. /**
  21121. * Gets the object center
  21122. * @returns The object center
  21123. */
  21124. getObjectCenter(): Vector3;
  21125. /**
  21126. * Get a specific parametes from the options parameter
  21127. * @param paramName The object parameter name
  21128. * @returns The object parameter
  21129. */
  21130. getParam(paramName: string): any;
  21131. /**
  21132. * Sets a specific parameter in the options given to the physics plugin
  21133. * @param paramName The parameter name
  21134. * @param value The value of the parameter
  21135. */
  21136. setParam(paramName: string, value: number): void;
  21137. /**
  21138. * Specifically change the body's mass option. Won't recreate the physics body object
  21139. * @param mass The mass of the physics imposter
  21140. */
  21141. setMass(mass: number): void;
  21142. /**
  21143. * Gets the linear velocity
  21144. * @returns linear velocity or null
  21145. */
  21146. getLinearVelocity(): Nullable<Vector3>;
  21147. /**
  21148. * Sets the linear velocity
  21149. * @param velocity linear velocity or null
  21150. */
  21151. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21152. /**
  21153. * Gets the angular velocity
  21154. * @returns angular velocity or null
  21155. */
  21156. getAngularVelocity(): Nullable<Vector3>;
  21157. /**
  21158. * Sets the angular velocity
  21159. * @param velocity The velocity or null
  21160. */
  21161. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21162. /**
  21163. * Execute a function with the physics plugin native code
  21164. * Provide a function the will have two variables - the world object and the physics body object
  21165. * @param func The function to execute with the physics plugin native code
  21166. */
  21167. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21168. /**
  21169. * Register a function that will be executed before the physics world is stepping forward
  21170. * @param func The function to execute before the physics world is stepped forward
  21171. */
  21172. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21173. /**
  21174. * Unregister a function that will be executed before the physics world is stepping forward
  21175. * @param func The function to execute before the physics world is stepped forward
  21176. */
  21177. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21178. /**
  21179. * Register a function that will be executed after the physics step
  21180. * @param func The function to execute after physics step
  21181. */
  21182. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21183. /**
  21184. * Unregisters a function that will be executed after the physics step
  21185. * @param func The function to execute after physics step
  21186. */
  21187. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21188. /**
  21189. * register a function that will be executed when this impostor collides against a different body
  21190. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21191. * @param func Callback that is executed on collision
  21192. */
  21193. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21194. /**
  21195. * Unregisters the physics imposter on contact
  21196. * @param collideAgainst The physics object to collide against
  21197. * @param func Callback to execute on collision
  21198. */
  21199. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21200. private _tmpQuat;
  21201. private _tmpQuat2;
  21202. /**
  21203. * Get the parent rotation
  21204. * @returns The parent rotation
  21205. */
  21206. getParentsRotation(): Quaternion;
  21207. /**
  21208. * this function is executed by the physics engine.
  21209. */
  21210. beforeStep: () => void;
  21211. /**
  21212. * this function is executed by the physics engine
  21213. */
  21214. afterStep: () => void;
  21215. /**
  21216. * Legacy collision detection event support
  21217. */
  21218. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21219. /**
  21220. * event and body object due to cannon's event-based architecture.
  21221. */
  21222. onCollide: (e: {
  21223. body: any;
  21224. }) => void;
  21225. /**
  21226. * Apply a force
  21227. * @param force The force to apply
  21228. * @param contactPoint The contact point for the force
  21229. * @returns The physics imposter
  21230. */
  21231. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21232. /**
  21233. * Apply an impulse
  21234. * @param force The impulse force
  21235. * @param contactPoint The contact point for the impulse force
  21236. * @returns The physics imposter
  21237. */
  21238. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21239. /**
  21240. * A help function to create a joint
  21241. * @param otherImpostor A physics imposter used to create a joint
  21242. * @param jointType The type of joint
  21243. * @param jointData The data for the joint
  21244. * @returns The physics imposter
  21245. */
  21246. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21247. /**
  21248. * Add a joint to this impostor with a different impostor
  21249. * @param otherImpostor A physics imposter used to add a joint
  21250. * @param joint The joint to add
  21251. * @returns The physics imposter
  21252. */
  21253. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21254. /**
  21255. * Add an anchor to a cloth impostor
  21256. * @param otherImpostor rigid impostor to anchor to
  21257. * @param width ratio across width from 0 to 1
  21258. * @param height ratio up height from 0 to 1
  21259. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21260. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21261. * @returns impostor the soft imposter
  21262. */
  21263. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21264. /**
  21265. * Add a hook to a rope impostor
  21266. * @param otherImpostor rigid impostor to anchor to
  21267. * @param length ratio across rope from 0 to 1
  21268. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21269. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21270. * @returns impostor the rope imposter
  21271. */
  21272. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21273. /**
  21274. * Will keep this body still, in a sleep mode.
  21275. * @returns the physics imposter
  21276. */
  21277. sleep(): PhysicsImpostor;
  21278. /**
  21279. * Wake the body up.
  21280. * @returns The physics imposter
  21281. */
  21282. wakeUp(): PhysicsImpostor;
  21283. /**
  21284. * Clones the physics imposter
  21285. * @param newObject The physics imposter clones to this physics-enabled object
  21286. * @returns A nullable physics imposter
  21287. */
  21288. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21289. /**
  21290. * Disposes the physics imposter
  21291. */
  21292. dispose(): void;
  21293. /**
  21294. * Sets the delta position
  21295. * @param position The delta position amount
  21296. */
  21297. setDeltaPosition(position: Vector3): void;
  21298. /**
  21299. * Sets the delta rotation
  21300. * @param rotation The delta rotation amount
  21301. */
  21302. setDeltaRotation(rotation: Quaternion): void;
  21303. /**
  21304. * Gets the box size of the physics imposter and stores the result in the input parameter
  21305. * @param result Stores the box size
  21306. * @returns The physics imposter
  21307. */
  21308. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21309. /**
  21310. * Gets the radius of the physics imposter
  21311. * @returns Radius of the physics imposter
  21312. */
  21313. getRadius(): number;
  21314. /**
  21315. * Sync a bone with this impostor
  21316. * @param bone The bone to sync to the impostor.
  21317. * @param boneMesh The mesh that the bone is influencing.
  21318. * @param jointPivot The pivot of the joint / bone in local space.
  21319. * @param distToJoint Optional distance from the impostor to the joint.
  21320. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21321. */
  21322. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21323. /**
  21324. * Sync impostor to a bone
  21325. * @param bone The bone that the impostor will be synced to.
  21326. * @param boneMesh The mesh that the bone is influencing.
  21327. * @param jointPivot The pivot of the joint / bone in local space.
  21328. * @param distToJoint Optional distance from the impostor to the joint.
  21329. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21330. * @param boneAxis Optional vector3 axis the bone is aligned with
  21331. */
  21332. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21333. /**
  21334. * No-Imposter type
  21335. */
  21336. static NoImpostor: number;
  21337. /**
  21338. * Sphere-Imposter type
  21339. */
  21340. static SphereImpostor: number;
  21341. /**
  21342. * Box-Imposter type
  21343. */
  21344. static BoxImpostor: number;
  21345. /**
  21346. * Plane-Imposter type
  21347. */
  21348. static PlaneImpostor: number;
  21349. /**
  21350. * Mesh-imposter type
  21351. */
  21352. static MeshImpostor: number;
  21353. /**
  21354. * Cylinder-Imposter type
  21355. */
  21356. static CylinderImpostor: number;
  21357. /**
  21358. * Particle-Imposter type
  21359. */
  21360. static ParticleImpostor: number;
  21361. /**
  21362. * Heightmap-Imposter type
  21363. */
  21364. static HeightmapImpostor: number;
  21365. /**
  21366. * ConvexHull-Impostor type (Ammo.js plugin only)
  21367. */
  21368. static ConvexHullImpostor: number;
  21369. /**
  21370. * Rope-Imposter type
  21371. */
  21372. static RopeImpostor: number;
  21373. /**
  21374. * Cloth-Imposter type
  21375. */
  21376. static ClothImpostor: number;
  21377. /**
  21378. * Softbody-Imposter type
  21379. */
  21380. static SoftbodyImpostor: number;
  21381. }
  21382. }
  21383. declare module "babylonjs/Meshes/mesh" {
  21384. import { Observable } from "babylonjs/Misc/observable";
  21385. import { IAnimatable } from "babylonjs/Misc/tools";
  21386. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21387. import { Camera } from "babylonjs/Cameras/camera";
  21388. import { Scene } from "babylonjs/scene";
  21389. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21390. import { Engine } from "babylonjs/Engines/engine";
  21391. import { Node } from "babylonjs/node";
  21392. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21393. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21394. import { Buffer } from "babylonjs/Meshes/buffer";
  21395. import { Geometry } from "babylonjs/Meshes/geometry";
  21396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21397. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21398. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21399. import { Effect } from "babylonjs/Materials/effect";
  21400. import { Material } from "babylonjs/Materials/material";
  21401. import { Skeleton } from "babylonjs/Bones/skeleton";
  21402. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21403. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21404. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21405. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21406. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21407. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21408. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21409. /**
  21410. * @hidden
  21411. **/
  21412. export class _CreationDataStorage {
  21413. closePath?: boolean;
  21414. closeArray?: boolean;
  21415. idx: number[];
  21416. dashSize: number;
  21417. gapSize: number;
  21418. path3D: Path3D;
  21419. pathArray: Vector3[][];
  21420. arc: number;
  21421. radius: number;
  21422. cap: number;
  21423. tessellation: number;
  21424. }
  21425. /**
  21426. * @hidden
  21427. **/
  21428. class _InstanceDataStorage {
  21429. visibleInstances: any;
  21430. batchCache: _InstancesBatch;
  21431. instancesBufferSize: number;
  21432. instancesBuffer: Nullable<Buffer>;
  21433. instancesData: Float32Array;
  21434. overridenInstanceCount: number;
  21435. isFrozen: boolean;
  21436. previousBatch: _InstancesBatch;
  21437. hardwareInstancedRendering: boolean;
  21438. sideOrientation: number;
  21439. }
  21440. /**
  21441. * @hidden
  21442. **/
  21443. export class _InstancesBatch {
  21444. mustReturn: boolean;
  21445. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21446. renderSelf: boolean[];
  21447. hardwareInstancedRendering: boolean[];
  21448. }
  21449. /**
  21450. * Class used to represent renderable models
  21451. */
  21452. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21453. /**
  21454. * Mesh side orientation : usually the external or front surface
  21455. */
  21456. static readonly FRONTSIDE: number;
  21457. /**
  21458. * Mesh side orientation : usually the internal or back surface
  21459. */
  21460. static readonly BACKSIDE: number;
  21461. /**
  21462. * Mesh side orientation : both internal and external or front and back surfaces
  21463. */
  21464. static readonly DOUBLESIDE: number;
  21465. /**
  21466. * Mesh side orientation : by default, `FRONTSIDE`
  21467. */
  21468. static readonly DEFAULTSIDE: number;
  21469. /**
  21470. * Mesh cap setting : no cap
  21471. */
  21472. static readonly NO_CAP: number;
  21473. /**
  21474. * Mesh cap setting : one cap at the beginning of the mesh
  21475. */
  21476. static readonly CAP_START: number;
  21477. /**
  21478. * Mesh cap setting : one cap at the end of the mesh
  21479. */
  21480. static readonly CAP_END: number;
  21481. /**
  21482. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21483. */
  21484. static readonly CAP_ALL: number;
  21485. /**
  21486. * Gets the default side orientation.
  21487. * @param orientation the orientation to value to attempt to get
  21488. * @returns the default orientation
  21489. * @hidden
  21490. */
  21491. static _GetDefaultSideOrientation(orientation?: number): number;
  21492. private _internalMeshDataInfo;
  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. /**
  21533. * User defined function used to change how LOD level selection is done
  21534. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21535. */
  21536. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21537. /**
  21538. * Gets or sets the morph target manager
  21539. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21540. */
  21541. morphTargetManager: Nullable<MorphTargetManager>;
  21542. /** @hidden */
  21543. _creationDataStorage: Nullable<_CreationDataStorage>;
  21544. /** @hidden */
  21545. _geometry: Nullable<Geometry>;
  21546. /** @hidden */
  21547. _delayInfo: Array<string>;
  21548. /** @hidden */
  21549. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21550. /** @hidden */
  21551. _instanceDataStorage: _InstanceDataStorage;
  21552. private _effectiveMaterial;
  21553. /** @hidden */
  21554. _shouldGenerateFlatShading: boolean;
  21555. /** @hidden */
  21556. _originalBuilderSideOrientation: number;
  21557. /**
  21558. * Use this property to change the original side orientation defined at construction time
  21559. */
  21560. overrideMaterialSideOrientation: Nullable<number>;
  21561. /**
  21562. * Gets the source mesh (the one used to clone this one from)
  21563. */
  21564. readonly source: Nullable<Mesh>;
  21565. /**
  21566. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21567. */
  21568. isUnIndexed: boolean;
  21569. /**
  21570. * @constructor
  21571. * @param name The value used by scene.getMeshByName() to do a lookup.
  21572. * @param scene The scene to add this mesh to.
  21573. * @param parent The parent of this mesh, if it has one
  21574. * @param source An optional Mesh from which geometry is shared, cloned.
  21575. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21576. * When false, achieved by calling a clone(), also passing False.
  21577. * This will make creation of children, recursive.
  21578. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21579. */
  21580. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21581. /**
  21582. * Gets the class name
  21583. * @returns the string "Mesh".
  21584. */
  21585. getClassName(): string;
  21586. /** @hidden */
  21587. readonly _isMesh: boolean;
  21588. /**
  21589. * Returns a description of this mesh
  21590. * @param fullDetails define if full details about this mesh must be used
  21591. * @returns a descriptive string representing this mesh
  21592. */
  21593. toString(fullDetails?: boolean): string;
  21594. /** @hidden */
  21595. _unBindEffect(): void;
  21596. /**
  21597. * Gets a boolean indicating if this mesh has LOD
  21598. */
  21599. readonly hasLODLevels: boolean;
  21600. /**
  21601. * Gets the list of MeshLODLevel associated with the current mesh
  21602. * @returns an array of MeshLODLevel
  21603. */
  21604. getLODLevels(): MeshLODLevel[];
  21605. private _sortLODLevels;
  21606. /**
  21607. * Add a mesh as LOD level triggered at the given distance.
  21608. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21609. * @param distance The distance from the center of the object to show this level
  21610. * @param mesh The mesh to be added as LOD level (can be null)
  21611. * @return This mesh (for chaining)
  21612. */
  21613. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21614. /**
  21615. * Returns the LOD level mesh at the passed distance or null if not found.
  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. * @returns a Mesh or `null`
  21619. */
  21620. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21621. /**
  21622. * Remove a mesh from the LOD array
  21623. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21624. * @param mesh defines the mesh to be removed
  21625. * @return This mesh (for chaining)
  21626. */
  21627. removeLODLevel(mesh: Mesh): Mesh;
  21628. /**
  21629. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21630. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21631. * @param camera defines the camera to use to compute distance
  21632. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21633. * @return This mesh (for chaining)
  21634. */
  21635. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21636. /**
  21637. * Gets the mesh internal Geometry object
  21638. */
  21639. readonly geometry: Nullable<Geometry>;
  21640. /**
  21641. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21642. * @returns the total number of vertices
  21643. */
  21644. getTotalVertices(): number;
  21645. /**
  21646. * Returns the content of an associated vertex buffer
  21647. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21648. * - VertexBuffer.PositionKind
  21649. * - VertexBuffer.UVKind
  21650. * - VertexBuffer.UV2Kind
  21651. * - VertexBuffer.UV3Kind
  21652. * - VertexBuffer.UV4Kind
  21653. * - VertexBuffer.UV5Kind
  21654. * - VertexBuffer.UV6Kind
  21655. * - VertexBuffer.ColorKind
  21656. * - VertexBuffer.MatricesIndicesKind
  21657. * - VertexBuffer.MatricesIndicesExtraKind
  21658. * - VertexBuffer.MatricesWeightsKind
  21659. * - VertexBuffer.MatricesWeightsExtraKind
  21660. * @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
  21661. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21662. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21663. */
  21664. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21665. /**
  21666. * Returns the mesh VertexBuffer object from the requested `kind`
  21667. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21668. * - VertexBuffer.PositionKind
  21669. * - VertexBuffer.UVKind
  21670. * - VertexBuffer.UV2Kind
  21671. * - VertexBuffer.UV3Kind
  21672. * - VertexBuffer.UV4Kind
  21673. * - VertexBuffer.UV5Kind
  21674. * - VertexBuffer.UV6Kind
  21675. * - VertexBuffer.ColorKind
  21676. * - VertexBuffer.MatricesIndicesKind
  21677. * - VertexBuffer.MatricesIndicesExtraKind
  21678. * - VertexBuffer.MatricesWeightsKind
  21679. * - VertexBuffer.MatricesWeightsExtraKind
  21680. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21681. */
  21682. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21683. /**
  21684. * Tests if a specific vertex buffer is associated with this mesh
  21685. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21686. * - VertexBuffer.PositionKind
  21687. * - VertexBuffer.UVKind
  21688. * - VertexBuffer.UV2Kind
  21689. * - VertexBuffer.UV3Kind
  21690. * - VertexBuffer.UV4Kind
  21691. * - VertexBuffer.UV5Kind
  21692. * - VertexBuffer.UV6Kind
  21693. * - VertexBuffer.ColorKind
  21694. * - VertexBuffer.MatricesIndicesKind
  21695. * - VertexBuffer.MatricesIndicesExtraKind
  21696. * - VertexBuffer.MatricesWeightsKind
  21697. * - VertexBuffer.MatricesWeightsExtraKind
  21698. * @returns a boolean
  21699. */
  21700. isVerticesDataPresent(kind: string): boolean;
  21701. /**
  21702. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21703. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21704. * - VertexBuffer.PositionKind
  21705. * - VertexBuffer.UVKind
  21706. * - VertexBuffer.UV2Kind
  21707. * - VertexBuffer.UV3Kind
  21708. * - VertexBuffer.UV4Kind
  21709. * - VertexBuffer.UV5Kind
  21710. * - VertexBuffer.UV6Kind
  21711. * - VertexBuffer.ColorKind
  21712. * - VertexBuffer.MatricesIndicesKind
  21713. * - VertexBuffer.MatricesIndicesExtraKind
  21714. * - VertexBuffer.MatricesWeightsKind
  21715. * - VertexBuffer.MatricesWeightsExtraKind
  21716. * @returns a boolean
  21717. */
  21718. isVertexBufferUpdatable(kind: string): boolean;
  21719. /**
  21720. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21721. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21722. * - VertexBuffer.PositionKind
  21723. * - VertexBuffer.UVKind
  21724. * - VertexBuffer.UV2Kind
  21725. * - VertexBuffer.UV3Kind
  21726. * - VertexBuffer.UV4Kind
  21727. * - VertexBuffer.UV5Kind
  21728. * - VertexBuffer.UV6Kind
  21729. * - VertexBuffer.ColorKind
  21730. * - VertexBuffer.MatricesIndicesKind
  21731. * - VertexBuffer.MatricesIndicesExtraKind
  21732. * - VertexBuffer.MatricesWeightsKind
  21733. * - VertexBuffer.MatricesWeightsExtraKind
  21734. * @returns an array of strings
  21735. */
  21736. getVerticesDataKinds(): string[];
  21737. /**
  21738. * Returns a positive integer : the total number of indices in this mesh geometry.
  21739. * @returns the numner of indices or zero if the mesh has no geometry.
  21740. */
  21741. getTotalIndices(): number;
  21742. /**
  21743. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21744. * @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.
  21745. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21746. * @returns the indices array or an empty array if the mesh has no geometry
  21747. */
  21748. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21749. readonly isBlocked: boolean;
  21750. /**
  21751. * Determine if the current mesh is ready to be rendered
  21752. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21753. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21754. * @returns true if all associated assets are ready (material, textures, shaders)
  21755. */
  21756. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21757. /**
  21758. * 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.
  21759. */
  21760. readonly areNormalsFrozen: boolean;
  21761. /**
  21762. * 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.
  21763. * @returns the current mesh
  21764. */
  21765. freezeNormals(): Mesh;
  21766. /**
  21767. * 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
  21768. * @returns the current mesh
  21769. */
  21770. unfreezeNormals(): Mesh;
  21771. /**
  21772. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21773. */
  21774. overridenInstanceCount: number;
  21775. /** @hidden */
  21776. _preActivate(): Mesh;
  21777. /** @hidden */
  21778. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21779. /** @hidden */
  21780. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21781. /**
  21782. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21783. * This means the mesh underlying bounding box and sphere are recomputed.
  21784. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21785. * @returns the current mesh
  21786. */
  21787. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21788. /** @hidden */
  21789. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21790. /**
  21791. * This function will subdivide the mesh into multiple submeshes
  21792. * @param count defines the expected number of submeshes
  21793. */
  21794. subdivide(count: number): void;
  21795. /**
  21796. * Copy a FloatArray into a specific associated vertex buffer
  21797. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21798. * - VertexBuffer.PositionKind
  21799. * - VertexBuffer.UVKind
  21800. * - VertexBuffer.UV2Kind
  21801. * - VertexBuffer.UV3Kind
  21802. * - VertexBuffer.UV4Kind
  21803. * - VertexBuffer.UV5Kind
  21804. * - VertexBuffer.UV6Kind
  21805. * - VertexBuffer.ColorKind
  21806. * - VertexBuffer.MatricesIndicesKind
  21807. * - VertexBuffer.MatricesIndicesExtraKind
  21808. * - VertexBuffer.MatricesWeightsKind
  21809. * - VertexBuffer.MatricesWeightsExtraKind
  21810. * @param data defines the data source
  21811. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21812. * @param stride defines the data stride size (can be null)
  21813. * @returns the current mesh
  21814. */
  21815. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21816. /**
  21817. * Flags an associated vertex buffer as updatable
  21818. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21819. * - VertexBuffer.PositionKind
  21820. * - VertexBuffer.UVKind
  21821. * - VertexBuffer.UV2Kind
  21822. * - VertexBuffer.UV3Kind
  21823. * - VertexBuffer.UV4Kind
  21824. * - VertexBuffer.UV5Kind
  21825. * - VertexBuffer.UV6Kind
  21826. * - VertexBuffer.ColorKind
  21827. * - VertexBuffer.MatricesIndicesKind
  21828. * - VertexBuffer.MatricesIndicesExtraKind
  21829. * - VertexBuffer.MatricesWeightsKind
  21830. * - VertexBuffer.MatricesWeightsExtraKind
  21831. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21832. */
  21833. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21834. /**
  21835. * Sets the mesh global Vertex Buffer
  21836. * @param buffer defines the buffer to use
  21837. * @returns the current mesh
  21838. */
  21839. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21840. /**
  21841. * Update a specific associated vertex buffer
  21842. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21843. * - VertexBuffer.PositionKind
  21844. * - VertexBuffer.UVKind
  21845. * - VertexBuffer.UV2Kind
  21846. * - VertexBuffer.UV3Kind
  21847. * - VertexBuffer.UV4Kind
  21848. * - VertexBuffer.UV5Kind
  21849. * - VertexBuffer.UV6Kind
  21850. * - VertexBuffer.ColorKind
  21851. * - VertexBuffer.MatricesIndicesKind
  21852. * - VertexBuffer.MatricesIndicesExtraKind
  21853. * - VertexBuffer.MatricesWeightsKind
  21854. * - VertexBuffer.MatricesWeightsExtraKind
  21855. * @param data defines the data source
  21856. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21857. * @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)
  21858. * @returns the current mesh
  21859. */
  21860. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21861. /**
  21862. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21863. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21864. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21865. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21866. * @returns the current mesh
  21867. */
  21868. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21869. /**
  21870. * Creates a un-shared specific occurence of the geometry for the mesh.
  21871. * @returns the current mesh
  21872. */
  21873. makeGeometryUnique(): Mesh;
  21874. /**
  21875. * Set the index buffer of this mesh
  21876. * @param indices defines the source data
  21877. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21878. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21879. * @returns the current mesh
  21880. */
  21881. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21882. /**
  21883. * Update the current index buffer
  21884. * @param indices defines the source data
  21885. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21886. * @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)
  21887. * @returns the current mesh
  21888. */
  21889. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21890. /**
  21891. * Invert the geometry to move from a right handed system to a left handed one.
  21892. * @returns the current mesh
  21893. */
  21894. toLeftHanded(): Mesh;
  21895. /** @hidden */
  21896. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21897. /** @hidden */
  21898. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21899. /**
  21900. * Registers for this mesh a javascript function called just before the rendering process
  21901. * @param func defines the function to call before rendering this mesh
  21902. * @returns the current mesh
  21903. */
  21904. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21905. /**
  21906. * Disposes a previously registered javascript function called before the rendering
  21907. * @param func defines the function to remove
  21908. * @returns the current mesh
  21909. */
  21910. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21911. /**
  21912. * Registers for this mesh a javascript function called just after the rendering is complete
  21913. * @param func defines the function to call after rendering this mesh
  21914. * @returns the current mesh
  21915. */
  21916. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21917. /**
  21918. * Disposes a previously registered javascript function called after the rendering.
  21919. * @param func defines the function to remove
  21920. * @returns the current mesh
  21921. */
  21922. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21923. /** @hidden */
  21924. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21925. /** @hidden */
  21926. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21927. /** @hidden */
  21928. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21929. /** @hidden */
  21930. _freeze(): void;
  21931. /** @hidden */
  21932. _unFreeze(): void;
  21933. /**
  21934. * 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
  21935. * @param subMesh defines the subMesh to render
  21936. * @param enableAlphaMode defines if alpha mode can be changed
  21937. * @returns the current mesh
  21938. */
  21939. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21940. private _onBeforeDraw;
  21941. /**
  21942. * Renormalize the mesh and patch it up if there are no weights
  21943. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21944. * However in the case of zero weights then we set just a single influence to 1.
  21945. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21946. */
  21947. cleanMatrixWeights(): void;
  21948. private normalizeSkinFourWeights;
  21949. private normalizeSkinWeightsAndExtra;
  21950. /**
  21951. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21952. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21953. * the user know there was an issue with importing the mesh
  21954. * @returns a validation object with skinned, valid and report string
  21955. */
  21956. validateSkinning(): {
  21957. skinned: boolean;
  21958. valid: boolean;
  21959. report: string;
  21960. };
  21961. /** @hidden */
  21962. _checkDelayState(): Mesh;
  21963. private _queueLoad;
  21964. /**
  21965. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21966. * A mesh is in the frustum if its bounding box intersects the frustum
  21967. * @param frustumPlanes defines the frustum to test
  21968. * @returns true if the mesh is in the frustum planes
  21969. */
  21970. isInFrustum(frustumPlanes: Plane[]): boolean;
  21971. /**
  21972. * Sets the mesh material by the material or multiMaterial `id` property
  21973. * @param id is a string identifying the material or the multiMaterial
  21974. * @returns the current mesh
  21975. */
  21976. setMaterialByID(id: string): Mesh;
  21977. /**
  21978. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21979. * @returns an array of IAnimatable
  21980. */
  21981. getAnimatables(): IAnimatable[];
  21982. /**
  21983. * Modifies the mesh geometry according to the passed transformation matrix.
  21984. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21985. * The mesh normals are modified using the same transformation.
  21986. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21987. * @param transform defines the transform matrix to use
  21988. * @see http://doc.babylonjs.com/resources/baking_transformations
  21989. * @returns the current mesh
  21990. */
  21991. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21992. /**
  21993. * Modifies the mesh geometry according to its own current World Matrix.
  21994. * The mesh World Matrix is then reset.
  21995. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21996. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21997. * @see http://doc.babylonjs.com/resources/baking_transformations
  21998. * @returns the current mesh
  21999. */
  22000. bakeCurrentTransformIntoVertices(): Mesh;
  22001. /** @hidden */
  22002. readonly _positions: Nullable<Vector3[]>;
  22003. /** @hidden */
  22004. _resetPointsArrayCache(): Mesh;
  22005. /** @hidden */
  22006. _generatePointsArray(): boolean;
  22007. /**
  22008. * Returns a new Mesh object generated from the current mesh properties.
  22009. * This method must not get confused with createInstance()
  22010. * @param name is a string, the name given to the new mesh
  22011. * @param newParent can be any Node object (default `null`)
  22012. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22013. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22014. * @returns a new mesh
  22015. */
  22016. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22017. /**
  22018. * Releases resources associated with this mesh.
  22019. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22020. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22021. */
  22022. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22023. /**
  22024. * Modifies the mesh geometry according to a displacement map.
  22025. * 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.
  22026. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22027. * @param url is a string, the URL from the image file is to be downloaded.
  22028. * @param minHeight is the lower limit of the displacement.
  22029. * @param maxHeight is the upper limit of the displacement.
  22030. * @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.
  22031. * @param uvOffset is an optional vector2 used to offset UV.
  22032. * @param uvScale is an optional vector2 used to scale UV.
  22033. * @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.
  22034. * @returns the Mesh.
  22035. */
  22036. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22037. /**
  22038. * Modifies the mesh geometry according to a displacementMap buffer.
  22039. * 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.
  22040. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22041. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22042. * @param heightMapWidth is the width of the buffer image.
  22043. * @param heightMapHeight is the height of the buffer image.
  22044. * @param minHeight is the lower limit of the displacement.
  22045. * @param maxHeight is the upper limit of the displacement.
  22046. * @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.
  22047. * @param uvOffset is an optional vector2 used to offset UV.
  22048. * @param uvScale is an optional vector2 used to scale UV.
  22049. * @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.
  22050. * @returns the Mesh.
  22051. */
  22052. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22053. /**
  22054. * Modify the mesh to get a flat shading rendering.
  22055. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22056. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22057. * @returns current mesh
  22058. */
  22059. convertToFlatShadedMesh(): Mesh;
  22060. /**
  22061. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22062. * In other words, more vertices, no more indices and a single bigger VBO.
  22063. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22064. * @returns current mesh
  22065. */
  22066. convertToUnIndexedMesh(): Mesh;
  22067. /**
  22068. * Inverses facet orientations.
  22069. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22070. * @param flipNormals will also inverts the normals
  22071. * @returns current mesh
  22072. */
  22073. flipFaces(flipNormals?: boolean): Mesh;
  22074. /**
  22075. * Increase the number of facets and hence vertices in a mesh
  22076. * Vertex normals are interpolated from existing vertex normals
  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 numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22079. */
  22080. increaseVertices(numberPerEdge: number): void;
  22081. /**
  22082. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22083. * This will undo any application of covertToFlatShadedMesh
  22084. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22085. */
  22086. forceSharedVertices(): void;
  22087. /** @hidden */
  22088. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22089. /** @hidden */
  22090. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22091. /**
  22092. * Creates a new InstancedMesh object from the mesh model.
  22093. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22094. * @param name defines the name of the new instance
  22095. * @returns a new InstancedMesh
  22096. */
  22097. createInstance(name: string): InstancedMesh;
  22098. /**
  22099. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22100. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22101. * @returns the current mesh
  22102. */
  22103. synchronizeInstances(): Mesh;
  22104. /**
  22105. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22106. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22107. * This should be used together with the simplification to avoid disappearing triangles.
  22108. * @param successCallback an optional success callback to be called after the optimization finished.
  22109. * @returns the current mesh
  22110. */
  22111. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22112. /**
  22113. * Serialize current mesh
  22114. * @param serializationObject defines the object which will receive the serialization data
  22115. */
  22116. serialize(serializationObject: any): void;
  22117. /** @hidden */
  22118. _syncGeometryWithMorphTargetManager(): void;
  22119. /** @hidden */
  22120. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22121. /**
  22122. * Returns a new Mesh object parsed from the source provided.
  22123. * @param parsedMesh is the source
  22124. * @param scene defines the hosting scene
  22125. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22126. * @returns a new Mesh
  22127. */
  22128. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22129. /**
  22130. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22131. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22132. * @param name defines the name of the mesh to create
  22133. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22134. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22135. * @param closePath creates a seam between the first and the last points of each path of the path array
  22136. * @param offset is taken in account only if the `pathArray` is containing a single path
  22137. * @param scene defines the hosting scene
  22138. * @param updatable defines if the mesh must be flagged as updatable
  22139. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22140. * @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)
  22141. * @returns a new Mesh
  22142. */
  22143. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22144. /**
  22145. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22146. * @param name defines the name of the mesh to create
  22147. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22148. * @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
  22149. * @param scene defines the hosting scene
  22150. * @param updatable defines if the mesh must be flagged as updatable
  22151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22152. * @returns a new Mesh
  22153. */
  22154. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22155. /**
  22156. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22157. * @param name defines the name of the mesh to create
  22158. * @param size sets the size (float) of each box side (default 1)
  22159. * @param scene defines the hosting scene
  22160. * @param updatable defines if the mesh must be flagged as updatable
  22161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22162. * @returns a new Mesh
  22163. */
  22164. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22165. /**
  22166. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22167. * @param name defines the name of the mesh to create
  22168. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22169. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22170. * @param scene defines the hosting scene
  22171. * @param updatable defines if the mesh must be flagged as updatable
  22172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22173. * @returns a new Mesh
  22174. */
  22175. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22176. /**
  22177. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22178. * @param name defines the name of the mesh to create
  22179. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22180. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22181. * @param scene defines the hosting scene
  22182. * @returns a new Mesh
  22183. */
  22184. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22185. /**
  22186. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22187. * @param name defines the name of the mesh to create
  22188. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22189. * @param diameterTop set the top cap diameter (floats, default 1)
  22190. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22191. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22192. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22193. * @param scene defines the hosting scene
  22194. * @param updatable defines if the mesh must be flagged as updatable
  22195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22196. * @returns a new Mesh
  22197. */
  22198. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22199. /**
  22200. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22201. * @param name defines the name of the mesh to create
  22202. * @param diameter sets the diameter size (float) of the torus (default 1)
  22203. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22204. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22205. * @param scene defines the hosting scene
  22206. * @param updatable defines if the mesh must be flagged as updatable
  22207. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22208. * @returns a new Mesh
  22209. */
  22210. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22211. /**
  22212. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22213. * @param name defines the name of the mesh to create
  22214. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22215. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22216. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22217. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22218. * @param p the number of windings on X axis (positive integers, default 2)
  22219. * @param q the number of windings on Y axis (positive integers, default 3)
  22220. * @param scene defines the hosting scene
  22221. * @param updatable defines if the mesh must be flagged as updatable
  22222. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22223. * @returns a new Mesh
  22224. */
  22225. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22226. /**
  22227. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22228. * @param name defines the name of the mesh to create
  22229. * @param points is an array successive Vector3
  22230. * @param scene defines the hosting scene
  22231. * @param updatable defines if the mesh must be flagged as updatable
  22232. * @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).
  22233. * @returns a new Mesh
  22234. */
  22235. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22236. /**
  22237. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22238. * @param name defines the name of the mesh to create
  22239. * @param points is an array successive Vector3
  22240. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22241. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22242. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22243. * @param scene defines the hosting scene
  22244. * @param updatable defines if the mesh must be flagged as updatable
  22245. * @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)
  22246. * @returns a new Mesh
  22247. */
  22248. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22249. /**
  22250. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22251. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22252. * 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.
  22253. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22254. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22255. * Remember you can only change the shape positions, not their number when updating a polygon.
  22256. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22257. * @param name defines the name of the mesh to create
  22258. * @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
  22259. * @param scene defines the hosting scene
  22260. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22261. * @param updatable defines if the mesh must be flagged as updatable
  22262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22263. * @param earcutInjection can be used to inject your own earcut reference
  22264. * @returns a new Mesh
  22265. */
  22266. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22267. /**
  22268. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22269. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22270. * @param name defines the name of the mesh to create
  22271. * @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
  22272. * @param depth defines the height of extrusion
  22273. * @param scene defines the hosting scene
  22274. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22275. * @param updatable defines if the mesh must be flagged as updatable
  22276. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22277. * @param earcutInjection can be used to inject your own earcut reference
  22278. * @returns a new Mesh
  22279. */
  22280. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22281. /**
  22282. * Creates an extruded shape mesh.
  22283. * 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
  22284. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22285. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22286. * @param name defines the name of the mesh to create
  22287. * @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
  22288. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22289. * @param scale is the value to scale the shape
  22290. * @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
  22291. * @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
  22292. * @param scene defines the hosting scene
  22293. * @param updatable defines if the mesh must be flagged as updatable
  22294. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22295. * @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)
  22296. * @returns a new Mesh
  22297. */
  22298. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22299. /**
  22300. * Creates an custom extruded shape mesh.
  22301. * The custom extrusion is a parametric shape.
  22302. * It has no predefined shape. Its final shape will depend on the input parameters.
  22303. * Please consider using the same method from the MeshBuilder class instead
  22304. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22305. * @param name defines the name of the mesh to create
  22306. * @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
  22307. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22308. * @param scaleFunction is a custom Javascript function called on each path point
  22309. * @param rotationFunction is a custom Javascript function called on each path point
  22310. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22311. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22312. * @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
  22313. * @param scene defines the hosting scene
  22314. * @param updatable defines if the mesh must be flagged as updatable
  22315. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22316. * @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)
  22317. * @returns a new Mesh
  22318. */
  22319. 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;
  22320. /**
  22321. * Creates lathe mesh.
  22322. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22323. * Please consider using the same method from the MeshBuilder class instead
  22324. * @param name defines the name of the mesh to create
  22325. * @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
  22326. * @param radius is the radius value of the lathe
  22327. * @param tessellation is the side number of the lathe.
  22328. * @param scene defines the hosting scene
  22329. * @param updatable defines if the mesh must be flagged as updatable
  22330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22331. * @returns a new Mesh
  22332. */
  22333. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22334. /**
  22335. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22336. * @param name defines the name of the mesh to create
  22337. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22338. * @param scene defines the hosting scene
  22339. * @param updatable defines if the mesh must be flagged as updatable
  22340. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22341. * @returns a new Mesh
  22342. */
  22343. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22344. /**
  22345. * Creates a ground mesh.
  22346. * Please consider using the same method from the MeshBuilder class instead
  22347. * @param name defines the name of the mesh to create
  22348. * @param width set the width of the ground
  22349. * @param height set the height of the ground
  22350. * @param subdivisions sets the number of subdivisions per side
  22351. * @param scene defines the hosting scene
  22352. * @param updatable defines if the mesh must be flagged as updatable
  22353. * @returns a new Mesh
  22354. */
  22355. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22356. /**
  22357. * Creates a tiled ground mesh.
  22358. * Please consider using the same method from the MeshBuilder class instead
  22359. * @param name defines the name of the mesh to create
  22360. * @param xmin set the ground minimum X coordinate
  22361. * @param zmin set the ground minimum Y coordinate
  22362. * @param xmax set the ground maximum X coordinate
  22363. * @param zmax set the ground maximum Z coordinate
  22364. * @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
  22365. * @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
  22366. * @param scene defines the hosting scene
  22367. * @param updatable defines if the mesh must be flagged as updatable
  22368. * @returns a new Mesh
  22369. */
  22370. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22371. w: number;
  22372. h: number;
  22373. }, precision: {
  22374. w: number;
  22375. h: number;
  22376. }, scene: Scene, updatable?: boolean): Mesh;
  22377. /**
  22378. * Creates a ground mesh from a height map.
  22379. * Please consider using the same method from the MeshBuilder class instead
  22380. * @see http://doc.babylonjs.com/babylon101/height_map
  22381. * @param name defines the name of the mesh to create
  22382. * @param url sets the URL of the height map image resource
  22383. * @param width set the ground width size
  22384. * @param height set the ground height size
  22385. * @param subdivisions sets the number of subdivision per side
  22386. * @param minHeight is the minimum altitude on the ground
  22387. * @param maxHeight is the maximum altitude on the ground
  22388. * @param scene defines the hosting scene
  22389. * @param updatable defines if the mesh must be flagged as updatable
  22390. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22391. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22392. * @returns a new Mesh
  22393. */
  22394. 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;
  22395. /**
  22396. * Creates a tube mesh.
  22397. * The tube is a parametric shape.
  22398. * It has no predefined shape. Its final shape will depend on the input parameters.
  22399. * Please consider using the same method from the MeshBuilder class instead
  22400. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22401. * @param name defines the name of the mesh to create
  22402. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22403. * @param radius sets the tube radius size
  22404. * @param tessellation is the number of sides on the tubular surface
  22405. * @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
  22406. * @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
  22407. * @param scene defines the hosting scene
  22408. * @param updatable defines if the mesh must be flagged as updatable
  22409. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22410. * @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)
  22411. * @returns a new Mesh
  22412. */
  22413. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22414. (i: number, distance: number): number;
  22415. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22416. /**
  22417. * Creates a polyhedron mesh.
  22418. * Please consider using the same method from the MeshBuilder class instead.
  22419. * * 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
  22420. * * The parameter `size` (positive float, default 1) sets the polygon size
  22421. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22422. * * 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`
  22423. * * 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
  22424. * * 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)`)
  22425. * * 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
  22426. * * 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
  22427. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22428. * * If you create a double-sided mesh, you can choose what parts of 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
  22429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22430. * @param name defines the name of the mesh to create
  22431. * @param options defines the options used to create the mesh
  22432. * @param scene defines the hosting scene
  22433. * @returns a new Mesh
  22434. */
  22435. static CreatePolyhedron(name: string, options: {
  22436. type?: number;
  22437. size?: number;
  22438. sizeX?: number;
  22439. sizeY?: number;
  22440. sizeZ?: number;
  22441. custom?: any;
  22442. faceUV?: Vector4[];
  22443. faceColors?: Color4[];
  22444. updatable?: boolean;
  22445. sideOrientation?: number;
  22446. }, scene: Scene): Mesh;
  22447. /**
  22448. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22449. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22450. * * 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`)
  22451. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22452. * * 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
  22453. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22454. * * If you create a double-sided mesh, you can choose what parts of 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
  22455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22456. * @param name defines the name of the mesh
  22457. * @param options defines the options used to create the mesh
  22458. * @param scene defines the hosting scene
  22459. * @returns a new Mesh
  22460. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22461. */
  22462. static CreateIcoSphere(name: string, options: {
  22463. radius?: number;
  22464. flat?: boolean;
  22465. subdivisions?: number;
  22466. sideOrientation?: number;
  22467. updatable?: boolean;
  22468. }, scene: Scene): Mesh;
  22469. /**
  22470. * Creates a decal mesh.
  22471. * Please consider using the same method from the MeshBuilder class instead.
  22472. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22473. * @param name defines the name of the mesh
  22474. * @param sourceMesh defines the mesh receiving the decal
  22475. * @param position sets the position of the decal in world coordinates
  22476. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22477. * @param size sets the decal scaling
  22478. * @param angle sets the angle to rotate the decal
  22479. * @returns a new Mesh
  22480. */
  22481. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22482. /**
  22483. * Prepare internal position array for software CPU skinning
  22484. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22485. */
  22486. setPositionsForCPUSkinning(): Float32Array;
  22487. /**
  22488. * Prepare internal normal array for software CPU skinning
  22489. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22490. */
  22491. setNormalsForCPUSkinning(): Float32Array;
  22492. /**
  22493. * Updates the vertex buffer by applying transformation from the bones
  22494. * @param skeleton defines the skeleton to apply to current mesh
  22495. * @returns the current mesh
  22496. */
  22497. applySkeleton(skeleton: Skeleton): Mesh;
  22498. /**
  22499. * 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
  22500. * @param meshes defines the list of meshes to scan
  22501. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22502. */
  22503. static MinMax(meshes: AbstractMesh[]): {
  22504. min: Vector3;
  22505. max: Vector3;
  22506. };
  22507. /**
  22508. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22509. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22510. * @returns a vector3
  22511. */
  22512. static Center(meshesOrMinMaxVector: {
  22513. min: Vector3;
  22514. max: Vector3;
  22515. } | AbstractMesh[]): Vector3;
  22516. /**
  22517. * Merge the array of meshes into a single mesh for performance reasons.
  22518. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22519. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22520. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22521. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22522. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22523. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22524. * @returns a new mesh
  22525. */
  22526. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22527. /** @hidden */
  22528. addInstance(instance: InstancedMesh): void;
  22529. /** @hidden */
  22530. removeInstance(instance: InstancedMesh): void;
  22531. }
  22532. }
  22533. declare module "babylonjs/Materials/material" {
  22534. import { IAnimatable } from "babylonjs/Misc/tools";
  22535. import { SmartArray } from "babylonjs/Misc/smartArray";
  22536. import { Observable } from "babylonjs/Misc/observable";
  22537. import { Nullable } from "babylonjs/types";
  22538. import { Scene } from "babylonjs/scene";
  22539. import { Matrix } from "babylonjs/Maths/math";
  22540. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22542. import { Mesh } from "babylonjs/Meshes/mesh";
  22543. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22544. import { Effect } from "babylonjs/Materials/effect";
  22545. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22546. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22547. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22548. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22549. import { Animation } from "babylonjs/Animations/animation";
  22550. /**
  22551. * Base class for the main features of a material in Babylon.js
  22552. */
  22553. export class Material implements IAnimatable {
  22554. /**
  22555. * Returns the triangle fill mode
  22556. */
  22557. static readonly TriangleFillMode: number;
  22558. /**
  22559. * Returns the wireframe mode
  22560. */
  22561. static readonly WireFrameFillMode: number;
  22562. /**
  22563. * Returns the point fill mode
  22564. */
  22565. static readonly PointFillMode: number;
  22566. /**
  22567. * Returns the point list draw mode
  22568. */
  22569. static readonly PointListDrawMode: number;
  22570. /**
  22571. * Returns the line list draw mode
  22572. */
  22573. static readonly LineListDrawMode: number;
  22574. /**
  22575. * Returns the line loop draw mode
  22576. */
  22577. static readonly LineLoopDrawMode: number;
  22578. /**
  22579. * Returns the line strip draw mode
  22580. */
  22581. static readonly LineStripDrawMode: number;
  22582. /**
  22583. * Returns the triangle strip draw mode
  22584. */
  22585. static readonly TriangleStripDrawMode: number;
  22586. /**
  22587. * Returns the triangle fan draw mode
  22588. */
  22589. static readonly TriangleFanDrawMode: number;
  22590. /**
  22591. * Stores the clock-wise side orientation
  22592. */
  22593. static readonly ClockWiseSideOrientation: number;
  22594. /**
  22595. * Stores the counter clock-wise side orientation
  22596. */
  22597. static readonly CounterClockWiseSideOrientation: number;
  22598. /**
  22599. * The dirty texture flag value
  22600. */
  22601. static readonly TextureDirtyFlag: number;
  22602. /**
  22603. * The dirty light flag value
  22604. */
  22605. static readonly LightDirtyFlag: number;
  22606. /**
  22607. * The dirty fresnel flag value
  22608. */
  22609. static readonly FresnelDirtyFlag: number;
  22610. /**
  22611. * The dirty attribute flag value
  22612. */
  22613. static readonly AttributesDirtyFlag: number;
  22614. /**
  22615. * The dirty misc flag value
  22616. */
  22617. static readonly MiscDirtyFlag: number;
  22618. /**
  22619. * The all dirty flag value
  22620. */
  22621. static readonly AllDirtyFlag: number;
  22622. /**
  22623. * The ID of the material
  22624. */
  22625. id: string;
  22626. /**
  22627. * Gets or sets the unique id of the material
  22628. */
  22629. uniqueId: number;
  22630. /**
  22631. * The name of the material
  22632. */
  22633. name: string;
  22634. /**
  22635. * Gets or sets user defined metadata
  22636. */
  22637. metadata: any;
  22638. /**
  22639. * For internal use only. Please do not use.
  22640. */
  22641. reservedDataStore: any;
  22642. /**
  22643. * Specifies if the ready state should be checked on each call
  22644. */
  22645. checkReadyOnEveryCall: boolean;
  22646. /**
  22647. * Specifies if the ready state should be checked once
  22648. */
  22649. checkReadyOnlyOnce: boolean;
  22650. /**
  22651. * The state of the material
  22652. */
  22653. state: string;
  22654. /**
  22655. * The alpha value of the material
  22656. */
  22657. protected _alpha: number;
  22658. /**
  22659. * List of inspectable custom properties (used by the Inspector)
  22660. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22661. */
  22662. inspectableCustomProperties: IInspectable[];
  22663. /**
  22664. * Sets the alpha value of the material
  22665. */
  22666. /**
  22667. * Gets the alpha value of the material
  22668. */
  22669. alpha: number;
  22670. /**
  22671. * Specifies if back face culling is enabled
  22672. */
  22673. protected _backFaceCulling: boolean;
  22674. /**
  22675. * Sets the back-face culling state
  22676. */
  22677. /**
  22678. * Gets the back-face culling state
  22679. */
  22680. backFaceCulling: boolean;
  22681. /**
  22682. * Stores the value for side orientation
  22683. */
  22684. sideOrientation: number;
  22685. /**
  22686. * Callback triggered when the material is compiled
  22687. */
  22688. onCompiled: Nullable<(effect: Effect) => void>;
  22689. /**
  22690. * Callback triggered when an error occurs
  22691. */
  22692. onError: Nullable<(effect: Effect, errors: string) => void>;
  22693. /**
  22694. * Callback triggered to get the render target textures
  22695. */
  22696. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22697. /**
  22698. * Gets a boolean indicating that current material needs to register RTT
  22699. */
  22700. readonly hasRenderTargetTextures: boolean;
  22701. /**
  22702. * Specifies if the material should be serialized
  22703. */
  22704. doNotSerialize: boolean;
  22705. /**
  22706. * @hidden
  22707. */
  22708. _storeEffectOnSubMeshes: boolean;
  22709. /**
  22710. * Stores the animations for the material
  22711. */
  22712. animations: Nullable<Array<Animation>>;
  22713. /**
  22714. * An event triggered when the material is disposed
  22715. */
  22716. onDisposeObservable: Observable<Material>;
  22717. /**
  22718. * An observer which watches for dispose events
  22719. */
  22720. private _onDisposeObserver;
  22721. private _onUnBindObservable;
  22722. /**
  22723. * Called during a dispose event
  22724. */
  22725. onDispose: () => void;
  22726. private _onBindObservable;
  22727. /**
  22728. * An event triggered when the material is bound
  22729. */
  22730. readonly onBindObservable: Observable<AbstractMesh>;
  22731. /**
  22732. * An observer which watches for bind events
  22733. */
  22734. private _onBindObserver;
  22735. /**
  22736. * Called during a bind event
  22737. */
  22738. onBind: (Mesh: AbstractMesh) => void;
  22739. /**
  22740. * An event triggered when the material is unbound
  22741. */
  22742. readonly onUnBindObservable: Observable<Material>;
  22743. /**
  22744. * Stores the value of the alpha mode
  22745. */
  22746. private _alphaMode;
  22747. /**
  22748. * Sets the value of the alpha mode.
  22749. *
  22750. * | Value | Type | Description |
  22751. * | --- | --- | --- |
  22752. * | 0 | ALPHA_DISABLE | |
  22753. * | 1 | ALPHA_ADD | |
  22754. * | 2 | ALPHA_COMBINE | |
  22755. * | 3 | ALPHA_SUBTRACT | |
  22756. * | 4 | ALPHA_MULTIPLY | |
  22757. * | 5 | ALPHA_MAXIMIZED | |
  22758. * | 6 | ALPHA_ONEONE | |
  22759. * | 7 | ALPHA_PREMULTIPLIED | |
  22760. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22761. * | 9 | ALPHA_INTERPOLATE | |
  22762. * | 10 | ALPHA_SCREENMODE | |
  22763. *
  22764. */
  22765. /**
  22766. * Gets the value of the alpha mode
  22767. */
  22768. alphaMode: number;
  22769. /**
  22770. * Stores the state of the need depth pre-pass value
  22771. */
  22772. private _needDepthPrePass;
  22773. /**
  22774. * Sets the need depth pre-pass value
  22775. */
  22776. /**
  22777. * Gets the depth pre-pass value
  22778. */
  22779. needDepthPrePass: boolean;
  22780. /**
  22781. * Specifies if depth writing should be disabled
  22782. */
  22783. disableDepthWrite: boolean;
  22784. /**
  22785. * Specifies if depth writing should be forced
  22786. */
  22787. forceDepthWrite: boolean;
  22788. /**
  22789. * Specifies if there should be a separate pass for culling
  22790. */
  22791. separateCullingPass: boolean;
  22792. /**
  22793. * Stores the state specifing if fog should be enabled
  22794. */
  22795. private _fogEnabled;
  22796. /**
  22797. * Sets the state for enabling fog
  22798. */
  22799. /**
  22800. * Gets the value of the fog enabled state
  22801. */
  22802. fogEnabled: boolean;
  22803. /**
  22804. * Stores the size of points
  22805. */
  22806. pointSize: number;
  22807. /**
  22808. * Stores the z offset value
  22809. */
  22810. zOffset: number;
  22811. /**
  22812. * Gets a value specifying if wireframe mode is enabled
  22813. */
  22814. /**
  22815. * Sets the state of wireframe mode
  22816. */
  22817. wireframe: boolean;
  22818. /**
  22819. * Gets the value specifying if point clouds are enabled
  22820. */
  22821. /**
  22822. * Sets the state of point cloud mode
  22823. */
  22824. pointsCloud: boolean;
  22825. /**
  22826. * Gets the material fill mode
  22827. */
  22828. /**
  22829. * Sets the material fill mode
  22830. */
  22831. fillMode: number;
  22832. /**
  22833. * @hidden
  22834. * Stores the effects for the material
  22835. */
  22836. _effect: Nullable<Effect>;
  22837. /**
  22838. * @hidden
  22839. * Specifies if the material was previously ready
  22840. */
  22841. _wasPreviouslyReady: boolean;
  22842. /**
  22843. * Specifies if uniform buffers should be used
  22844. */
  22845. private _useUBO;
  22846. /**
  22847. * Stores a reference to the scene
  22848. */
  22849. private _scene;
  22850. /**
  22851. * Stores the fill mode state
  22852. */
  22853. private _fillMode;
  22854. /**
  22855. * Specifies if the depth write state should be cached
  22856. */
  22857. private _cachedDepthWriteState;
  22858. /**
  22859. * Stores the uniform buffer
  22860. */
  22861. protected _uniformBuffer: UniformBuffer;
  22862. /** @hidden */
  22863. _indexInSceneMaterialArray: number;
  22864. /** @hidden */
  22865. meshMap: Nullable<{
  22866. [id: string]: AbstractMesh | undefined;
  22867. }>;
  22868. /**
  22869. * Creates a material instance
  22870. * @param name defines the name of the material
  22871. * @param scene defines the scene to reference
  22872. * @param doNotAdd specifies if the material should be added to the scene
  22873. */
  22874. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22875. /**
  22876. * Returns a string representation of the current material
  22877. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22878. * @returns a string with material information
  22879. */
  22880. toString(fullDetails?: boolean): string;
  22881. /**
  22882. * Gets the class name of the material
  22883. * @returns a string with the class name of the material
  22884. */
  22885. getClassName(): string;
  22886. /**
  22887. * Specifies if updates for the material been locked
  22888. */
  22889. readonly isFrozen: boolean;
  22890. /**
  22891. * Locks updates for the material
  22892. */
  22893. freeze(): void;
  22894. /**
  22895. * Unlocks updates for the material
  22896. */
  22897. unfreeze(): void;
  22898. /**
  22899. * Specifies if the material is ready to be used
  22900. * @param mesh defines the mesh to check
  22901. * @param useInstances specifies if instances should be used
  22902. * @returns a boolean indicating if the material is ready to be used
  22903. */
  22904. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22905. /**
  22906. * Specifies that the submesh is ready to be used
  22907. * @param mesh defines the mesh to check
  22908. * @param subMesh defines which submesh to check
  22909. * @param useInstances specifies that instances should be used
  22910. * @returns a boolean indicating that the submesh is ready or not
  22911. */
  22912. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22913. /**
  22914. * Returns the material effect
  22915. * @returns the effect associated with the material
  22916. */
  22917. getEffect(): Nullable<Effect>;
  22918. /**
  22919. * Returns the current scene
  22920. * @returns a Scene
  22921. */
  22922. getScene(): Scene;
  22923. /**
  22924. * Specifies if the material will require alpha blending
  22925. * @returns a boolean specifying if alpha blending is needed
  22926. */
  22927. needAlphaBlending(): boolean;
  22928. /**
  22929. * Specifies if the mesh will require alpha blending
  22930. * @param mesh defines the mesh to check
  22931. * @returns a boolean specifying if alpha blending is needed for the mesh
  22932. */
  22933. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22934. /**
  22935. * Specifies if this material should be rendered in alpha test mode
  22936. * @returns a boolean specifying if an alpha test is needed.
  22937. */
  22938. needAlphaTesting(): boolean;
  22939. /**
  22940. * Gets the texture used for the alpha test
  22941. * @returns the texture to use for alpha testing
  22942. */
  22943. getAlphaTestTexture(): Nullable<BaseTexture>;
  22944. /**
  22945. * Marks the material to indicate that it needs to be re-calculated
  22946. */
  22947. markDirty(): void;
  22948. /** @hidden */
  22949. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22950. /**
  22951. * Binds the material to the mesh
  22952. * @param world defines the world transformation matrix
  22953. * @param mesh defines the mesh to bind the material to
  22954. */
  22955. bind(world: Matrix, mesh?: Mesh): void;
  22956. /**
  22957. * Binds the submesh to the material
  22958. * @param world defines the world transformation matrix
  22959. * @param mesh defines the mesh containing the submesh
  22960. * @param subMesh defines the submesh to bind the material to
  22961. */
  22962. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22963. /**
  22964. * Binds the world matrix to the material
  22965. * @param world defines the world transformation matrix
  22966. */
  22967. bindOnlyWorldMatrix(world: Matrix): void;
  22968. /**
  22969. * Binds the scene's uniform buffer to the effect.
  22970. * @param effect defines the effect to bind to the scene uniform buffer
  22971. * @param sceneUbo defines the uniform buffer storing scene data
  22972. */
  22973. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22974. /**
  22975. * Binds the view matrix to the effect
  22976. * @param effect defines the effect to bind the view matrix to
  22977. */
  22978. bindView(effect: Effect): void;
  22979. /**
  22980. * Binds the view projection matrix to the effect
  22981. * @param effect defines the effect to bind the view projection matrix to
  22982. */
  22983. bindViewProjection(effect: Effect): void;
  22984. /**
  22985. * Specifies if material alpha testing should be turned on for the mesh
  22986. * @param mesh defines the mesh to check
  22987. */
  22988. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22989. /**
  22990. * Processes to execute after binding the material to a mesh
  22991. * @param mesh defines the rendered mesh
  22992. */
  22993. protected _afterBind(mesh?: Mesh): void;
  22994. /**
  22995. * Unbinds the material from the mesh
  22996. */
  22997. unbind(): void;
  22998. /**
  22999. * Gets the active textures from the material
  23000. * @returns an array of textures
  23001. */
  23002. getActiveTextures(): BaseTexture[];
  23003. /**
  23004. * Specifies if the material uses a texture
  23005. * @param texture defines the texture to check against the material
  23006. * @returns a boolean specifying if the material uses the texture
  23007. */
  23008. hasTexture(texture: BaseTexture): boolean;
  23009. /**
  23010. * Makes a duplicate of the material, and gives it a new name
  23011. * @param name defines the new name for the duplicated material
  23012. * @returns the cloned material
  23013. */
  23014. clone(name: string): Nullable<Material>;
  23015. /**
  23016. * Gets the meshes bound to the material
  23017. * @returns an array of meshes bound to the material
  23018. */
  23019. getBindedMeshes(): AbstractMesh[];
  23020. /**
  23021. * Force shader compilation
  23022. * @param mesh defines the mesh associated with this material
  23023. * @param onCompiled defines a function to execute once the material is compiled
  23024. * @param options defines the options to configure the compilation
  23025. */
  23026. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23027. clipPlane: boolean;
  23028. }>): void;
  23029. /**
  23030. * Force shader compilation
  23031. * @param mesh defines the mesh that will use this material
  23032. * @param options defines additional options for compiling the shaders
  23033. * @returns a promise that resolves when the compilation completes
  23034. */
  23035. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23036. clipPlane: boolean;
  23037. }>): Promise<void>;
  23038. private static readonly _ImageProcessingDirtyCallBack;
  23039. private static readonly _TextureDirtyCallBack;
  23040. private static readonly _FresnelDirtyCallBack;
  23041. private static readonly _MiscDirtyCallBack;
  23042. private static readonly _LightsDirtyCallBack;
  23043. private static readonly _AttributeDirtyCallBack;
  23044. private static _FresnelAndMiscDirtyCallBack;
  23045. private static _TextureAndMiscDirtyCallBack;
  23046. private static readonly _DirtyCallbackArray;
  23047. private static readonly _RunDirtyCallBacks;
  23048. /**
  23049. * Marks a define in the material to indicate that it needs to be re-computed
  23050. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23051. */
  23052. markAsDirty(flag: number): void;
  23053. /**
  23054. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23055. * @param func defines a function which checks material defines against the submeshes
  23056. */
  23057. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23058. /**
  23059. * Indicates that image processing needs to be re-calculated for all submeshes
  23060. */
  23061. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23062. /**
  23063. * Indicates that textures need to be re-calculated for all submeshes
  23064. */
  23065. protected _markAllSubMeshesAsTexturesDirty(): void;
  23066. /**
  23067. * Indicates that fresnel needs to be re-calculated for all submeshes
  23068. */
  23069. protected _markAllSubMeshesAsFresnelDirty(): void;
  23070. /**
  23071. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23072. */
  23073. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23074. /**
  23075. * Indicates that lights need to be re-calculated for all submeshes
  23076. */
  23077. protected _markAllSubMeshesAsLightsDirty(): void;
  23078. /**
  23079. * Indicates that attributes need to be re-calculated for all submeshes
  23080. */
  23081. protected _markAllSubMeshesAsAttributesDirty(): void;
  23082. /**
  23083. * Indicates that misc needs to be re-calculated for all submeshes
  23084. */
  23085. protected _markAllSubMeshesAsMiscDirty(): void;
  23086. /**
  23087. * Indicates that textures and misc need to be re-calculated for all submeshes
  23088. */
  23089. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23090. /**
  23091. * Disposes the material
  23092. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23093. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23094. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23095. */
  23096. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23097. /** @hidden */
  23098. private releaseVertexArrayObject;
  23099. /**
  23100. * Serializes this material
  23101. * @returns the serialized material object
  23102. */
  23103. serialize(): any;
  23104. /**
  23105. * Creates a material from parsed material data
  23106. * @param parsedMaterial defines parsed material data
  23107. * @param scene defines the hosting scene
  23108. * @param rootUrl defines the root URL to use to load textures
  23109. * @returns a new material
  23110. */
  23111. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23112. }
  23113. }
  23114. declare module "babylonjs/Meshes/subMesh" {
  23115. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23116. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23117. import { Engine } from "babylonjs/Engines/engine";
  23118. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23119. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23120. import { Effect } from "babylonjs/Materials/effect";
  23121. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23122. import { Collider } from "babylonjs/Collisions/collider";
  23123. import { Material } from "babylonjs/Materials/material";
  23124. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23126. import { Mesh } from "babylonjs/Meshes/mesh";
  23127. import { Ray } from "babylonjs/Culling/ray";
  23128. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23129. /**
  23130. * Base class for submeshes
  23131. */
  23132. export class BaseSubMesh {
  23133. /** @hidden */
  23134. _materialDefines: Nullable<MaterialDefines>;
  23135. /** @hidden */
  23136. _materialEffect: Nullable<Effect>;
  23137. /**
  23138. * Gets associated effect
  23139. */
  23140. readonly effect: Nullable<Effect>;
  23141. /**
  23142. * Sets associated effect (effect used to render this submesh)
  23143. * @param effect defines the effect to associate with
  23144. * @param defines defines the set of defines used to compile this effect
  23145. */
  23146. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23147. }
  23148. /**
  23149. * Defines a subdivision inside a mesh
  23150. */
  23151. export class SubMesh extends BaseSubMesh implements ICullable {
  23152. /** the material index to use */
  23153. materialIndex: number;
  23154. /** vertex index start */
  23155. verticesStart: number;
  23156. /** vertices count */
  23157. verticesCount: number;
  23158. /** index start */
  23159. indexStart: number;
  23160. /** indices count */
  23161. indexCount: number;
  23162. /** @hidden */
  23163. _linesIndexCount: number;
  23164. private _mesh;
  23165. private _renderingMesh;
  23166. private _boundingInfo;
  23167. private _linesIndexBuffer;
  23168. /** @hidden */
  23169. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23170. /** @hidden */
  23171. _trianglePlanes: Plane[];
  23172. /** @hidden */
  23173. _lastColliderTransformMatrix: Nullable<Matrix>;
  23174. /** @hidden */
  23175. _renderId: number;
  23176. /** @hidden */
  23177. _alphaIndex: number;
  23178. /** @hidden */
  23179. _distanceToCamera: number;
  23180. /** @hidden */
  23181. _id: number;
  23182. private _currentMaterial;
  23183. /**
  23184. * Add a new submesh to a mesh
  23185. * @param materialIndex defines the material index to use
  23186. * @param verticesStart defines vertex index start
  23187. * @param verticesCount defines vertices count
  23188. * @param indexStart defines index start
  23189. * @param indexCount defines indices count
  23190. * @param mesh defines the parent mesh
  23191. * @param renderingMesh defines an optional rendering mesh
  23192. * @param createBoundingBox defines if bounding box should be created for this submesh
  23193. * @returns the new submesh
  23194. */
  23195. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23196. /**
  23197. * Creates a new submesh
  23198. * @param materialIndex defines the material index to use
  23199. * @param verticesStart defines vertex index start
  23200. * @param verticesCount defines vertices count
  23201. * @param indexStart defines index start
  23202. * @param indexCount defines indices count
  23203. * @param mesh defines the parent mesh
  23204. * @param renderingMesh defines an optional rendering mesh
  23205. * @param createBoundingBox defines if bounding box should be created for this submesh
  23206. */
  23207. constructor(
  23208. /** the material index to use */
  23209. materialIndex: number,
  23210. /** vertex index start */
  23211. verticesStart: number,
  23212. /** vertices count */
  23213. verticesCount: number,
  23214. /** index start */
  23215. indexStart: number,
  23216. /** indices count */
  23217. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23218. /**
  23219. * Returns true if this submesh covers the entire parent mesh
  23220. * @ignorenaming
  23221. */
  23222. readonly IsGlobal: boolean;
  23223. /**
  23224. * Returns the submesh BoudingInfo object
  23225. * @returns current bounding info (or mesh's one if the submesh is global)
  23226. */
  23227. getBoundingInfo(): BoundingInfo;
  23228. /**
  23229. * Sets the submesh BoundingInfo
  23230. * @param boundingInfo defines the new bounding info to use
  23231. * @returns the SubMesh
  23232. */
  23233. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23234. /**
  23235. * Returns the mesh of the current submesh
  23236. * @return the parent mesh
  23237. */
  23238. getMesh(): AbstractMesh;
  23239. /**
  23240. * Returns the rendering mesh of the submesh
  23241. * @returns the rendering mesh (could be different from parent mesh)
  23242. */
  23243. getRenderingMesh(): Mesh;
  23244. /**
  23245. * Returns the submesh material
  23246. * @returns null or the current material
  23247. */
  23248. getMaterial(): Nullable<Material>;
  23249. /**
  23250. * Sets a new updated BoundingInfo object to the submesh
  23251. * @param data defines an optional position array to use to determine the bounding info
  23252. * @returns the SubMesh
  23253. */
  23254. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23255. /** @hidden */
  23256. _checkCollision(collider: Collider): boolean;
  23257. /**
  23258. * Updates the submesh BoundingInfo
  23259. * @param world defines the world matrix to use to update the bounding info
  23260. * @returns the submesh
  23261. */
  23262. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23263. /**
  23264. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23265. * @param frustumPlanes defines the frustum planes
  23266. * @returns true if the submesh is intersecting with the frustum
  23267. */
  23268. isInFrustum(frustumPlanes: Plane[]): boolean;
  23269. /**
  23270. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23271. * @param frustumPlanes defines the frustum planes
  23272. * @returns true if the submesh is inside the frustum
  23273. */
  23274. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23275. /**
  23276. * Renders the submesh
  23277. * @param enableAlphaMode defines if alpha needs to be used
  23278. * @returns the submesh
  23279. */
  23280. render(enableAlphaMode: boolean): SubMesh;
  23281. /**
  23282. * @hidden
  23283. */
  23284. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23285. /**
  23286. * Checks if the submesh intersects with a ray
  23287. * @param ray defines the ray to test
  23288. * @returns true is the passed ray intersects the submesh bounding box
  23289. */
  23290. canIntersects(ray: Ray): boolean;
  23291. /**
  23292. * Intersects current submesh with a ray
  23293. * @param ray defines the ray to test
  23294. * @param positions defines mesh's positions array
  23295. * @param indices defines mesh's indices array
  23296. * @param fastCheck defines if only bounding info should be used
  23297. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23298. * @returns intersection info or null if no intersection
  23299. */
  23300. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23301. /** @hidden */
  23302. private _intersectLines;
  23303. /** @hidden */
  23304. private _intersectTriangles;
  23305. /** @hidden */
  23306. private _intersectUnIndexedTriangles;
  23307. /** @hidden */
  23308. _rebuild(): void;
  23309. /**
  23310. * Creates a new submesh from the passed mesh
  23311. * @param newMesh defines the new hosting mesh
  23312. * @param newRenderingMesh defines an optional rendering mesh
  23313. * @returns the new submesh
  23314. */
  23315. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23316. /**
  23317. * Release associated resources
  23318. */
  23319. dispose(): void;
  23320. /**
  23321. * Gets the class name
  23322. * @returns the string "SubMesh".
  23323. */
  23324. getClassName(): string;
  23325. /**
  23326. * Creates a new submesh from indices data
  23327. * @param materialIndex the index of the main mesh material
  23328. * @param startIndex the index where to start the copy in the mesh indices array
  23329. * @param indexCount the number of indices to copy then from the startIndex
  23330. * @param mesh the main mesh to create the submesh from
  23331. * @param renderingMesh the optional rendering mesh
  23332. * @returns a new submesh
  23333. */
  23334. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23335. }
  23336. }
  23337. declare module "babylonjs/Meshes/geometry" {
  23338. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23339. import { Scene } from "babylonjs/scene";
  23340. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23341. import { Engine } from "babylonjs/Engines/engine";
  23342. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23343. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23344. import { Effect } from "babylonjs/Materials/effect";
  23345. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23346. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23347. import { Mesh } from "babylonjs/Meshes/mesh";
  23348. /**
  23349. * Class used to store geometry data (vertex buffers + index buffer)
  23350. */
  23351. export class Geometry implements IGetSetVerticesData {
  23352. /**
  23353. * Gets or sets the ID of the geometry
  23354. */
  23355. id: string;
  23356. /**
  23357. * Gets or sets the unique ID of the geometry
  23358. */
  23359. uniqueId: number;
  23360. /**
  23361. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23362. */
  23363. delayLoadState: number;
  23364. /**
  23365. * Gets the file containing the data to load when running in delay load state
  23366. */
  23367. delayLoadingFile: Nullable<string>;
  23368. /**
  23369. * Callback called when the geometry is updated
  23370. */
  23371. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23372. private _scene;
  23373. private _engine;
  23374. private _meshes;
  23375. private _totalVertices;
  23376. /** @hidden */
  23377. _indices: IndicesArray;
  23378. /** @hidden */
  23379. _vertexBuffers: {
  23380. [key: string]: VertexBuffer;
  23381. };
  23382. private _isDisposed;
  23383. private _extend;
  23384. private _boundingBias;
  23385. /** @hidden */
  23386. _delayInfo: Array<string>;
  23387. private _indexBuffer;
  23388. private _indexBufferIsUpdatable;
  23389. /** @hidden */
  23390. _boundingInfo: Nullable<BoundingInfo>;
  23391. /** @hidden */
  23392. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23393. /** @hidden */
  23394. _softwareSkinningFrameId: number;
  23395. private _vertexArrayObjects;
  23396. private _updatable;
  23397. /** @hidden */
  23398. _positions: Nullable<Vector3[]>;
  23399. /**
  23400. * 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
  23401. */
  23402. /**
  23403. * 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
  23404. */
  23405. boundingBias: Vector2;
  23406. /**
  23407. * Static function used to attach a new empty geometry to a mesh
  23408. * @param mesh defines the mesh to attach the geometry to
  23409. * @returns the new Geometry
  23410. */
  23411. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23412. /**
  23413. * Creates a new geometry
  23414. * @param id defines the unique ID
  23415. * @param scene defines the hosting scene
  23416. * @param vertexData defines the VertexData used to get geometry data
  23417. * @param updatable defines if geometry must be updatable (false by default)
  23418. * @param mesh defines the mesh that will be associated with the geometry
  23419. */
  23420. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23421. /**
  23422. * Gets the current extend of the geometry
  23423. */
  23424. readonly extend: {
  23425. minimum: Vector3;
  23426. maximum: Vector3;
  23427. };
  23428. /**
  23429. * Gets the hosting scene
  23430. * @returns the hosting Scene
  23431. */
  23432. getScene(): Scene;
  23433. /**
  23434. * Gets the hosting engine
  23435. * @returns the hosting Engine
  23436. */
  23437. getEngine(): Engine;
  23438. /**
  23439. * Defines if the geometry is ready to use
  23440. * @returns true if the geometry is ready to be used
  23441. */
  23442. isReady(): boolean;
  23443. /**
  23444. * Gets a value indicating that the geometry should not be serialized
  23445. */
  23446. readonly doNotSerialize: boolean;
  23447. /** @hidden */
  23448. _rebuild(): void;
  23449. /**
  23450. * Affects all geometry data in one call
  23451. * @param vertexData defines the geometry data
  23452. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23453. */
  23454. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23455. /**
  23456. * Set specific vertex data
  23457. * @param kind defines the data kind (Position, normal, etc...)
  23458. * @param data defines the vertex data to use
  23459. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23460. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23461. */
  23462. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23463. /**
  23464. * Removes a specific vertex data
  23465. * @param kind defines the data kind (Position, normal, etc...)
  23466. */
  23467. removeVerticesData(kind: string): void;
  23468. /**
  23469. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23470. * @param buffer defines the vertex buffer to use
  23471. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23472. */
  23473. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23474. /**
  23475. * Update a specific vertex buffer
  23476. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23477. * It will do nothing if the buffer is not updatable
  23478. * @param kind defines the data kind (Position, normal, etc...)
  23479. * @param data defines the data to use
  23480. * @param offset defines the offset in the target buffer where to store the data
  23481. * @param useBytes set to true if the offset is in bytes
  23482. */
  23483. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23484. /**
  23485. * Update a specific vertex buffer
  23486. * This function will create a new buffer if the current one is not updatable
  23487. * @param kind defines the data kind (Position, normal, etc...)
  23488. * @param data defines the data to use
  23489. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23490. */
  23491. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23492. private _updateBoundingInfo;
  23493. /** @hidden */
  23494. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23495. /**
  23496. * Gets total number of vertices
  23497. * @returns the total number of vertices
  23498. */
  23499. getTotalVertices(): number;
  23500. /**
  23501. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23502. * @param kind defines the data kind (Position, normal, etc...)
  23503. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23504. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23505. * @returns a float array containing vertex data
  23506. */
  23507. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23508. /**
  23509. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23510. * @param kind defines the data kind (Position, normal, etc...)
  23511. * @returns true if the vertex buffer with the specified kind is updatable
  23512. */
  23513. isVertexBufferUpdatable(kind: string): boolean;
  23514. /**
  23515. * Gets a specific vertex buffer
  23516. * @param kind defines the data kind (Position, normal, etc...)
  23517. * @returns a VertexBuffer
  23518. */
  23519. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23520. /**
  23521. * Returns all vertex buffers
  23522. * @return an object holding all vertex buffers indexed by kind
  23523. */
  23524. getVertexBuffers(): Nullable<{
  23525. [key: string]: VertexBuffer;
  23526. }>;
  23527. /**
  23528. * Gets a boolean indicating if specific vertex buffer is present
  23529. * @param kind defines the data kind (Position, normal, etc...)
  23530. * @returns true if data is present
  23531. */
  23532. isVerticesDataPresent(kind: string): boolean;
  23533. /**
  23534. * Gets a list of all attached data kinds (Position, normal, etc...)
  23535. * @returns a list of string containing all kinds
  23536. */
  23537. getVerticesDataKinds(): string[];
  23538. /**
  23539. * Update index buffer
  23540. * @param indices defines the indices to store in the index buffer
  23541. * @param offset defines the offset in the target buffer where to store the data
  23542. * @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)
  23543. */
  23544. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23545. /**
  23546. * Creates a new index buffer
  23547. * @param indices defines the indices to store in the index buffer
  23548. * @param totalVertices defines the total number of vertices (could be null)
  23549. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23550. */
  23551. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23552. /**
  23553. * Return the total number of indices
  23554. * @returns the total number of indices
  23555. */
  23556. getTotalIndices(): number;
  23557. /**
  23558. * Gets the index buffer array
  23559. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23560. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23561. * @returns the index buffer array
  23562. */
  23563. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23564. /**
  23565. * Gets the index buffer
  23566. * @return the index buffer
  23567. */
  23568. getIndexBuffer(): Nullable<DataBuffer>;
  23569. /** @hidden */
  23570. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23571. /**
  23572. * Release the associated resources for a specific mesh
  23573. * @param mesh defines the source mesh
  23574. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23575. */
  23576. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23577. /**
  23578. * Apply current geometry to a given mesh
  23579. * @param mesh defines the mesh to apply geometry to
  23580. */
  23581. applyToMesh(mesh: Mesh): void;
  23582. private _updateExtend;
  23583. private _applyToMesh;
  23584. private notifyUpdate;
  23585. /**
  23586. * Load the geometry if it was flagged as delay loaded
  23587. * @param scene defines the hosting scene
  23588. * @param onLoaded defines a callback called when the geometry is loaded
  23589. */
  23590. load(scene: Scene, onLoaded?: () => void): void;
  23591. private _queueLoad;
  23592. /**
  23593. * Invert the geometry to move from a right handed system to a left handed one.
  23594. */
  23595. toLeftHanded(): void;
  23596. /** @hidden */
  23597. _resetPointsArrayCache(): void;
  23598. /** @hidden */
  23599. _generatePointsArray(): boolean;
  23600. /**
  23601. * Gets a value indicating if the geometry is disposed
  23602. * @returns true if the geometry was disposed
  23603. */
  23604. isDisposed(): boolean;
  23605. private _disposeVertexArrayObjects;
  23606. /**
  23607. * Free all associated resources
  23608. */
  23609. dispose(): void;
  23610. /**
  23611. * Clone the current geometry into a new geometry
  23612. * @param id defines the unique ID of the new geometry
  23613. * @returns a new geometry object
  23614. */
  23615. copy(id: string): Geometry;
  23616. /**
  23617. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23618. * @return a JSON representation of the current geometry data (without the vertices data)
  23619. */
  23620. serialize(): any;
  23621. private toNumberArray;
  23622. /**
  23623. * Serialize all vertices data into a JSON oject
  23624. * @returns a JSON representation of the current geometry data
  23625. */
  23626. serializeVerticeData(): any;
  23627. /**
  23628. * Extracts a clone of a mesh geometry
  23629. * @param mesh defines the source mesh
  23630. * @param id defines the unique ID of the new geometry object
  23631. * @returns the new geometry object
  23632. */
  23633. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23634. /**
  23635. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23636. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23637. * Be aware Math.random() could cause collisions, but:
  23638. * "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"
  23639. * @returns a string containing a new GUID
  23640. */
  23641. static RandomId(): string;
  23642. /** @hidden */
  23643. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23644. private static _CleanMatricesWeights;
  23645. /**
  23646. * Create a new geometry from persisted data (Using .babylon file format)
  23647. * @param parsedVertexData defines the persisted data
  23648. * @param scene defines the hosting scene
  23649. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23650. * @returns the new geometry object
  23651. */
  23652. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23653. }
  23654. }
  23655. declare module "babylonjs/Meshes/mesh.vertexData" {
  23656. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23657. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23658. import { Geometry } from "babylonjs/Meshes/geometry";
  23659. import { Mesh } from "babylonjs/Meshes/mesh";
  23660. /**
  23661. * Define an interface for all classes that will get and set the data on vertices
  23662. */
  23663. export interface IGetSetVerticesData {
  23664. /**
  23665. * Gets a boolean indicating if specific vertex data is present
  23666. * @param kind defines the vertex data kind to use
  23667. * @returns true is data kind is present
  23668. */
  23669. isVerticesDataPresent(kind: string): boolean;
  23670. /**
  23671. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23672. * @param kind defines the data kind (Position, normal, etc...)
  23673. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23674. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23675. * @returns a float array containing vertex data
  23676. */
  23677. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23678. /**
  23679. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23680. * @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.
  23681. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23682. * @returns the indices array or an empty array if the mesh has no geometry
  23683. */
  23684. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23685. /**
  23686. * Set specific vertex data
  23687. * @param kind defines the data kind (Position, normal, etc...)
  23688. * @param data defines the vertex data to use
  23689. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23690. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23691. */
  23692. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23693. /**
  23694. * Update a specific associated vertex buffer
  23695. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23696. * - VertexBuffer.PositionKind
  23697. * - VertexBuffer.UVKind
  23698. * - VertexBuffer.UV2Kind
  23699. * - VertexBuffer.UV3Kind
  23700. * - VertexBuffer.UV4Kind
  23701. * - VertexBuffer.UV5Kind
  23702. * - VertexBuffer.UV6Kind
  23703. * - VertexBuffer.ColorKind
  23704. * - VertexBuffer.MatricesIndicesKind
  23705. * - VertexBuffer.MatricesIndicesExtraKind
  23706. * - VertexBuffer.MatricesWeightsKind
  23707. * - VertexBuffer.MatricesWeightsExtraKind
  23708. * @param data defines the data source
  23709. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23710. * @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)
  23711. */
  23712. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23713. /**
  23714. * Creates a new index buffer
  23715. * @param indices defines the indices to store in the index buffer
  23716. * @param totalVertices defines the total number of vertices (could be null)
  23717. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23718. */
  23719. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23720. }
  23721. /**
  23722. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23723. */
  23724. export class VertexData {
  23725. /**
  23726. * Mesh side orientation : usually the external or front surface
  23727. */
  23728. static readonly FRONTSIDE: number;
  23729. /**
  23730. * Mesh side orientation : usually the internal or back surface
  23731. */
  23732. static readonly BACKSIDE: number;
  23733. /**
  23734. * Mesh side orientation : both internal and external or front and back surfaces
  23735. */
  23736. static readonly DOUBLESIDE: number;
  23737. /**
  23738. * Mesh side orientation : by default, `FRONTSIDE`
  23739. */
  23740. static readonly DEFAULTSIDE: number;
  23741. /**
  23742. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23743. */
  23744. positions: Nullable<FloatArray>;
  23745. /**
  23746. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23747. */
  23748. normals: Nullable<FloatArray>;
  23749. /**
  23750. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23751. */
  23752. tangents: Nullable<FloatArray>;
  23753. /**
  23754. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23755. */
  23756. uvs: Nullable<FloatArray>;
  23757. /**
  23758. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23759. */
  23760. uvs2: Nullable<FloatArray>;
  23761. /**
  23762. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23763. */
  23764. uvs3: Nullable<FloatArray>;
  23765. /**
  23766. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23767. */
  23768. uvs4: Nullable<FloatArray>;
  23769. /**
  23770. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23771. */
  23772. uvs5: Nullable<FloatArray>;
  23773. /**
  23774. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23775. */
  23776. uvs6: Nullable<FloatArray>;
  23777. /**
  23778. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23779. */
  23780. colors: Nullable<FloatArray>;
  23781. /**
  23782. * 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).
  23783. */
  23784. matricesIndices: Nullable<FloatArray>;
  23785. /**
  23786. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23787. */
  23788. matricesWeights: Nullable<FloatArray>;
  23789. /**
  23790. * An array extending the number of possible indices
  23791. */
  23792. matricesIndicesExtra: Nullable<FloatArray>;
  23793. /**
  23794. * An array extending the number of possible weights when the number of indices is extended
  23795. */
  23796. matricesWeightsExtra: Nullable<FloatArray>;
  23797. /**
  23798. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23799. */
  23800. indices: Nullable<IndicesArray>;
  23801. /**
  23802. * Uses the passed data array to set the set the values for the specified kind of data
  23803. * @param data a linear array of floating numbers
  23804. * @param kind the type of data that is being set, eg positions, colors etc
  23805. */
  23806. set(data: FloatArray, kind: string): void;
  23807. /**
  23808. * Associates the vertexData to the passed Mesh.
  23809. * Sets it as updatable or not (default `false`)
  23810. * @param mesh the mesh the vertexData is applied to
  23811. * @param updatable when used and having the value true allows new data to update the vertexData
  23812. * @returns the VertexData
  23813. */
  23814. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23815. /**
  23816. * Associates the vertexData to the passed Geometry.
  23817. * Sets it as updatable or not (default `false`)
  23818. * @param geometry the geometry the vertexData is applied to
  23819. * @param updatable when used and having the value true allows new data to update the vertexData
  23820. * @returns VertexData
  23821. */
  23822. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23823. /**
  23824. * Updates the associated mesh
  23825. * @param mesh the mesh to be updated
  23826. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23827. * @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
  23828. * @returns VertexData
  23829. */
  23830. updateMesh(mesh: Mesh): VertexData;
  23831. /**
  23832. * Updates the associated geometry
  23833. * @param geometry the geometry to be updated
  23834. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23835. * @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
  23836. * @returns VertexData.
  23837. */
  23838. updateGeometry(geometry: Geometry): VertexData;
  23839. private _applyTo;
  23840. private _update;
  23841. /**
  23842. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23843. * @param matrix the transforming matrix
  23844. * @returns the VertexData
  23845. */
  23846. transform(matrix: Matrix): VertexData;
  23847. /**
  23848. * Merges the passed VertexData into the current one
  23849. * @param other the VertexData to be merged into the current one
  23850. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23851. * @returns the modified VertexData
  23852. */
  23853. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23854. private _mergeElement;
  23855. private _validate;
  23856. /**
  23857. * Serializes the VertexData
  23858. * @returns a serialized object
  23859. */
  23860. serialize(): any;
  23861. /**
  23862. * Extracts the vertexData from a mesh
  23863. * @param mesh the mesh from which to extract the VertexData
  23864. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23865. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23866. * @returns the object VertexData associated to the passed mesh
  23867. */
  23868. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23869. /**
  23870. * Extracts the vertexData from the geometry
  23871. * @param geometry the geometry from which to extract the VertexData
  23872. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23873. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23874. * @returns the object VertexData associated to the passed mesh
  23875. */
  23876. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23877. private static _ExtractFrom;
  23878. /**
  23879. * Creates the VertexData for a Ribbon
  23880. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23881. * * pathArray array of paths, each of which an array of successive Vector3
  23882. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23883. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23884. * * 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
  23885. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23886. * * 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)
  23887. * * 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)
  23888. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23889. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23890. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23891. * @returns the VertexData of the ribbon
  23892. */
  23893. static CreateRibbon(options: {
  23894. pathArray: Vector3[][];
  23895. closeArray?: boolean;
  23896. closePath?: boolean;
  23897. offset?: number;
  23898. sideOrientation?: number;
  23899. frontUVs?: Vector4;
  23900. backUVs?: Vector4;
  23901. invertUV?: boolean;
  23902. uvs?: Vector2[];
  23903. colors?: Color4[];
  23904. }): VertexData;
  23905. /**
  23906. * Creates the VertexData for a box
  23907. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23908. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23909. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23910. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23911. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23912. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23913. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23915. * * 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)
  23916. * * 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)
  23917. * @returns the VertexData of the box
  23918. */
  23919. static CreateBox(options: {
  23920. size?: number;
  23921. width?: number;
  23922. height?: number;
  23923. depth?: number;
  23924. faceUV?: Vector4[];
  23925. faceColors?: Color4[];
  23926. sideOrientation?: number;
  23927. frontUVs?: Vector4;
  23928. backUVs?: Vector4;
  23929. }): VertexData;
  23930. /**
  23931. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23932. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23933. * * segments sets the number of horizontal strips optional, default 32
  23934. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23935. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23936. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23937. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23938. * * 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
  23939. * * 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
  23940. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23941. * * 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)
  23942. * * 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)
  23943. * @returns the VertexData of the ellipsoid
  23944. */
  23945. static CreateSphere(options: {
  23946. segments?: number;
  23947. diameter?: number;
  23948. diameterX?: number;
  23949. diameterY?: number;
  23950. diameterZ?: number;
  23951. arc?: number;
  23952. slice?: number;
  23953. sideOrientation?: number;
  23954. frontUVs?: Vector4;
  23955. backUVs?: Vector4;
  23956. }): VertexData;
  23957. /**
  23958. * Creates the VertexData for a cylinder, cone or prism
  23959. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23960. * * height sets the height (y direction) of the cylinder, optional, default 2
  23961. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23962. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23963. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23964. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23965. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23966. * * 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
  23967. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23968. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23969. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23970. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23971. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23972. * * 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)
  23973. * * 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)
  23974. * @returns the VertexData of the cylinder, cone or prism
  23975. */
  23976. static CreateCylinder(options: {
  23977. height?: number;
  23978. diameterTop?: number;
  23979. diameterBottom?: number;
  23980. diameter?: number;
  23981. tessellation?: number;
  23982. subdivisions?: number;
  23983. arc?: number;
  23984. faceColors?: Color4[];
  23985. faceUV?: Vector4[];
  23986. hasRings?: boolean;
  23987. enclose?: boolean;
  23988. sideOrientation?: number;
  23989. frontUVs?: Vector4;
  23990. backUVs?: Vector4;
  23991. }): VertexData;
  23992. /**
  23993. * Creates the VertexData for a torus
  23994. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23995. * * diameter the diameter of the torus, optional default 1
  23996. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23997. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23998. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23999. * * 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)
  24000. * * 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)
  24001. * @returns the VertexData of the torus
  24002. */
  24003. static CreateTorus(options: {
  24004. diameter?: number;
  24005. thickness?: number;
  24006. tessellation?: number;
  24007. sideOrientation?: number;
  24008. frontUVs?: Vector4;
  24009. backUVs?: Vector4;
  24010. }): VertexData;
  24011. /**
  24012. * Creates the VertexData of the LineSystem
  24013. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24014. * - lines an array of lines, each line being an array of successive Vector3
  24015. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24016. * @returns the VertexData of the LineSystem
  24017. */
  24018. static CreateLineSystem(options: {
  24019. lines: Vector3[][];
  24020. colors?: Nullable<Color4[][]>;
  24021. }): VertexData;
  24022. /**
  24023. * Create the VertexData for a DashedLines
  24024. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24025. * - points an array successive Vector3
  24026. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24027. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24028. * - dashNb the intended total number of dashes, optional, default 200
  24029. * @returns the VertexData for the DashedLines
  24030. */
  24031. static CreateDashedLines(options: {
  24032. points: Vector3[];
  24033. dashSize?: number;
  24034. gapSize?: number;
  24035. dashNb?: number;
  24036. }): VertexData;
  24037. /**
  24038. * Creates the VertexData for a Ground
  24039. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24040. * - width the width (x direction) of the ground, optional, default 1
  24041. * - height the height (z direction) of the ground, optional, default 1
  24042. * - subdivisions the number of subdivisions per side, optional, default 1
  24043. * @returns the VertexData of the Ground
  24044. */
  24045. static CreateGround(options: {
  24046. width?: number;
  24047. height?: number;
  24048. subdivisions?: number;
  24049. subdivisionsX?: number;
  24050. subdivisionsY?: number;
  24051. }): VertexData;
  24052. /**
  24053. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24054. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24055. * * xmin the ground minimum X coordinate, optional, default -1
  24056. * * zmin the ground minimum Z coordinate, optional, default -1
  24057. * * xmax the ground maximum X coordinate, optional, default 1
  24058. * * zmax the ground maximum Z coordinate, optional, default 1
  24059. * * 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}
  24060. * * 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}
  24061. * @returns the VertexData of the TiledGround
  24062. */
  24063. static CreateTiledGround(options: {
  24064. xmin: number;
  24065. zmin: number;
  24066. xmax: number;
  24067. zmax: number;
  24068. subdivisions?: {
  24069. w: number;
  24070. h: number;
  24071. };
  24072. precision?: {
  24073. w: number;
  24074. h: number;
  24075. };
  24076. }): VertexData;
  24077. /**
  24078. * Creates the VertexData of the Ground designed from a heightmap
  24079. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24080. * * width the width (x direction) of the ground
  24081. * * height the height (z direction) of the ground
  24082. * * subdivisions the number of subdivisions per side
  24083. * * minHeight the minimum altitude on the ground, optional, default 0
  24084. * * maxHeight the maximum altitude on the ground, optional default 1
  24085. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24086. * * buffer the array holding the image color data
  24087. * * bufferWidth the width of image
  24088. * * bufferHeight the height of image
  24089. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24090. * @returns the VertexData of the Ground designed from a heightmap
  24091. */
  24092. static CreateGroundFromHeightMap(options: {
  24093. width: number;
  24094. height: number;
  24095. subdivisions: number;
  24096. minHeight: number;
  24097. maxHeight: number;
  24098. colorFilter: Color3;
  24099. buffer: Uint8Array;
  24100. bufferWidth: number;
  24101. bufferHeight: number;
  24102. alphaFilter: number;
  24103. }): VertexData;
  24104. /**
  24105. * Creates the VertexData for a Plane
  24106. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24107. * * size sets the width and height of the plane to the value of size, optional default 1
  24108. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24109. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24111. * * 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)
  24112. * * 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)
  24113. * @returns the VertexData of the box
  24114. */
  24115. static CreatePlane(options: {
  24116. size?: number;
  24117. width?: number;
  24118. height?: number;
  24119. sideOrientation?: number;
  24120. frontUVs?: Vector4;
  24121. backUVs?: Vector4;
  24122. }): VertexData;
  24123. /**
  24124. * Creates the VertexData of the Disc or regular Polygon
  24125. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24126. * * radius the radius of the disc, optional default 0.5
  24127. * * tessellation the number of polygon sides, optional, default 64
  24128. * * 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
  24129. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24130. * * 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)
  24131. * * 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)
  24132. * @returns the VertexData of the box
  24133. */
  24134. static CreateDisc(options: {
  24135. radius?: number;
  24136. tessellation?: number;
  24137. arc?: number;
  24138. sideOrientation?: number;
  24139. frontUVs?: Vector4;
  24140. backUVs?: Vector4;
  24141. }): VertexData;
  24142. /**
  24143. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24144. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24145. * @param polygon a mesh built from polygonTriangulation.build()
  24146. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24147. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24148. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24149. * @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)
  24150. * @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)
  24151. * @returns the VertexData of the Polygon
  24152. */
  24153. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24154. /**
  24155. * Creates the VertexData of the IcoSphere
  24156. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24157. * * radius the radius of the IcoSphere, optional default 1
  24158. * * radiusX allows stretching in the x direction, optional, default radius
  24159. * * radiusY allows stretching in the y direction, optional, default radius
  24160. * * radiusZ allows stretching in the z direction, optional, default radius
  24161. * * flat when true creates a flat shaded mesh, optional, default true
  24162. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24164. * * 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)
  24165. * * 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)
  24166. * @returns the VertexData of the IcoSphere
  24167. */
  24168. static CreateIcoSphere(options: {
  24169. radius?: number;
  24170. radiusX?: number;
  24171. radiusY?: number;
  24172. radiusZ?: number;
  24173. flat?: boolean;
  24174. subdivisions?: number;
  24175. sideOrientation?: number;
  24176. frontUVs?: Vector4;
  24177. backUVs?: Vector4;
  24178. }): VertexData;
  24179. /**
  24180. * Creates the VertexData for a Polyhedron
  24181. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24182. * * type provided types are:
  24183. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24184. * * 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)
  24185. * * size the size of the IcoSphere, optional default 1
  24186. * * sizeX allows stretching in the x direction, optional, default size
  24187. * * sizeY allows stretching in the y direction, optional, default size
  24188. * * sizeZ allows stretching in the z direction, optional, default size
  24189. * * 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
  24190. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24191. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24192. * * flat when true creates a flat shaded mesh, optional, default true
  24193. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24194. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24195. * * 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)
  24196. * * 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)
  24197. * @returns the VertexData of the Polyhedron
  24198. */
  24199. static CreatePolyhedron(options: {
  24200. type?: number;
  24201. size?: number;
  24202. sizeX?: number;
  24203. sizeY?: number;
  24204. sizeZ?: number;
  24205. custom?: any;
  24206. faceUV?: Vector4[];
  24207. faceColors?: Color4[];
  24208. flat?: boolean;
  24209. sideOrientation?: number;
  24210. frontUVs?: Vector4;
  24211. backUVs?: Vector4;
  24212. }): VertexData;
  24213. /**
  24214. * Creates the VertexData for a TorusKnot
  24215. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24216. * * radius the radius of the torus knot, optional, default 2
  24217. * * tube the thickness of the tube, optional, default 0.5
  24218. * * radialSegments the number of sides on each tube segments, optional, default 32
  24219. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24220. * * p the number of windings around the z axis, optional, default 2
  24221. * * q the number of windings around the x axis, optional, default 3
  24222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24223. * * 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)
  24224. * * 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)
  24225. * @returns the VertexData of the Torus Knot
  24226. */
  24227. static CreateTorusKnot(options: {
  24228. radius?: number;
  24229. tube?: number;
  24230. radialSegments?: number;
  24231. tubularSegments?: number;
  24232. p?: number;
  24233. q?: number;
  24234. sideOrientation?: number;
  24235. frontUVs?: Vector4;
  24236. backUVs?: Vector4;
  24237. }): VertexData;
  24238. /**
  24239. * Compute normals for given positions and indices
  24240. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24241. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24242. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24243. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24244. * * facetNormals : optional array of facet normals (vector3)
  24245. * * facetPositions : optional array of facet positions (vector3)
  24246. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24247. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24248. * * bInfo : optional bounding info, required for facetPartitioning computation
  24249. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24250. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24251. * * useRightHandedSystem: optional boolean to for right handed system computation
  24252. * * depthSort : optional boolean to enable the facet depth sort computation
  24253. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24254. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24255. */
  24256. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24257. facetNormals?: any;
  24258. facetPositions?: any;
  24259. facetPartitioning?: any;
  24260. ratio?: number;
  24261. bInfo?: any;
  24262. bbSize?: Vector3;
  24263. subDiv?: any;
  24264. useRightHandedSystem?: boolean;
  24265. depthSort?: boolean;
  24266. distanceTo?: Vector3;
  24267. depthSortedFacets?: any;
  24268. }): void;
  24269. /** @hidden */
  24270. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24271. /**
  24272. * Applies VertexData created from the imported parameters to the geometry
  24273. * @param parsedVertexData the parsed data from an imported file
  24274. * @param geometry the geometry to apply the VertexData to
  24275. */
  24276. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24277. }
  24278. }
  24279. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24280. import { Nullable } from "babylonjs/types";
  24281. import { Scene } from "babylonjs/scene";
  24282. import { Vector4 } from "babylonjs/Maths/math";
  24283. import { Mesh } from "babylonjs/Meshes/mesh";
  24284. /**
  24285. * Class containing static functions to help procedurally build meshes
  24286. */
  24287. export class DiscBuilder {
  24288. /**
  24289. * Creates a plane polygonal mesh. By default, this is a disc
  24290. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24291. * * 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
  24292. * * 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
  24293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24296. * @param name defines the name of the mesh
  24297. * @param options defines the options used to create the mesh
  24298. * @param scene defines the hosting scene
  24299. * @returns the plane polygonal mesh
  24300. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24301. */
  24302. static CreateDisc(name: string, options: {
  24303. radius?: number;
  24304. tessellation?: number;
  24305. arc?: number;
  24306. updatable?: boolean;
  24307. sideOrientation?: number;
  24308. frontUVs?: Vector4;
  24309. backUVs?: Vector4;
  24310. }, scene?: Nullable<Scene>): Mesh;
  24311. }
  24312. }
  24313. declare module "babylonjs/Particles/solidParticleSystem" {
  24314. import { Vector3 } from "babylonjs/Maths/math";
  24315. import { Mesh } from "babylonjs/Meshes/mesh";
  24316. import { Scene, IDisposable } from "babylonjs/scene";
  24317. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24318. /**
  24319. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24320. *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.
  24321. * The SPS is also a particle system. It provides some methods to manage the particles.
  24322. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24323. *
  24324. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24325. */
  24326. export class SolidParticleSystem implements IDisposable {
  24327. /**
  24328. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24329. * Example : var p = SPS.particles[i];
  24330. */
  24331. particles: SolidParticle[];
  24332. /**
  24333. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24334. */
  24335. nbParticles: number;
  24336. /**
  24337. * If the particles must ever face the camera (default false). Useful for planar particles.
  24338. */
  24339. billboard: boolean;
  24340. /**
  24341. * Recompute normals when adding a shape
  24342. */
  24343. recomputeNormals: boolean;
  24344. /**
  24345. * This a counter ofr your own usage. It's not set by any SPS functions.
  24346. */
  24347. counter: number;
  24348. /**
  24349. * The SPS name. This name is also given to the underlying mesh.
  24350. */
  24351. name: string;
  24352. /**
  24353. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24354. */
  24355. mesh: Mesh;
  24356. /**
  24357. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24358. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24359. */
  24360. vars: any;
  24361. /**
  24362. * This array is populated when the SPS is set as 'pickable'.
  24363. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24364. * Each element of this array is an object `{idx: int, faceId: int}`.
  24365. * `idx` is the picked particle index in the `SPS.particles` array
  24366. * `faceId` is the picked face index counted within this particle.
  24367. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24368. */
  24369. pickedParticles: {
  24370. idx: number;
  24371. faceId: number;
  24372. }[];
  24373. /**
  24374. * This array is populated when `enableDepthSort` is set to true.
  24375. * Each element of this array is an instance of the class DepthSortedParticle.
  24376. */
  24377. depthSortedParticles: DepthSortedParticle[];
  24378. /**
  24379. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24380. * @hidden
  24381. */
  24382. _bSphereOnly: boolean;
  24383. /**
  24384. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24385. * @hidden
  24386. */
  24387. _bSphereRadiusFactor: number;
  24388. private _scene;
  24389. private _positions;
  24390. private _indices;
  24391. private _normals;
  24392. private _colors;
  24393. private _uvs;
  24394. private _indices32;
  24395. private _positions32;
  24396. private _normals32;
  24397. private _fixedNormal32;
  24398. private _colors32;
  24399. private _uvs32;
  24400. private _index;
  24401. private _updatable;
  24402. private _pickable;
  24403. private _isVisibilityBoxLocked;
  24404. private _alwaysVisible;
  24405. private _depthSort;
  24406. private _shapeCounter;
  24407. private _copy;
  24408. private _color;
  24409. private _computeParticleColor;
  24410. private _computeParticleTexture;
  24411. private _computeParticleRotation;
  24412. private _computeParticleVertex;
  24413. private _computeBoundingBox;
  24414. private _depthSortParticles;
  24415. private _camera;
  24416. private _mustUnrotateFixedNormals;
  24417. private _particlesIntersect;
  24418. private _needs32Bits;
  24419. /**
  24420. * Creates a SPS (Solid Particle System) object.
  24421. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24422. * @param scene (Scene) is the scene in which the SPS is added.
  24423. * @param options defines the options of the sps e.g.
  24424. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24425. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24426. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24427. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24428. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24429. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24430. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24431. */
  24432. constructor(name: string, scene: Scene, options?: {
  24433. updatable?: boolean;
  24434. isPickable?: boolean;
  24435. enableDepthSort?: boolean;
  24436. particleIntersection?: boolean;
  24437. boundingSphereOnly?: boolean;
  24438. bSphereRadiusFactor?: number;
  24439. });
  24440. /**
  24441. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24442. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24443. * @returns the created mesh
  24444. */
  24445. buildMesh(): Mesh;
  24446. /**
  24447. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24448. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24449. * Thus the particles generated from `digest()` have their property `position` set yet.
  24450. * @param mesh ( Mesh ) is the mesh to be digested
  24451. * @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
  24452. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24453. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24454. * @returns the current SPS
  24455. */
  24456. digest(mesh: Mesh, options?: {
  24457. facetNb?: number;
  24458. number?: number;
  24459. delta?: number;
  24460. }): SolidParticleSystem;
  24461. private _unrotateFixedNormals;
  24462. private _resetCopy;
  24463. private _meshBuilder;
  24464. private _posToShape;
  24465. private _uvsToShapeUV;
  24466. private _addParticle;
  24467. /**
  24468. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24469. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24470. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24471. * @param nb (positive integer) the number of particles to be created from this model
  24472. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24473. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24474. * @returns the number of shapes in the system
  24475. */
  24476. addShape(mesh: Mesh, nb: number, options?: {
  24477. positionFunction?: any;
  24478. vertexFunction?: any;
  24479. }): number;
  24480. private _rebuildParticle;
  24481. /**
  24482. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24483. * @returns the SPS.
  24484. */
  24485. rebuildMesh(): SolidParticleSystem;
  24486. /**
  24487. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24488. * This method calls `updateParticle()` for each particle of the SPS.
  24489. * For an animated SPS, it is usually called within the render loop.
  24490. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24491. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24492. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24493. * @returns the SPS.
  24494. */
  24495. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24496. /**
  24497. * Disposes the SPS.
  24498. */
  24499. dispose(): void;
  24500. /**
  24501. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24502. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24503. * @returns the SPS.
  24504. */
  24505. refreshVisibleSize(): SolidParticleSystem;
  24506. /**
  24507. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24508. * @param size the size (float) of the visibility box
  24509. * note : this doesn't lock the SPS mesh bounding box.
  24510. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24511. */
  24512. setVisibilityBox(size: number): void;
  24513. /**
  24514. * Gets whether the SPS as always visible or not
  24515. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24516. */
  24517. /**
  24518. * Sets the SPS as always visible or not
  24519. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24520. */
  24521. isAlwaysVisible: boolean;
  24522. /**
  24523. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24524. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24525. */
  24526. /**
  24527. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24528. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24529. */
  24530. isVisibilityBoxLocked: boolean;
  24531. /**
  24532. * Tells to `setParticles()` to compute the particle rotations or not.
  24533. * Default value : true. The SPS is faster when it's set to false.
  24534. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24535. */
  24536. /**
  24537. * Gets if `setParticles()` computes the particle rotations or not.
  24538. * Default value : true. The SPS is faster when it's set to false.
  24539. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24540. */
  24541. computeParticleRotation: boolean;
  24542. /**
  24543. * Tells to `setParticles()` to compute the particle colors or not.
  24544. * Default value : true. The SPS is faster when it's set to false.
  24545. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24546. */
  24547. /**
  24548. * Gets if `setParticles()` computes the particle colors or not.
  24549. * Default value : true. The SPS is faster when it's set to false.
  24550. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24551. */
  24552. computeParticleColor: boolean;
  24553. /**
  24554. * Gets if `setParticles()` computes the particle textures or not.
  24555. * Default value : true. The SPS is faster when it's set to false.
  24556. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24557. */
  24558. computeParticleTexture: boolean;
  24559. /**
  24560. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24561. * Default value : false. The SPS is faster when it's set to false.
  24562. * Note : the particle custom vertex positions aren't stored values.
  24563. */
  24564. /**
  24565. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24566. * Default value : false. The SPS is faster when it's set to false.
  24567. * Note : the particle custom vertex positions aren't stored values.
  24568. */
  24569. computeParticleVertex: boolean;
  24570. /**
  24571. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24572. */
  24573. /**
  24574. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24575. */
  24576. computeBoundingBox: boolean;
  24577. /**
  24578. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24579. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24580. * Default : `true`
  24581. */
  24582. /**
  24583. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24584. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24585. * Default : `true`
  24586. */
  24587. depthSortParticles: boolean;
  24588. /**
  24589. * This function does nothing. It may be overwritten to set all the particle first values.
  24590. * The SPS doesn't call this function, you may have to call it by your own.
  24591. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24592. */
  24593. initParticles(): void;
  24594. /**
  24595. * This function does nothing. It may be overwritten to recycle a particle.
  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. * @param particle The particle to recycle
  24599. * @returns the recycled particle
  24600. */
  24601. recycleParticle(particle: SolidParticle): SolidParticle;
  24602. /**
  24603. * Updates a particle : this function should be overwritten by the user.
  24604. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24605. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24606. * @example : just set a particle position or velocity and recycle conditions
  24607. * @param particle The particle to update
  24608. * @returns the updated particle
  24609. */
  24610. updateParticle(particle: SolidParticle): SolidParticle;
  24611. /**
  24612. * Updates a vertex of a particle : it can be overwritten by the user.
  24613. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24614. * @param particle the current particle
  24615. * @param vertex the current index of the current particle
  24616. * @param pt the index of the current vertex in the particle shape
  24617. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24618. * @example : just set a vertex particle position
  24619. * @returns the updated vertex
  24620. */
  24621. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24622. /**
  24623. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24624. * This does nothing and may be overwritten by the user.
  24625. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24626. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24627. * @param update the boolean update value actually passed to setParticles()
  24628. */
  24629. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24630. /**
  24631. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24632. * This will be passed three parameters.
  24633. * This does nothing and may be overwritten by the user.
  24634. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24635. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24636. * @param update the boolean update value actually passed to setParticles()
  24637. */
  24638. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24639. }
  24640. }
  24641. declare module "babylonjs/Particles/solidParticle" {
  24642. import { Nullable } from "babylonjs/types";
  24643. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24644. import { Mesh } from "babylonjs/Meshes/mesh";
  24645. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24646. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24647. /**
  24648. * Represents one particle of a solid particle system.
  24649. */
  24650. export class SolidParticle {
  24651. /**
  24652. * particle global index
  24653. */
  24654. idx: number;
  24655. /**
  24656. * The color of the particle
  24657. */
  24658. color: Nullable<Color4>;
  24659. /**
  24660. * The world space position of the particle.
  24661. */
  24662. position: Vector3;
  24663. /**
  24664. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24665. */
  24666. rotation: Vector3;
  24667. /**
  24668. * The world space rotation quaternion of the particle.
  24669. */
  24670. rotationQuaternion: Nullable<Quaternion>;
  24671. /**
  24672. * The scaling of the particle.
  24673. */
  24674. scaling: Vector3;
  24675. /**
  24676. * The uvs of the particle.
  24677. */
  24678. uvs: Vector4;
  24679. /**
  24680. * The current speed of the particle.
  24681. */
  24682. velocity: Vector3;
  24683. /**
  24684. * The pivot point in the particle local space.
  24685. */
  24686. pivot: Vector3;
  24687. /**
  24688. * Must the particle be translated from its pivot point in its local space ?
  24689. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24690. * Default : false
  24691. */
  24692. translateFromPivot: boolean;
  24693. /**
  24694. * Is the particle active or not ?
  24695. */
  24696. alive: boolean;
  24697. /**
  24698. * Is the particle visible or not ?
  24699. */
  24700. isVisible: boolean;
  24701. /**
  24702. * Index of this particle in the global "positions" array (Internal use)
  24703. * @hidden
  24704. */
  24705. _pos: number;
  24706. /**
  24707. * @hidden Index of this particle in the global "indices" array (Internal use)
  24708. */
  24709. _ind: number;
  24710. /**
  24711. * @hidden ModelShape of this particle (Internal use)
  24712. */
  24713. _model: ModelShape;
  24714. /**
  24715. * ModelShape id of this particle
  24716. */
  24717. shapeId: number;
  24718. /**
  24719. * Index of the particle in its shape id (Internal use)
  24720. */
  24721. idxInShape: number;
  24722. /**
  24723. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24724. */
  24725. _modelBoundingInfo: BoundingInfo;
  24726. /**
  24727. * @hidden Particle BoundingInfo object (Internal use)
  24728. */
  24729. _boundingInfo: BoundingInfo;
  24730. /**
  24731. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24732. */
  24733. _sps: SolidParticleSystem;
  24734. /**
  24735. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24736. */
  24737. _stillInvisible: boolean;
  24738. /**
  24739. * @hidden Last computed particle rotation matrix
  24740. */
  24741. _rotationMatrix: number[];
  24742. /**
  24743. * Parent particle Id, if any.
  24744. * Default null.
  24745. */
  24746. parentId: Nullable<number>;
  24747. /**
  24748. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24749. * The possible values are :
  24750. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24751. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24752. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24753. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24754. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24755. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24756. * */
  24757. cullingStrategy: number;
  24758. /**
  24759. * @hidden Internal global position in the SPS.
  24760. */
  24761. _globalPosition: Vector3;
  24762. /**
  24763. * Creates a Solid Particle object.
  24764. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24765. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24766. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24767. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24768. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24769. * @param shapeId (integer) is the model shape identifier in the SPS.
  24770. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24771. * @param sps defines the sps it is associated to
  24772. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24773. */
  24774. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24775. /**
  24776. * Legacy support, changed scale to scaling
  24777. */
  24778. /**
  24779. * Legacy support, changed scale to scaling
  24780. */
  24781. scale: Vector3;
  24782. /**
  24783. * Legacy support, changed quaternion to rotationQuaternion
  24784. */
  24785. /**
  24786. * Legacy support, changed quaternion to rotationQuaternion
  24787. */
  24788. quaternion: Nullable<Quaternion>;
  24789. /**
  24790. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24791. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24792. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24793. * @returns true if it intersects
  24794. */
  24795. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24796. /**
  24797. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24798. * A particle is in the frustum if its bounding box intersects the frustum
  24799. * @param frustumPlanes defines the frustum to test
  24800. * @returns true if the particle is in the frustum planes
  24801. */
  24802. isInFrustum(frustumPlanes: Plane[]): boolean;
  24803. /**
  24804. * get the rotation matrix of the particle
  24805. * @hidden
  24806. */
  24807. getRotationMatrix(m: Matrix): void;
  24808. }
  24809. /**
  24810. * Represents the shape of the model used by one particle of a solid particle system.
  24811. * SPS internal tool, don't use it manually.
  24812. */
  24813. export class ModelShape {
  24814. /**
  24815. * The shape id
  24816. * @hidden
  24817. */
  24818. shapeID: number;
  24819. /**
  24820. * flat array of model positions (internal use)
  24821. * @hidden
  24822. */
  24823. _shape: Vector3[];
  24824. /**
  24825. * flat array of model UVs (internal use)
  24826. * @hidden
  24827. */
  24828. _shapeUV: number[];
  24829. /**
  24830. * length of the shape in the model indices array (internal use)
  24831. * @hidden
  24832. */
  24833. _indicesLength: number;
  24834. /**
  24835. * Custom position function (internal use)
  24836. * @hidden
  24837. */
  24838. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24839. /**
  24840. * Custom vertex function (internal use)
  24841. * @hidden
  24842. */
  24843. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24844. /**
  24845. * 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.
  24846. * SPS internal tool, don't use it manually.
  24847. * @hidden
  24848. */
  24849. 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>);
  24850. }
  24851. /**
  24852. * Represents a Depth Sorted Particle in the solid particle system.
  24853. */
  24854. export class DepthSortedParticle {
  24855. /**
  24856. * Index of the particle in the "indices" array
  24857. */
  24858. ind: number;
  24859. /**
  24860. * Length of the particle shape in the "indices" array
  24861. */
  24862. indicesLength: number;
  24863. /**
  24864. * Squared distance from the particle to the camera
  24865. */
  24866. sqDistance: number;
  24867. }
  24868. }
  24869. declare module "babylonjs/Collisions/meshCollisionData" {
  24870. import { Collider } from "babylonjs/Collisions/collider";
  24871. import { Vector3 } from "babylonjs/Maths/math";
  24872. import { Nullable } from "babylonjs/types";
  24873. import { Observer } from "babylonjs/Misc/observable";
  24874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24875. /**
  24876. * @hidden
  24877. */
  24878. export class _MeshCollisionData {
  24879. _checkCollisions: boolean;
  24880. _collisionMask: number;
  24881. _collisionGroup: number;
  24882. _collider: Nullable<Collider>;
  24883. _oldPositionForCollisions: Vector3;
  24884. _diffPositionForCollisions: Vector3;
  24885. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24886. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24887. }
  24888. }
  24889. declare module "babylonjs/Meshes/abstractMesh" {
  24890. import { Observable } from "babylonjs/Misc/observable";
  24891. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24892. import { Camera } from "babylonjs/Cameras/camera";
  24893. import { Scene, IDisposable } from "babylonjs/scene";
  24894. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24895. import { Node } from "babylonjs/node";
  24896. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24897. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24898. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24899. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24900. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24901. import { Material } from "babylonjs/Materials/material";
  24902. import { Light } from "babylonjs/Lights/light";
  24903. import { Skeleton } from "babylonjs/Bones/skeleton";
  24904. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24905. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24906. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24907. import { Ray } from "babylonjs/Culling/ray";
  24908. import { Collider } from "babylonjs/Collisions/collider";
  24909. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24910. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24911. /**
  24912. * Class used to store all common mesh properties
  24913. */
  24914. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24915. /** No occlusion */
  24916. static OCCLUSION_TYPE_NONE: number;
  24917. /** Occlusion set to optimisitic */
  24918. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24919. /** Occlusion set to strict */
  24920. static OCCLUSION_TYPE_STRICT: number;
  24921. /** Use an accurante occlusion algorithm */
  24922. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24923. /** Use a conservative occlusion algorithm */
  24924. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24925. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24926. * Test order :
  24927. * Is the bounding sphere outside the frustum ?
  24928. * If not, are the bounding box vertices outside the frustum ?
  24929. * It not, then the cullable object is in the frustum.
  24930. */
  24931. static readonly CULLINGSTRATEGY_STANDARD: number;
  24932. /** Culling strategy : Bounding Sphere Only.
  24933. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24934. * It's also less accurate than the standard because some not visible objects can still be selected.
  24935. * Test : is the bounding sphere outside the frustum ?
  24936. * If not, then the cullable object is in the frustum.
  24937. */
  24938. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24939. /** Culling strategy : Optimistic Inclusion.
  24940. * This in an inclusion test first, then the standard exclusion test.
  24941. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24942. * 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.
  24943. * Anyway, it's as accurate as the standard strategy.
  24944. * Test :
  24945. * Is the cullable object bounding sphere center in the frustum ?
  24946. * If not, apply the default culling strategy.
  24947. */
  24948. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24949. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24950. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24951. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24952. * 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.
  24953. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24954. * Test :
  24955. * Is the cullable object bounding sphere center in the frustum ?
  24956. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24957. */
  24958. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24959. /**
  24960. * No billboard
  24961. */
  24962. static readonly BILLBOARDMODE_NONE: number;
  24963. /** Billboard on X axis */
  24964. static readonly BILLBOARDMODE_X: number;
  24965. /** Billboard on Y axis */
  24966. static readonly BILLBOARDMODE_Y: number;
  24967. /** Billboard on Z axis */
  24968. static readonly BILLBOARDMODE_Z: number;
  24969. /** Billboard on all axes */
  24970. static readonly BILLBOARDMODE_ALL: number;
  24971. private _internalAbstractMeshDataInfo;
  24972. /**
  24973. * The culling strategy to use to check whether the mesh must be rendered or not.
  24974. * This value can be changed at any time and will be used on the next render mesh selection.
  24975. * The possible values are :
  24976. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24977. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24978. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24979. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24980. * Please read each static variable documentation to get details about the culling process.
  24981. * */
  24982. cullingStrategy: number;
  24983. /**
  24984. * Gets the number of facets in the mesh
  24985. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24986. */
  24987. readonly facetNb: number;
  24988. /**
  24989. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24991. */
  24992. partitioningSubdivisions: number;
  24993. /**
  24994. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24995. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24996. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24997. */
  24998. partitioningBBoxRatio: number;
  24999. /**
  25000. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25001. * Works only for updatable meshes.
  25002. * Doesn't work with multi-materials
  25003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25004. */
  25005. mustDepthSortFacets: boolean;
  25006. /**
  25007. * The location (Vector3) where the facet depth sort must be computed from.
  25008. * By default, the active camera position.
  25009. * Used only when facet depth sort is enabled
  25010. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25011. */
  25012. facetDepthSortFrom: Vector3;
  25013. /**
  25014. * gets a boolean indicating if facetData is enabled
  25015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25016. */
  25017. readonly isFacetDataEnabled: boolean;
  25018. /** @hidden */
  25019. _updateNonUniformScalingState(value: boolean): boolean;
  25020. /**
  25021. * An event triggered when this mesh collides with another one
  25022. */
  25023. onCollideObservable: Observable<AbstractMesh>;
  25024. /** Set a function to call when this mesh collides with another one */
  25025. onCollide: () => void;
  25026. /**
  25027. * An event triggered when the collision's position changes
  25028. */
  25029. onCollisionPositionChangeObservable: Observable<Vector3>;
  25030. /** Set a function to call when the collision's position changes */
  25031. onCollisionPositionChange: () => void;
  25032. /**
  25033. * An event triggered when material is changed
  25034. */
  25035. onMaterialChangedObservable: Observable<AbstractMesh>;
  25036. /**
  25037. * Gets or sets the orientation for POV movement & rotation
  25038. */
  25039. definedFacingForward: boolean;
  25040. /** @hidden */
  25041. _occlusionQuery: Nullable<WebGLQuery>;
  25042. /** @hidden */
  25043. _isActive: boolean;
  25044. /** @hidden */
  25045. _onlyForInstances: boolean;
  25046. /** @hidden */
  25047. _renderingGroup: Nullable<RenderingGroup>;
  25048. /**
  25049. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25050. */
  25051. /**
  25052. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25053. */
  25054. visibility: number;
  25055. /** Gets or sets the alpha index used to sort transparent meshes
  25056. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25057. */
  25058. alphaIndex: number;
  25059. /**
  25060. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25061. */
  25062. isVisible: boolean;
  25063. /**
  25064. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25065. */
  25066. isPickable: boolean;
  25067. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25068. showSubMeshesBoundingBox: boolean;
  25069. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25070. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25071. */
  25072. isBlocker: boolean;
  25073. /**
  25074. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25075. */
  25076. enablePointerMoveEvents: boolean;
  25077. /**
  25078. * Specifies the rendering group id for this mesh (0 by default)
  25079. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25080. */
  25081. renderingGroupId: number;
  25082. private _material;
  25083. /** Gets or sets current material */
  25084. material: Nullable<Material>;
  25085. /**
  25086. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25087. * @see http://doc.babylonjs.com/babylon101/shadows
  25088. */
  25089. receiveShadows: boolean;
  25090. /** Defines color to use when rendering outline */
  25091. outlineColor: Color3;
  25092. /** Define width to use when rendering outline */
  25093. outlineWidth: number;
  25094. /** Defines color to use when rendering overlay */
  25095. overlayColor: Color3;
  25096. /** Defines alpha to use when rendering overlay */
  25097. overlayAlpha: number;
  25098. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25099. hasVertexAlpha: boolean;
  25100. /** 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) */
  25101. useVertexColors: boolean;
  25102. /**
  25103. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25104. */
  25105. computeBonesUsingShaders: boolean;
  25106. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25107. numBoneInfluencers: number;
  25108. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25109. applyFog: boolean;
  25110. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25111. useOctreeForRenderingSelection: boolean;
  25112. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25113. useOctreeForPicking: boolean;
  25114. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25115. useOctreeForCollisions: boolean;
  25116. /**
  25117. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25118. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25119. */
  25120. layerMask: number;
  25121. /**
  25122. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25123. */
  25124. alwaysSelectAsActiveMesh: boolean;
  25125. /**
  25126. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25127. */
  25128. doNotSyncBoundingInfo: boolean;
  25129. /**
  25130. * Gets or sets the current action manager
  25131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25132. */
  25133. actionManager: Nullable<AbstractActionManager>;
  25134. private _meshCollisionData;
  25135. /**
  25136. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25137. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25138. */
  25139. ellipsoid: Vector3;
  25140. /**
  25141. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25143. */
  25144. ellipsoidOffset: Vector3;
  25145. /**
  25146. * Gets or sets a collision mask used to mask collisions (default is -1).
  25147. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25148. */
  25149. collisionMask: number;
  25150. /**
  25151. * Gets or sets the current collision group mask (-1 by default).
  25152. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25153. */
  25154. collisionGroup: number;
  25155. /**
  25156. * Defines edge width used when edgesRenderer is enabled
  25157. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25158. */
  25159. edgesWidth: number;
  25160. /**
  25161. * Defines edge color used when edgesRenderer is enabled
  25162. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25163. */
  25164. edgesColor: Color4;
  25165. /** @hidden */
  25166. _edgesRenderer: Nullable<IEdgesRenderer>;
  25167. /** @hidden */
  25168. _masterMesh: Nullable<AbstractMesh>;
  25169. /** @hidden */
  25170. _boundingInfo: Nullable<BoundingInfo>;
  25171. /** @hidden */
  25172. _renderId: number;
  25173. /**
  25174. * Gets or sets the list of subMeshes
  25175. * @see http://doc.babylonjs.com/how_to/multi_materials
  25176. */
  25177. subMeshes: SubMesh[];
  25178. /** @hidden */
  25179. _intersectionsInProgress: AbstractMesh[];
  25180. /** @hidden */
  25181. _unIndexed: boolean;
  25182. /** @hidden */
  25183. _lightSources: Light[];
  25184. /** Gets the list of lights affecting that mesh */
  25185. readonly lightSources: Light[];
  25186. /** @hidden */
  25187. readonly _positions: Nullable<Vector3[]>;
  25188. /** @hidden */
  25189. _waitingData: {
  25190. lods: Nullable<any>;
  25191. actions: Nullable<any>;
  25192. freezeWorldMatrix: Nullable<boolean>;
  25193. };
  25194. /** @hidden */
  25195. _bonesTransformMatrices: Nullable<Float32Array>;
  25196. /**
  25197. * Gets or sets a skeleton to apply skining transformations
  25198. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25199. */
  25200. skeleton: Nullable<Skeleton>;
  25201. /**
  25202. * An event triggered when the mesh is rebuilt.
  25203. */
  25204. onRebuildObservable: Observable<AbstractMesh>;
  25205. /**
  25206. * Creates a new AbstractMesh
  25207. * @param name defines the name of the mesh
  25208. * @param scene defines the hosting scene
  25209. */
  25210. constructor(name: string, scene?: Nullable<Scene>);
  25211. /**
  25212. * Returns the string "AbstractMesh"
  25213. * @returns "AbstractMesh"
  25214. */
  25215. getClassName(): string;
  25216. /**
  25217. * Gets a string representation of the current mesh
  25218. * @param fullDetails defines a boolean indicating if full details must be included
  25219. * @returns a string representation of the current mesh
  25220. */
  25221. toString(fullDetails?: boolean): string;
  25222. /**
  25223. * @hidden
  25224. */
  25225. protected _getEffectiveParent(): Nullable<Node>;
  25226. /** @hidden */
  25227. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25228. /** @hidden */
  25229. _rebuild(): void;
  25230. /** @hidden */
  25231. _resyncLightSources(): void;
  25232. /** @hidden */
  25233. _resyncLighSource(light: Light): void;
  25234. /** @hidden */
  25235. _unBindEffect(): void;
  25236. /** @hidden */
  25237. _removeLightSource(light: Light): void;
  25238. private _markSubMeshesAsDirty;
  25239. /** @hidden */
  25240. _markSubMeshesAsLightDirty(): void;
  25241. /** @hidden */
  25242. _markSubMeshesAsAttributesDirty(): void;
  25243. /** @hidden */
  25244. _markSubMeshesAsMiscDirty(): void;
  25245. /**
  25246. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25247. */
  25248. scaling: Vector3;
  25249. /**
  25250. * Returns true if the mesh is blocked. Implemented by child classes
  25251. */
  25252. readonly isBlocked: boolean;
  25253. /**
  25254. * Returns the mesh itself by default. Implemented by child classes
  25255. * @param camera defines the camera to use to pick the right LOD level
  25256. * @returns the currentAbstractMesh
  25257. */
  25258. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25259. /**
  25260. * Returns 0 by default. Implemented by child classes
  25261. * @returns an integer
  25262. */
  25263. getTotalVertices(): number;
  25264. /**
  25265. * Returns a positive integer : the total number of indices in this mesh geometry.
  25266. * @returns the numner of indices or zero if the mesh has no geometry.
  25267. */
  25268. getTotalIndices(): number;
  25269. /**
  25270. * Returns null by default. Implemented by child classes
  25271. * @returns null
  25272. */
  25273. getIndices(): Nullable<IndicesArray>;
  25274. /**
  25275. * Returns the array of the requested vertex data kind. Implemented by child classes
  25276. * @param kind defines the vertex data kind to use
  25277. * @returns null
  25278. */
  25279. getVerticesData(kind: string): Nullable<FloatArray>;
  25280. /**
  25281. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25282. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25283. * Note that a new underlying VertexBuffer object is created each call.
  25284. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25285. * @param kind defines vertex data kind:
  25286. * * VertexBuffer.PositionKind
  25287. * * VertexBuffer.UVKind
  25288. * * VertexBuffer.UV2Kind
  25289. * * VertexBuffer.UV3Kind
  25290. * * VertexBuffer.UV4Kind
  25291. * * VertexBuffer.UV5Kind
  25292. * * VertexBuffer.UV6Kind
  25293. * * VertexBuffer.ColorKind
  25294. * * VertexBuffer.MatricesIndicesKind
  25295. * * VertexBuffer.MatricesIndicesExtraKind
  25296. * * VertexBuffer.MatricesWeightsKind
  25297. * * VertexBuffer.MatricesWeightsExtraKind
  25298. * @param data defines the data source
  25299. * @param updatable defines if the data must be flagged as updatable (or static)
  25300. * @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
  25301. * @returns the current mesh
  25302. */
  25303. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25304. /**
  25305. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25306. * If the mesh has no geometry, it is simply returned as it is.
  25307. * @param kind defines vertex data kind:
  25308. * * VertexBuffer.PositionKind
  25309. * * VertexBuffer.UVKind
  25310. * * VertexBuffer.UV2Kind
  25311. * * VertexBuffer.UV3Kind
  25312. * * VertexBuffer.UV4Kind
  25313. * * VertexBuffer.UV5Kind
  25314. * * VertexBuffer.UV6Kind
  25315. * * VertexBuffer.ColorKind
  25316. * * VertexBuffer.MatricesIndicesKind
  25317. * * VertexBuffer.MatricesIndicesExtraKind
  25318. * * VertexBuffer.MatricesWeightsKind
  25319. * * VertexBuffer.MatricesWeightsExtraKind
  25320. * @param data defines the data source
  25321. * @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
  25322. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25323. * @returns the current mesh
  25324. */
  25325. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25326. /**
  25327. * Sets the mesh indices,
  25328. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25329. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25330. * @param totalVertices Defines the total number of vertices
  25331. * @returns the current mesh
  25332. */
  25333. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25334. /**
  25335. * Gets a boolean indicating if specific vertex data is present
  25336. * @param kind defines the vertex data kind to use
  25337. * @returns true is data kind is present
  25338. */
  25339. isVerticesDataPresent(kind: string): boolean;
  25340. /**
  25341. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25342. * @returns a BoundingInfo
  25343. */
  25344. getBoundingInfo(): BoundingInfo;
  25345. /**
  25346. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25347. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25348. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25349. * @returns the current mesh
  25350. */
  25351. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25352. /**
  25353. * Overwrite the current bounding info
  25354. * @param boundingInfo defines the new bounding info
  25355. * @returns the current mesh
  25356. */
  25357. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25358. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25359. readonly useBones: boolean;
  25360. /** @hidden */
  25361. _preActivate(): void;
  25362. /** @hidden */
  25363. _preActivateForIntermediateRendering(renderId: number): void;
  25364. /** @hidden */
  25365. _activate(renderId: number): boolean;
  25366. /** @hidden */
  25367. _postActivate(): void;
  25368. /** @hidden */
  25369. _freeze(): void;
  25370. /** @hidden */
  25371. _unFreeze(): void;
  25372. /**
  25373. * Gets the current world matrix
  25374. * @returns a Matrix
  25375. */
  25376. getWorldMatrix(): Matrix;
  25377. /** @hidden */
  25378. _getWorldMatrixDeterminant(): number;
  25379. /**
  25380. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25381. */
  25382. readonly isAnInstance: boolean;
  25383. /**
  25384. * Perform relative position change from the point of view of behind the front of the mesh.
  25385. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25386. * Supports definition of mesh facing forward or backward
  25387. * @param amountRight defines the distance on the right axis
  25388. * @param amountUp defines the distance on the up axis
  25389. * @param amountForward defines the distance on the forward axis
  25390. * @returns the current mesh
  25391. */
  25392. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25393. /**
  25394. * Calculate relative position change from the point of view of behind the front of the mesh.
  25395. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25396. * Supports definition of mesh facing forward or backward
  25397. * @param amountRight defines the distance on the right axis
  25398. * @param amountUp defines the distance on the up axis
  25399. * @param amountForward defines the distance on the forward axis
  25400. * @returns the new displacement vector
  25401. */
  25402. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25403. /**
  25404. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25405. * Supports definition of mesh facing forward or backward
  25406. * @param flipBack defines the flip
  25407. * @param twirlClockwise defines the twirl
  25408. * @param tiltRight defines the tilt
  25409. * @returns the current mesh
  25410. */
  25411. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25412. /**
  25413. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25414. * Supports definition of mesh facing forward or backward.
  25415. * @param flipBack defines the flip
  25416. * @param twirlClockwise defines the twirl
  25417. * @param tiltRight defines the tilt
  25418. * @returns the new rotation vector
  25419. */
  25420. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25421. /**
  25422. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25423. * This means the mesh underlying bounding box and sphere are recomputed.
  25424. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25425. * @returns the current mesh
  25426. */
  25427. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25428. /** @hidden */
  25429. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25430. /** @hidden */
  25431. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25432. /** @hidden */
  25433. _updateBoundingInfo(): AbstractMesh;
  25434. /** @hidden */
  25435. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25436. /** @hidden */
  25437. protected _afterComputeWorldMatrix(): void;
  25438. /** @hidden */
  25439. readonly _effectiveMesh: AbstractMesh;
  25440. /**
  25441. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25442. * A mesh is in the frustum if its bounding box intersects the frustum
  25443. * @param frustumPlanes defines the frustum to test
  25444. * @returns true if the mesh is in the frustum planes
  25445. */
  25446. isInFrustum(frustumPlanes: Plane[]): boolean;
  25447. /**
  25448. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25449. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25450. * @param frustumPlanes defines the frustum to test
  25451. * @returns true if the mesh is completely in the frustum planes
  25452. */
  25453. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25454. /**
  25455. * True if the mesh intersects another mesh or a SolidParticle object
  25456. * @param mesh defines a target mesh or SolidParticle to test
  25457. * @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)
  25458. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25459. * @returns true if there is an intersection
  25460. */
  25461. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25462. /**
  25463. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25464. * @param point defines the point to test
  25465. * @returns true if there is an intersection
  25466. */
  25467. intersectsPoint(point: Vector3): boolean;
  25468. /**
  25469. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25471. */
  25472. checkCollisions: boolean;
  25473. /**
  25474. * Gets Collider object used to compute collisions (not physics)
  25475. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25476. */
  25477. readonly collider: Nullable<Collider>;
  25478. /**
  25479. * Move the mesh using collision engine
  25480. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25481. * @param displacement defines the requested displacement vector
  25482. * @returns the current mesh
  25483. */
  25484. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25485. private _onCollisionPositionChange;
  25486. /** @hidden */
  25487. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25488. /** @hidden */
  25489. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25490. /** @hidden */
  25491. _checkCollision(collider: Collider): AbstractMesh;
  25492. /** @hidden */
  25493. _generatePointsArray(): boolean;
  25494. /**
  25495. * Checks if the passed Ray intersects with the mesh
  25496. * @param ray defines the ray to use
  25497. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25498. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25499. * @returns the picking info
  25500. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25501. */
  25502. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25503. /**
  25504. * Clones the current mesh
  25505. * @param name defines the mesh name
  25506. * @param newParent defines the new mesh parent
  25507. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25508. * @returns the new mesh
  25509. */
  25510. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25511. /**
  25512. * Disposes all the submeshes of the current meshnp
  25513. * @returns the current mesh
  25514. */
  25515. releaseSubMeshes(): AbstractMesh;
  25516. /**
  25517. * Releases resources associated with this abstract mesh.
  25518. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25519. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25520. */
  25521. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25522. /**
  25523. * Adds the passed mesh as a child to the current mesh
  25524. * @param mesh defines the child mesh
  25525. * @returns the current mesh
  25526. */
  25527. addChild(mesh: AbstractMesh): AbstractMesh;
  25528. /**
  25529. * Removes the passed mesh from the current mesh children list
  25530. * @param mesh defines the child mesh
  25531. * @returns the current mesh
  25532. */
  25533. removeChild(mesh: AbstractMesh): AbstractMesh;
  25534. /** @hidden */
  25535. private _initFacetData;
  25536. /**
  25537. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25538. * This method can be called within the render loop.
  25539. * 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
  25540. * @returns the current mesh
  25541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25542. */
  25543. updateFacetData(): AbstractMesh;
  25544. /**
  25545. * Returns the facetLocalNormals array.
  25546. * The normals are expressed in the mesh local spac
  25547. * @returns an array of Vector3
  25548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25549. */
  25550. getFacetLocalNormals(): Vector3[];
  25551. /**
  25552. * Returns the facetLocalPositions array.
  25553. * The facet positions are expressed in the mesh local space
  25554. * @returns an array of Vector3
  25555. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25556. */
  25557. getFacetLocalPositions(): Vector3[];
  25558. /**
  25559. * Returns the facetLocalPartioning array
  25560. * @returns an array of array of numbers
  25561. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25562. */
  25563. getFacetLocalPartitioning(): number[][];
  25564. /**
  25565. * Returns the i-th facet position in the world system.
  25566. * This method allocates a new Vector3 per call
  25567. * @param i defines the facet index
  25568. * @returns a new Vector3
  25569. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25570. */
  25571. getFacetPosition(i: number): Vector3;
  25572. /**
  25573. * Sets the reference Vector3 with the i-th facet position in the world system
  25574. * @param i defines the facet index
  25575. * @param ref defines the target vector
  25576. * @returns the current mesh
  25577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25578. */
  25579. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25580. /**
  25581. * Returns the i-th facet normal in the world system.
  25582. * This method allocates a new Vector3 per call
  25583. * @param i defines the facet index
  25584. * @returns a new Vector3
  25585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25586. */
  25587. getFacetNormal(i: number): Vector3;
  25588. /**
  25589. * Sets the reference Vector3 with the i-th facet normal in the world system
  25590. * @param i defines the facet index
  25591. * @param ref defines the target vector
  25592. * @returns the current mesh
  25593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25594. */
  25595. getFacetNormalToRef(i: number, ref: Vector3): this;
  25596. /**
  25597. * 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)
  25598. * @param x defines x coordinate
  25599. * @param y defines y coordinate
  25600. * @param z defines z coordinate
  25601. * @returns the array of facet indexes
  25602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25603. */
  25604. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25605. /**
  25606. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25607. * @param projected sets as the (x,y,z) world projection on the facet
  25608. * @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
  25609. * @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
  25610. * @param x defines x coordinate
  25611. * @param y defines y coordinate
  25612. * @param z defines z coordinate
  25613. * @returns the face index if found (or null instead)
  25614. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25615. */
  25616. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25617. /**
  25618. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25619. * @param projected sets as the (x,y,z) local projection on the facet
  25620. * @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
  25621. * @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
  25622. * @param x defines x coordinate
  25623. * @param y defines y coordinate
  25624. * @param z defines z coordinate
  25625. * @returns the face index if found (or null instead)
  25626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25627. */
  25628. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25629. /**
  25630. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25631. * @returns the parameters
  25632. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25633. */
  25634. getFacetDataParameters(): any;
  25635. /**
  25636. * Disables the feature FacetData and frees the related memory
  25637. * @returns the current mesh
  25638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25639. */
  25640. disableFacetData(): AbstractMesh;
  25641. /**
  25642. * Updates the AbstractMesh indices array
  25643. * @param indices defines the data source
  25644. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25645. * @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)
  25646. * @returns the current mesh
  25647. */
  25648. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25649. /**
  25650. * Creates new normals data for the mesh
  25651. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25652. * @returns the current mesh
  25653. */
  25654. createNormals(updatable: boolean): AbstractMesh;
  25655. /**
  25656. * Align the mesh with a normal
  25657. * @param normal defines the normal to use
  25658. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25659. * @returns the current mesh
  25660. */
  25661. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25662. /** @hidden */
  25663. _checkOcclusionQuery(): boolean;
  25664. }
  25665. }
  25666. declare module "babylonjs/Actions/actionEvent" {
  25667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25668. import { Nullable } from "babylonjs/types";
  25669. import { Sprite } from "babylonjs/Sprites/sprite";
  25670. import { Scene } from "babylonjs/scene";
  25671. import { Vector2 } from "babylonjs/Maths/math";
  25672. /**
  25673. * Interface used to define ActionEvent
  25674. */
  25675. export interface IActionEvent {
  25676. /** The mesh or sprite that triggered the action */
  25677. source: any;
  25678. /** The X mouse cursor position at the time of the event */
  25679. pointerX: number;
  25680. /** The Y mouse cursor position at the time of the event */
  25681. pointerY: number;
  25682. /** The mesh that is currently pointed at (can be null) */
  25683. meshUnderPointer: Nullable<AbstractMesh>;
  25684. /** the original (browser) event that triggered the ActionEvent */
  25685. sourceEvent?: any;
  25686. /** additional data for the event */
  25687. additionalData?: any;
  25688. }
  25689. /**
  25690. * ActionEvent is the event being sent when an action is triggered.
  25691. */
  25692. export class ActionEvent implements IActionEvent {
  25693. /** The mesh or sprite that triggered the action */
  25694. source: any;
  25695. /** The X mouse cursor position at the time of the event */
  25696. pointerX: number;
  25697. /** The Y mouse cursor position at the time of the event */
  25698. pointerY: number;
  25699. /** The mesh that is currently pointed at (can be null) */
  25700. meshUnderPointer: Nullable<AbstractMesh>;
  25701. /** the original (browser) event that triggered the ActionEvent */
  25702. sourceEvent?: any;
  25703. /** additional data for the event */
  25704. additionalData?: any;
  25705. /**
  25706. * Creates a new ActionEvent
  25707. * @param source The mesh or sprite that triggered the action
  25708. * @param pointerX The X mouse cursor position at the time of the event
  25709. * @param pointerY The Y mouse cursor position at the time of the event
  25710. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25711. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25712. * @param additionalData additional data for the event
  25713. */
  25714. constructor(
  25715. /** The mesh or sprite that triggered the action */
  25716. source: any,
  25717. /** The X mouse cursor position at the time of the event */
  25718. pointerX: number,
  25719. /** The Y mouse cursor position at the time of the event */
  25720. pointerY: number,
  25721. /** The mesh that is currently pointed at (can be null) */
  25722. meshUnderPointer: Nullable<AbstractMesh>,
  25723. /** the original (browser) event that triggered the ActionEvent */
  25724. sourceEvent?: any,
  25725. /** additional data for the event */
  25726. additionalData?: any);
  25727. /**
  25728. * Helper function to auto-create an ActionEvent from a source mesh.
  25729. * @param source The source mesh that triggered the event
  25730. * @param evt The original (browser) event
  25731. * @param additionalData additional data for the event
  25732. * @returns the new ActionEvent
  25733. */
  25734. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25735. /**
  25736. * Helper function to auto-create an ActionEvent from a source sprite
  25737. * @param source The source sprite that triggered the event
  25738. * @param scene Scene associated with the sprite
  25739. * @param evt The original (browser) event
  25740. * @param additionalData additional data for the event
  25741. * @returns the new ActionEvent
  25742. */
  25743. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25744. /**
  25745. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25746. * @param scene the scene where the event occurred
  25747. * @param evt The original (browser) event
  25748. * @returns the new ActionEvent
  25749. */
  25750. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25751. /**
  25752. * Helper function to auto-create an ActionEvent from a primitive
  25753. * @param prim defines the target primitive
  25754. * @param pointerPos defines the pointer position
  25755. * @param evt The original (browser) event
  25756. * @param additionalData additional data for the event
  25757. * @returns the new ActionEvent
  25758. */
  25759. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25760. }
  25761. }
  25762. declare module "babylonjs/Actions/abstractActionManager" {
  25763. import { IDisposable } from "babylonjs/scene";
  25764. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25765. import { IAction } from "babylonjs/Actions/action";
  25766. import { Nullable } from "babylonjs/types";
  25767. /**
  25768. * Abstract class used to decouple action Manager from scene and meshes.
  25769. * Do not instantiate.
  25770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25771. */
  25772. export abstract class AbstractActionManager implements IDisposable {
  25773. /** Gets the list of active triggers */
  25774. static Triggers: {
  25775. [key: string]: number;
  25776. };
  25777. /** Gets the cursor to use when hovering items */
  25778. hoverCursor: string;
  25779. /** Gets the list of actions */
  25780. actions: IAction[];
  25781. /**
  25782. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25783. */
  25784. isRecursive: boolean;
  25785. /**
  25786. * Releases all associated resources
  25787. */
  25788. abstract dispose(): void;
  25789. /**
  25790. * Does this action manager has pointer triggers
  25791. */
  25792. abstract readonly hasPointerTriggers: boolean;
  25793. /**
  25794. * Does this action manager has pick triggers
  25795. */
  25796. abstract readonly hasPickTriggers: boolean;
  25797. /**
  25798. * Process a specific trigger
  25799. * @param trigger defines the trigger to process
  25800. * @param evt defines the event details to be processed
  25801. */
  25802. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25803. /**
  25804. * Does this action manager handles actions of any of the given triggers
  25805. * @param triggers defines the triggers to be tested
  25806. * @return a boolean indicating whether one (or more) of the triggers is handled
  25807. */
  25808. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25809. /**
  25810. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25811. * speed.
  25812. * @param triggerA defines the trigger to be tested
  25813. * @param triggerB defines the trigger to be tested
  25814. * @return a boolean indicating whether one (or more) of the triggers is handled
  25815. */
  25816. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25817. /**
  25818. * Does this action manager handles actions of a given trigger
  25819. * @param trigger defines the trigger to be tested
  25820. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25821. * @return whether the trigger is handled
  25822. */
  25823. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25824. /**
  25825. * Serialize this manager to a JSON object
  25826. * @param name defines the property name to store this manager
  25827. * @returns a JSON representation of this manager
  25828. */
  25829. abstract serialize(name: string): any;
  25830. /**
  25831. * Registers an action to this action manager
  25832. * @param action defines the action to be registered
  25833. * @return the action amended (prepared) after registration
  25834. */
  25835. abstract registerAction(action: IAction): Nullable<IAction>;
  25836. /**
  25837. * Unregisters an action to this action manager
  25838. * @param action defines the action to be unregistered
  25839. * @return a boolean indicating whether the action has been unregistered
  25840. */
  25841. abstract unregisterAction(action: IAction): Boolean;
  25842. /**
  25843. * Does exist one action manager with at least one trigger
  25844. **/
  25845. static readonly HasTriggers: boolean;
  25846. /**
  25847. * Does exist one action manager with at least one pick trigger
  25848. **/
  25849. static readonly HasPickTriggers: boolean;
  25850. /**
  25851. * Does exist one action manager that handles actions of a given trigger
  25852. * @param trigger defines the trigger to be tested
  25853. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25854. **/
  25855. static HasSpecificTrigger(trigger: number): boolean;
  25856. }
  25857. }
  25858. declare module "babylonjs/node" {
  25859. import { Scene } from "babylonjs/scene";
  25860. import { Nullable } from "babylonjs/types";
  25861. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25862. import { Engine } from "babylonjs/Engines/engine";
  25863. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25864. import { Observable } from "babylonjs/Misc/observable";
  25865. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25866. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25867. import { Animatable } from "babylonjs/Animations/animatable";
  25868. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25869. import { Animation } from "babylonjs/Animations/animation";
  25870. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25872. /**
  25873. * Defines how a node can be built from a string name.
  25874. */
  25875. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25876. /**
  25877. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25878. */
  25879. export class Node implements IBehaviorAware<Node> {
  25880. /** @hidden */
  25881. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25882. private static _NodeConstructors;
  25883. /**
  25884. * Add a new node constructor
  25885. * @param type defines the type name of the node to construct
  25886. * @param constructorFunc defines the constructor function
  25887. */
  25888. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25889. /**
  25890. * Returns a node constructor based on type name
  25891. * @param type defines the type name
  25892. * @param name defines the new node name
  25893. * @param scene defines the hosting scene
  25894. * @param options defines optional options to transmit to constructors
  25895. * @returns the new constructor or null
  25896. */
  25897. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25898. /**
  25899. * Gets or sets the name of the node
  25900. */
  25901. name: string;
  25902. /**
  25903. * Gets or sets the id of the node
  25904. */
  25905. id: string;
  25906. /**
  25907. * Gets or sets the unique id of the node
  25908. */
  25909. uniqueId: number;
  25910. /**
  25911. * Gets or sets a string used to store user defined state for the node
  25912. */
  25913. state: string;
  25914. /**
  25915. * Gets or sets an object used to store user defined information for the node
  25916. */
  25917. metadata: any;
  25918. /**
  25919. * For internal use only. Please do not use.
  25920. */
  25921. reservedDataStore: any;
  25922. /**
  25923. * List of inspectable custom properties (used by the Inspector)
  25924. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25925. */
  25926. inspectableCustomProperties: IInspectable[];
  25927. /**
  25928. * Gets or sets a boolean used to define if the node must be serialized
  25929. */
  25930. doNotSerialize: boolean;
  25931. /** @hidden */
  25932. _isDisposed: boolean;
  25933. /**
  25934. * Gets a list of Animations associated with the node
  25935. */
  25936. animations: import("babylonjs/Animations/animation").Animation[];
  25937. protected _ranges: {
  25938. [name: string]: Nullable<AnimationRange>;
  25939. };
  25940. /**
  25941. * Callback raised when the node is ready to be used
  25942. */
  25943. onReady: Nullable<(node: Node) => void>;
  25944. private _isEnabled;
  25945. private _isParentEnabled;
  25946. private _isReady;
  25947. /** @hidden */
  25948. _currentRenderId: number;
  25949. private _parentUpdateId;
  25950. /** @hidden */
  25951. _childUpdateId: number;
  25952. /** @hidden */
  25953. _waitingParentId: Nullable<string>;
  25954. /** @hidden */
  25955. _scene: Scene;
  25956. /** @hidden */
  25957. _cache: any;
  25958. private _parentNode;
  25959. private _children;
  25960. /** @hidden */
  25961. _worldMatrix: Matrix;
  25962. /** @hidden */
  25963. _worldMatrixDeterminant: number;
  25964. /** @hidden */
  25965. _worldMatrixDeterminantIsDirty: boolean;
  25966. /** @hidden */
  25967. private _sceneRootNodesIndex;
  25968. /**
  25969. * Gets a boolean indicating if the node has been disposed
  25970. * @returns true if the node was disposed
  25971. */
  25972. isDisposed(): boolean;
  25973. /**
  25974. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25975. * @see https://doc.babylonjs.com/how_to/parenting
  25976. */
  25977. parent: Nullable<Node>;
  25978. private addToSceneRootNodes;
  25979. private removeFromSceneRootNodes;
  25980. private _animationPropertiesOverride;
  25981. /**
  25982. * Gets or sets the animation properties override
  25983. */
  25984. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25985. /**
  25986. * Gets a string idenfifying the name of the class
  25987. * @returns "Node" string
  25988. */
  25989. getClassName(): string;
  25990. /** @hidden */
  25991. readonly _isNode: boolean;
  25992. /**
  25993. * An event triggered when the mesh is disposed
  25994. */
  25995. onDisposeObservable: Observable<Node>;
  25996. private _onDisposeObserver;
  25997. /**
  25998. * Sets a callback that will be raised when the node will be disposed
  25999. */
  26000. onDispose: () => void;
  26001. /**
  26002. * Creates a new Node
  26003. * @param name the name and id to be given to this node
  26004. * @param scene the scene this node will be added to
  26005. * @param addToRootNodes the node will be added to scene.rootNodes
  26006. */
  26007. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26008. /**
  26009. * Gets the scene of the node
  26010. * @returns a scene
  26011. */
  26012. getScene(): Scene;
  26013. /**
  26014. * Gets the engine of the node
  26015. * @returns a Engine
  26016. */
  26017. getEngine(): Engine;
  26018. private _behaviors;
  26019. /**
  26020. * Attach a behavior to the node
  26021. * @see http://doc.babylonjs.com/features/behaviour
  26022. * @param behavior defines the behavior to attach
  26023. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26024. * @returns the current Node
  26025. */
  26026. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26027. /**
  26028. * Remove an attached behavior
  26029. * @see http://doc.babylonjs.com/features/behaviour
  26030. * @param behavior defines the behavior to attach
  26031. * @returns the current Node
  26032. */
  26033. removeBehavior(behavior: Behavior<Node>): Node;
  26034. /**
  26035. * Gets the list of attached behaviors
  26036. * @see http://doc.babylonjs.com/features/behaviour
  26037. */
  26038. readonly behaviors: Behavior<Node>[];
  26039. /**
  26040. * Gets an attached behavior by name
  26041. * @param name defines the name of the behavior to look for
  26042. * @see http://doc.babylonjs.com/features/behaviour
  26043. * @returns null if behavior was not found else the requested behavior
  26044. */
  26045. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26046. /**
  26047. * Returns the latest update of the World matrix
  26048. * @returns a Matrix
  26049. */
  26050. getWorldMatrix(): Matrix;
  26051. /** @hidden */
  26052. _getWorldMatrixDeterminant(): number;
  26053. /**
  26054. * Returns directly the latest state of the mesh World matrix.
  26055. * A Matrix is returned.
  26056. */
  26057. readonly worldMatrixFromCache: Matrix;
  26058. /** @hidden */
  26059. _initCache(): void;
  26060. /** @hidden */
  26061. updateCache(force?: boolean): void;
  26062. /** @hidden */
  26063. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26064. /** @hidden */
  26065. _updateCache(ignoreParentClass?: boolean): void;
  26066. /** @hidden */
  26067. _isSynchronized(): boolean;
  26068. /** @hidden */
  26069. _markSyncedWithParent(): void;
  26070. /** @hidden */
  26071. isSynchronizedWithParent(): boolean;
  26072. /** @hidden */
  26073. isSynchronized(): boolean;
  26074. /**
  26075. * Is this node ready to be used/rendered
  26076. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26077. * @return true if the node is ready
  26078. */
  26079. isReady(completeCheck?: boolean): boolean;
  26080. /**
  26081. * Is this node enabled?
  26082. * 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
  26083. * @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
  26084. * @return whether this node (and its parent) is enabled
  26085. */
  26086. isEnabled(checkAncestors?: boolean): boolean;
  26087. /** @hidden */
  26088. protected _syncParentEnabledState(): void;
  26089. /**
  26090. * Set the enabled state of this node
  26091. * @param value defines the new enabled state
  26092. */
  26093. setEnabled(value: boolean): void;
  26094. /**
  26095. * Is this node a descendant of the given node?
  26096. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26097. * @param ancestor defines the parent node to inspect
  26098. * @returns a boolean indicating if this node is a descendant of the given node
  26099. */
  26100. isDescendantOf(ancestor: Node): boolean;
  26101. /** @hidden */
  26102. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26103. /**
  26104. * Will return all nodes that have this node as ascendant
  26105. * @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
  26106. * @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
  26107. * @return all children nodes of all types
  26108. */
  26109. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26110. /**
  26111. * Get all child-meshes of this node
  26112. * @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)
  26113. * @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
  26114. * @returns an array of AbstractMesh
  26115. */
  26116. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26117. /**
  26118. * Get all direct children of this node
  26119. * @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
  26120. * @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)
  26121. * @returns an array of Node
  26122. */
  26123. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26124. /** @hidden */
  26125. _setReady(state: boolean): void;
  26126. /**
  26127. * Get an animation by name
  26128. * @param name defines the name of the animation to look for
  26129. * @returns null if not found else the requested animation
  26130. */
  26131. getAnimationByName(name: string): Nullable<Animation>;
  26132. /**
  26133. * Creates an animation range for this node
  26134. * @param name defines the name of the range
  26135. * @param from defines the starting key
  26136. * @param to defines the end key
  26137. */
  26138. createAnimationRange(name: string, from: number, to: number): void;
  26139. /**
  26140. * Delete a specific animation range
  26141. * @param name defines the name of the range to delete
  26142. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26143. */
  26144. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26145. /**
  26146. * Get an animation range by name
  26147. * @param name defines the name of the animation range to look for
  26148. * @returns null if not found else the requested animation range
  26149. */
  26150. getAnimationRange(name: string): Nullable<AnimationRange>;
  26151. /**
  26152. * Gets the list of all animation ranges defined on this node
  26153. * @returns an array
  26154. */
  26155. getAnimationRanges(): Nullable<AnimationRange>[];
  26156. /**
  26157. * Will start the animation sequence
  26158. * @param name defines the range frames for animation sequence
  26159. * @param loop defines if the animation should loop (false by default)
  26160. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26161. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26162. * @returns the object created for this animation. If range does not exist, it will return null
  26163. */
  26164. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26165. /**
  26166. * Serialize animation ranges into a JSON compatible object
  26167. * @returns serialization object
  26168. */
  26169. serializeAnimationRanges(): any;
  26170. /**
  26171. * Computes the world matrix of the node
  26172. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26173. * @returns the world matrix
  26174. */
  26175. computeWorldMatrix(force?: boolean): Matrix;
  26176. /**
  26177. * Releases resources associated with this node.
  26178. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26179. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26180. */
  26181. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26182. /**
  26183. * Parse animation range data from a serialization object and store them into a given node
  26184. * @param node defines where to store the animation ranges
  26185. * @param parsedNode defines the serialization object to read data from
  26186. * @param scene defines the hosting scene
  26187. */
  26188. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26189. /**
  26190. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26191. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26192. * @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
  26193. * @returns the new bounding vectors
  26194. */
  26195. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26196. min: Vector3;
  26197. max: Vector3;
  26198. };
  26199. }
  26200. }
  26201. declare module "babylonjs/Animations/animation" {
  26202. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26203. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26204. import { Nullable } from "babylonjs/types";
  26205. import { Scene } from "babylonjs/scene";
  26206. import { IAnimatable } from "babylonjs/Misc/tools";
  26207. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26208. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26209. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26210. import { Node } from "babylonjs/node";
  26211. import { Animatable } from "babylonjs/Animations/animatable";
  26212. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26213. /**
  26214. * @hidden
  26215. */
  26216. export class _IAnimationState {
  26217. key: number;
  26218. repeatCount: number;
  26219. workValue?: any;
  26220. loopMode?: number;
  26221. offsetValue?: any;
  26222. highLimitValue?: any;
  26223. }
  26224. /**
  26225. * Class used to store any kind of animation
  26226. */
  26227. export class Animation {
  26228. /**Name of the animation */
  26229. name: string;
  26230. /**Property to animate */
  26231. targetProperty: string;
  26232. /**The frames per second of the animation */
  26233. framePerSecond: number;
  26234. /**The data type of the animation */
  26235. dataType: number;
  26236. /**The loop mode of the animation */
  26237. loopMode?: number | undefined;
  26238. /**Specifies if blending should be enabled */
  26239. enableBlending?: boolean | undefined;
  26240. /**
  26241. * Use matrix interpolation instead of using direct key value when animating matrices
  26242. */
  26243. static AllowMatricesInterpolation: boolean;
  26244. /**
  26245. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26246. */
  26247. static AllowMatrixDecomposeForInterpolation: boolean;
  26248. /**
  26249. * Stores the key frames of the animation
  26250. */
  26251. private _keys;
  26252. /**
  26253. * Stores the easing function of the animation
  26254. */
  26255. private _easingFunction;
  26256. /**
  26257. * @hidden Internal use only
  26258. */
  26259. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26260. /**
  26261. * The set of event that will be linked to this animation
  26262. */
  26263. private _events;
  26264. /**
  26265. * Stores an array of target property paths
  26266. */
  26267. targetPropertyPath: string[];
  26268. /**
  26269. * Stores the blending speed of the animation
  26270. */
  26271. blendingSpeed: number;
  26272. /**
  26273. * Stores the animation ranges for the animation
  26274. */
  26275. private _ranges;
  26276. /**
  26277. * @hidden Internal use
  26278. */
  26279. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26280. /**
  26281. * Sets up an animation
  26282. * @param property The property to animate
  26283. * @param animationType The animation type to apply
  26284. * @param framePerSecond The frames per second of the animation
  26285. * @param easingFunction The easing function used in the animation
  26286. * @returns The created animation
  26287. */
  26288. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26289. /**
  26290. * Create and start an animation on a node
  26291. * @param name defines the name of the global animation that will be run on all nodes
  26292. * @param node defines the root node where the animation will take place
  26293. * @param targetProperty defines property to animate
  26294. * @param framePerSecond defines the number of frame per second yo use
  26295. * @param totalFrame defines the number of frames in total
  26296. * @param from defines the initial value
  26297. * @param to defines the final value
  26298. * @param loopMode defines which loop mode you want to use (off by default)
  26299. * @param easingFunction defines the easing function to use (linear by default)
  26300. * @param onAnimationEnd defines the callback to call when animation end
  26301. * @returns the animatable created for this animation
  26302. */
  26303. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26304. /**
  26305. * Create and start an animation on a node and its descendants
  26306. * @param name defines the name of the global animation that will be run on all nodes
  26307. * @param node defines the root node where the animation will take place
  26308. * @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
  26309. * @param targetProperty defines property to animate
  26310. * @param framePerSecond defines the number of frame per second to use
  26311. * @param totalFrame defines the number of frames in total
  26312. * @param from defines the initial value
  26313. * @param to defines the final value
  26314. * @param loopMode defines which loop mode you want to use (off by default)
  26315. * @param easingFunction defines the easing function to use (linear by default)
  26316. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26317. * @returns the list of animatables created for all nodes
  26318. * @example https://www.babylonjs-playground.com/#MH0VLI
  26319. */
  26320. 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[]>;
  26321. /**
  26322. * Creates a new animation, merges it with the existing animations and starts it
  26323. * @param name Name of the animation
  26324. * @param node Node which contains the scene that begins the animations
  26325. * @param targetProperty Specifies which property to animate
  26326. * @param framePerSecond The frames per second of the animation
  26327. * @param totalFrame The total number of frames
  26328. * @param from The frame at the beginning of the animation
  26329. * @param to The frame at the end of the animation
  26330. * @param loopMode Specifies the loop mode of the animation
  26331. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26332. * @param onAnimationEnd Callback to run once the animation is complete
  26333. * @returns Nullable animation
  26334. */
  26335. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26336. /**
  26337. * Transition property of an host to the target Value
  26338. * @param property The property to transition
  26339. * @param targetValue The target Value of the property
  26340. * @param host The object where the property to animate belongs
  26341. * @param scene Scene used to run the animation
  26342. * @param frameRate Framerate (in frame/s) to use
  26343. * @param transition The transition type we want to use
  26344. * @param duration The duration of the animation, in milliseconds
  26345. * @param onAnimationEnd Callback trigger at the end of the animation
  26346. * @returns Nullable animation
  26347. */
  26348. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26349. /**
  26350. * Return the array of runtime animations currently using this animation
  26351. */
  26352. readonly runtimeAnimations: RuntimeAnimation[];
  26353. /**
  26354. * Specifies if any of the runtime animations are currently running
  26355. */
  26356. readonly hasRunningRuntimeAnimations: boolean;
  26357. /**
  26358. * Initializes the animation
  26359. * @param name Name of the animation
  26360. * @param targetProperty Property to animate
  26361. * @param framePerSecond The frames per second of the animation
  26362. * @param dataType The data type of the animation
  26363. * @param loopMode The loop mode of the animation
  26364. * @param enableBlending Specifies if blending should be enabled
  26365. */
  26366. constructor(
  26367. /**Name of the animation */
  26368. name: string,
  26369. /**Property to animate */
  26370. targetProperty: string,
  26371. /**The frames per second of the animation */
  26372. framePerSecond: number,
  26373. /**The data type of the animation */
  26374. dataType: number,
  26375. /**The loop mode of the animation */
  26376. loopMode?: number | undefined,
  26377. /**Specifies if blending should be enabled */
  26378. enableBlending?: boolean | undefined);
  26379. /**
  26380. * Converts the animation to a string
  26381. * @param fullDetails support for multiple levels of logging within scene loading
  26382. * @returns String form of the animation
  26383. */
  26384. toString(fullDetails?: boolean): string;
  26385. /**
  26386. * Add an event to this animation
  26387. * @param event Event to add
  26388. */
  26389. addEvent(event: AnimationEvent): void;
  26390. /**
  26391. * Remove all events found at the given frame
  26392. * @param frame The frame to remove events from
  26393. */
  26394. removeEvents(frame: number): void;
  26395. /**
  26396. * Retrieves all the events from the animation
  26397. * @returns Events from the animation
  26398. */
  26399. getEvents(): AnimationEvent[];
  26400. /**
  26401. * Creates an animation range
  26402. * @param name Name of the animation range
  26403. * @param from Starting frame of the animation range
  26404. * @param to Ending frame of the animation
  26405. */
  26406. createRange(name: string, from: number, to: number): void;
  26407. /**
  26408. * Deletes an animation range by name
  26409. * @param name Name of the animation range to delete
  26410. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26411. */
  26412. deleteRange(name: string, deleteFrames?: boolean): void;
  26413. /**
  26414. * Gets the animation range by name, or null if not defined
  26415. * @param name Name of the animation range
  26416. * @returns Nullable animation range
  26417. */
  26418. getRange(name: string): Nullable<AnimationRange>;
  26419. /**
  26420. * Gets the key frames from the animation
  26421. * @returns The key frames of the animation
  26422. */
  26423. getKeys(): Array<IAnimationKey>;
  26424. /**
  26425. * Gets the highest frame rate of the animation
  26426. * @returns Highest frame rate of the animation
  26427. */
  26428. getHighestFrame(): number;
  26429. /**
  26430. * Gets the easing function of the animation
  26431. * @returns Easing function of the animation
  26432. */
  26433. getEasingFunction(): IEasingFunction;
  26434. /**
  26435. * Sets the easing function of the animation
  26436. * @param easingFunction A custom mathematical formula for animation
  26437. */
  26438. setEasingFunction(easingFunction: EasingFunction): void;
  26439. /**
  26440. * Interpolates a scalar linearly
  26441. * @param startValue Start value of the animation curve
  26442. * @param endValue End value of the animation curve
  26443. * @param gradient Scalar amount to interpolate
  26444. * @returns Interpolated scalar value
  26445. */
  26446. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26447. /**
  26448. * Interpolates a scalar cubically
  26449. * @param startValue Start value of the animation curve
  26450. * @param outTangent End tangent of the animation
  26451. * @param endValue End value of the animation curve
  26452. * @param inTangent Start tangent of the animation curve
  26453. * @param gradient Scalar amount to interpolate
  26454. * @returns Interpolated scalar value
  26455. */
  26456. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26457. /**
  26458. * Interpolates a quaternion using a spherical linear interpolation
  26459. * @param startValue Start value of the animation curve
  26460. * @param endValue End value of the animation curve
  26461. * @param gradient Scalar amount to interpolate
  26462. * @returns Interpolated quaternion value
  26463. */
  26464. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26465. /**
  26466. * Interpolates a quaternion cubically
  26467. * @param startValue Start value of the animation curve
  26468. * @param outTangent End tangent of the animation curve
  26469. * @param endValue End value of the animation curve
  26470. * @param inTangent Start tangent of the animation curve
  26471. * @param gradient Scalar amount to interpolate
  26472. * @returns Interpolated quaternion value
  26473. */
  26474. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26475. /**
  26476. * Interpolates a Vector3 linearl
  26477. * @param startValue Start value of the animation curve
  26478. * @param endValue End value of the animation curve
  26479. * @param gradient Scalar amount to interpolate
  26480. * @returns Interpolated scalar value
  26481. */
  26482. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26483. /**
  26484. * Interpolates a Vector3 cubically
  26485. * @param startValue Start value of the animation curve
  26486. * @param outTangent End tangent of the animation
  26487. * @param endValue End value of the animation curve
  26488. * @param inTangent Start tangent of the animation curve
  26489. * @param gradient Scalar amount to interpolate
  26490. * @returns InterpolatedVector3 value
  26491. */
  26492. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26493. /**
  26494. * Interpolates a Vector2 linearly
  26495. * @param startValue Start value of the animation curve
  26496. * @param endValue End value of the animation curve
  26497. * @param gradient Scalar amount to interpolate
  26498. * @returns Interpolated Vector2 value
  26499. */
  26500. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26501. /**
  26502. * Interpolates a Vector2 cubically
  26503. * @param startValue Start value of the animation curve
  26504. * @param outTangent End tangent of the animation
  26505. * @param endValue End value of the animation curve
  26506. * @param inTangent Start tangent of the animation curve
  26507. * @param gradient Scalar amount to interpolate
  26508. * @returns Interpolated Vector2 value
  26509. */
  26510. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26511. /**
  26512. * Interpolates a size linearly
  26513. * @param startValue Start value of the animation curve
  26514. * @param endValue End value of the animation curve
  26515. * @param gradient Scalar amount to interpolate
  26516. * @returns Interpolated Size value
  26517. */
  26518. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26519. /**
  26520. * Interpolates a Color3 linearly
  26521. * @param startValue Start value of the animation curve
  26522. * @param endValue End value of the animation curve
  26523. * @param gradient Scalar amount to interpolate
  26524. * @returns Interpolated Color3 value
  26525. */
  26526. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26527. /**
  26528. * @hidden Internal use only
  26529. */
  26530. _getKeyValue(value: any): any;
  26531. /**
  26532. * @hidden Internal use only
  26533. */
  26534. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26535. /**
  26536. * Defines the function to use to interpolate matrices
  26537. * @param startValue defines the start matrix
  26538. * @param endValue defines the end matrix
  26539. * @param gradient defines the gradient between both matrices
  26540. * @param result defines an optional target matrix where to store the interpolation
  26541. * @returns the interpolated matrix
  26542. */
  26543. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26544. /**
  26545. * Makes a copy of the animation
  26546. * @returns Cloned animation
  26547. */
  26548. clone(): Animation;
  26549. /**
  26550. * Sets the key frames of the animation
  26551. * @param values The animation key frames to set
  26552. */
  26553. setKeys(values: Array<IAnimationKey>): void;
  26554. /**
  26555. * Serializes the animation to an object
  26556. * @returns Serialized object
  26557. */
  26558. serialize(): any;
  26559. /**
  26560. * Float animation type
  26561. */
  26562. private static _ANIMATIONTYPE_FLOAT;
  26563. /**
  26564. * Vector3 animation type
  26565. */
  26566. private static _ANIMATIONTYPE_VECTOR3;
  26567. /**
  26568. * Quaternion animation type
  26569. */
  26570. private static _ANIMATIONTYPE_QUATERNION;
  26571. /**
  26572. * Matrix animation type
  26573. */
  26574. private static _ANIMATIONTYPE_MATRIX;
  26575. /**
  26576. * Color3 animation type
  26577. */
  26578. private static _ANIMATIONTYPE_COLOR3;
  26579. /**
  26580. * Vector2 animation type
  26581. */
  26582. private static _ANIMATIONTYPE_VECTOR2;
  26583. /**
  26584. * Size animation type
  26585. */
  26586. private static _ANIMATIONTYPE_SIZE;
  26587. /**
  26588. * Relative Loop Mode
  26589. */
  26590. private static _ANIMATIONLOOPMODE_RELATIVE;
  26591. /**
  26592. * Cycle Loop Mode
  26593. */
  26594. private static _ANIMATIONLOOPMODE_CYCLE;
  26595. /**
  26596. * Constant Loop Mode
  26597. */
  26598. private static _ANIMATIONLOOPMODE_CONSTANT;
  26599. /**
  26600. * Get the float animation type
  26601. */
  26602. static readonly ANIMATIONTYPE_FLOAT: number;
  26603. /**
  26604. * Get the Vector3 animation type
  26605. */
  26606. static readonly ANIMATIONTYPE_VECTOR3: number;
  26607. /**
  26608. * Get the Vector2 animation type
  26609. */
  26610. static readonly ANIMATIONTYPE_VECTOR2: number;
  26611. /**
  26612. * Get the Size animation type
  26613. */
  26614. static readonly ANIMATIONTYPE_SIZE: number;
  26615. /**
  26616. * Get the Quaternion animation type
  26617. */
  26618. static readonly ANIMATIONTYPE_QUATERNION: number;
  26619. /**
  26620. * Get the Matrix animation type
  26621. */
  26622. static readonly ANIMATIONTYPE_MATRIX: number;
  26623. /**
  26624. * Get the Color3 animation type
  26625. */
  26626. static readonly ANIMATIONTYPE_COLOR3: number;
  26627. /**
  26628. * Get the Relative Loop Mode
  26629. */
  26630. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26631. /**
  26632. * Get the Cycle Loop Mode
  26633. */
  26634. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26635. /**
  26636. * Get the Constant Loop Mode
  26637. */
  26638. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26639. /** @hidden */
  26640. static _UniversalLerp(left: any, right: any, amount: number): any;
  26641. /**
  26642. * Parses an animation object and creates an animation
  26643. * @param parsedAnimation Parsed animation object
  26644. * @returns Animation object
  26645. */
  26646. static Parse(parsedAnimation: any): Animation;
  26647. /**
  26648. * Appends the serialized animations from the source animations
  26649. * @param source Source containing the animations
  26650. * @param destination Target to store the animations
  26651. */
  26652. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26653. }
  26654. }
  26655. declare module "babylonjs/Materials/Textures/baseTexture" {
  26656. import { Observable } from "babylonjs/Misc/observable";
  26657. import { IAnimatable } from "babylonjs/Misc/tools";
  26658. import { Nullable } from "babylonjs/types";
  26659. import { Scene } from "babylonjs/scene";
  26660. import { Matrix, ISize } from "babylonjs/Maths/math";
  26661. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26662. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26663. /**
  26664. * Base class of all the textures in babylon.
  26665. * It groups all the common properties the materials, post process, lights... might need
  26666. * in order to make a correct use of the texture.
  26667. */
  26668. export class BaseTexture implements IAnimatable {
  26669. /**
  26670. * Default anisotropic filtering level for the application.
  26671. * It is set to 4 as a good tradeoff between perf and quality.
  26672. */
  26673. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26674. /**
  26675. * Gets or sets the unique id of the texture
  26676. */
  26677. uniqueId: number;
  26678. /**
  26679. * Define the name of the texture.
  26680. */
  26681. name: string;
  26682. /**
  26683. * Gets or sets an object used to store user defined information.
  26684. */
  26685. metadata: any;
  26686. /**
  26687. * For internal use only. Please do not use.
  26688. */
  26689. reservedDataStore: any;
  26690. private _hasAlpha;
  26691. /**
  26692. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26693. */
  26694. hasAlpha: boolean;
  26695. /**
  26696. * Defines if the alpha value should be determined via the rgb values.
  26697. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26698. */
  26699. getAlphaFromRGB: boolean;
  26700. /**
  26701. * Intensity or strength of the texture.
  26702. * It is commonly used by materials to fine tune the intensity of the texture
  26703. */
  26704. level: number;
  26705. /**
  26706. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26707. * This is part of the texture as textures usually maps to one uv set.
  26708. */
  26709. coordinatesIndex: number;
  26710. private _coordinatesMode;
  26711. /**
  26712. * How a texture is mapped.
  26713. *
  26714. * | Value | Type | Description |
  26715. * | ----- | ----------------------------------- | ----------- |
  26716. * | 0 | EXPLICIT_MODE | |
  26717. * | 1 | SPHERICAL_MODE | |
  26718. * | 2 | PLANAR_MODE | |
  26719. * | 3 | CUBIC_MODE | |
  26720. * | 4 | PROJECTION_MODE | |
  26721. * | 5 | SKYBOX_MODE | |
  26722. * | 6 | INVCUBIC_MODE | |
  26723. * | 7 | EQUIRECTANGULAR_MODE | |
  26724. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26725. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26726. */
  26727. coordinatesMode: number;
  26728. /**
  26729. * | Value | Type | Description |
  26730. * | ----- | ------------------ | ----------- |
  26731. * | 0 | CLAMP_ADDRESSMODE | |
  26732. * | 1 | WRAP_ADDRESSMODE | |
  26733. * | 2 | MIRROR_ADDRESSMODE | |
  26734. */
  26735. wrapU: number;
  26736. /**
  26737. * | Value | Type | Description |
  26738. * | ----- | ------------------ | ----------- |
  26739. * | 0 | CLAMP_ADDRESSMODE | |
  26740. * | 1 | WRAP_ADDRESSMODE | |
  26741. * | 2 | MIRROR_ADDRESSMODE | |
  26742. */
  26743. wrapV: number;
  26744. /**
  26745. * | Value | Type | Description |
  26746. * | ----- | ------------------ | ----------- |
  26747. * | 0 | CLAMP_ADDRESSMODE | |
  26748. * | 1 | WRAP_ADDRESSMODE | |
  26749. * | 2 | MIRROR_ADDRESSMODE | |
  26750. */
  26751. wrapR: number;
  26752. /**
  26753. * With compliant hardware and browser (supporting anisotropic filtering)
  26754. * this defines the level of anisotropic filtering in the texture.
  26755. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26756. */
  26757. anisotropicFilteringLevel: number;
  26758. /**
  26759. * Define if the texture is a cube texture or if false a 2d texture.
  26760. */
  26761. isCube: boolean;
  26762. /**
  26763. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26764. */
  26765. is3D: boolean;
  26766. /**
  26767. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26768. * HDR texture are usually stored in linear space.
  26769. * This only impacts the PBR and Background materials
  26770. */
  26771. gammaSpace: boolean;
  26772. /**
  26773. * Gets whether or not the texture contains RGBD data.
  26774. */
  26775. readonly isRGBD: boolean;
  26776. /**
  26777. * Is Z inverted in the texture (useful in a cube texture).
  26778. */
  26779. invertZ: boolean;
  26780. /**
  26781. * Are mip maps generated for this texture or not.
  26782. */
  26783. readonly noMipmap: boolean;
  26784. /**
  26785. * @hidden
  26786. */
  26787. lodLevelInAlpha: boolean;
  26788. /**
  26789. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26790. */
  26791. lodGenerationOffset: number;
  26792. /**
  26793. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26794. */
  26795. lodGenerationScale: number;
  26796. /**
  26797. * Define if the texture is a render target.
  26798. */
  26799. isRenderTarget: boolean;
  26800. /**
  26801. * Define the unique id of the texture in the scene.
  26802. */
  26803. readonly uid: string;
  26804. /**
  26805. * Return a string representation of the texture.
  26806. * @returns the texture as a string
  26807. */
  26808. toString(): string;
  26809. /**
  26810. * Get the class name of the texture.
  26811. * @returns "BaseTexture"
  26812. */
  26813. getClassName(): string;
  26814. /**
  26815. * Define the list of animation attached to the texture.
  26816. */
  26817. animations: import("babylonjs/Animations/animation").Animation[];
  26818. /**
  26819. * An event triggered when the texture is disposed.
  26820. */
  26821. onDisposeObservable: Observable<BaseTexture>;
  26822. private _onDisposeObserver;
  26823. /**
  26824. * Callback triggered when the texture has been disposed.
  26825. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26826. */
  26827. onDispose: () => void;
  26828. /**
  26829. * Define the current state of the loading sequence when in delayed load mode.
  26830. */
  26831. delayLoadState: number;
  26832. private _scene;
  26833. /** @hidden */
  26834. _texture: Nullable<InternalTexture>;
  26835. private _uid;
  26836. /**
  26837. * Define if the texture is preventinga material to render or not.
  26838. * If not and the texture is not ready, the engine will use a default black texture instead.
  26839. */
  26840. readonly isBlocking: boolean;
  26841. /**
  26842. * Instantiates a new BaseTexture.
  26843. * Base class of all the textures in babylon.
  26844. * It groups all the common properties the materials, post process, lights... might need
  26845. * in order to make a correct use of the texture.
  26846. * @param scene Define the scene the texture blongs to
  26847. */
  26848. constructor(scene: Nullable<Scene>);
  26849. /**
  26850. * Get the scene the texture belongs to.
  26851. * @returns the scene or null if undefined
  26852. */
  26853. getScene(): Nullable<Scene>;
  26854. /**
  26855. * Get the texture transform matrix used to offset tile the texture for istance.
  26856. * @returns the transformation matrix
  26857. */
  26858. getTextureMatrix(): Matrix;
  26859. /**
  26860. * Get the texture reflection matrix used to rotate/transform the reflection.
  26861. * @returns the reflection matrix
  26862. */
  26863. getReflectionTextureMatrix(): Matrix;
  26864. /**
  26865. * Get the underlying lower level texture from Babylon.
  26866. * @returns the insternal texture
  26867. */
  26868. getInternalTexture(): Nullable<InternalTexture>;
  26869. /**
  26870. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26871. * @returns true if ready or not blocking
  26872. */
  26873. isReadyOrNotBlocking(): boolean;
  26874. /**
  26875. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26876. * @returns true if fully ready
  26877. */
  26878. isReady(): boolean;
  26879. private _cachedSize;
  26880. /**
  26881. * Get the size of the texture.
  26882. * @returns the texture size.
  26883. */
  26884. getSize(): ISize;
  26885. /**
  26886. * Get the base size of the texture.
  26887. * It can be different from the size if the texture has been resized for POT for instance
  26888. * @returns the base size
  26889. */
  26890. getBaseSize(): ISize;
  26891. /**
  26892. * Update the sampling mode of the texture.
  26893. * Default is Trilinear mode.
  26894. *
  26895. * | Value | Type | Description |
  26896. * | ----- | ------------------ | ----------- |
  26897. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26898. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26899. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26900. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26901. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26902. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26903. * | 7 | NEAREST_LINEAR | |
  26904. * | 8 | NEAREST_NEAREST | |
  26905. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26906. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26907. * | 11 | LINEAR_LINEAR | |
  26908. * | 12 | LINEAR_NEAREST | |
  26909. *
  26910. * > _mag_: magnification filter (close to the viewer)
  26911. * > _min_: minification filter (far from the viewer)
  26912. * > _mip_: filter used between mip map levels
  26913. *@param samplingMode Define the new sampling mode of the texture
  26914. */
  26915. updateSamplingMode(samplingMode: number): void;
  26916. /**
  26917. * Scales the texture if is `canRescale()`
  26918. * @param ratio the resize factor we want to use to rescale
  26919. */
  26920. scale(ratio: number): void;
  26921. /**
  26922. * Get if the texture can rescale.
  26923. */
  26924. readonly canRescale: boolean;
  26925. /** @hidden */
  26926. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26927. /** @hidden */
  26928. _rebuild(): void;
  26929. /**
  26930. * Triggers the load sequence in delayed load mode.
  26931. */
  26932. delayLoad(): void;
  26933. /**
  26934. * Clones the texture.
  26935. * @returns the cloned texture
  26936. */
  26937. clone(): Nullable<BaseTexture>;
  26938. /**
  26939. * Get the texture underlying type (INT, FLOAT...)
  26940. */
  26941. readonly textureType: number;
  26942. /**
  26943. * Get the texture underlying format (RGB, RGBA...)
  26944. */
  26945. readonly textureFormat: number;
  26946. /**
  26947. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26948. * This will returns an RGBA array buffer containing either in values (0-255) or
  26949. * float values (0-1) depending of the underlying buffer type.
  26950. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26951. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26952. * @param buffer defines a user defined buffer to fill with data (can be null)
  26953. * @returns The Array buffer containing the pixels data.
  26954. */
  26955. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26956. /**
  26957. * Release and destroy the underlying lower level texture aka internalTexture.
  26958. */
  26959. releaseInternalTexture(): void;
  26960. /**
  26961. * Get the polynomial representation of the texture data.
  26962. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26963. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26964. */
  26965. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26966. /** @hidden */
  26967. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26968. /** @hidden */
  26969. readonly _lodTextureMid: Nullable<BaseTexture>;
  26970. /** @hidden */
  26971. readonly _lodTextureLow: Nullable<BaseTexture>;
  26972. /**
  26973. * Dispose the texture and release its associated resources.
  26974. */
  26975. dispose(): void;
  26976. /**
  26977. * Serialize the texture into a JSON representation that can be parsed later on.
  26978. * @returns the JSON representation of the texture
  26979. */
  26980. serialize(): any;
  26981. /**
  26982. * Helper function to be called back once a list of texture contains only ready textures.
  26983. * @param textures Define the list of textures to wait for
  26984. * @param callback Define the callback triggered once the entire list will be ready
  26985. */
  26986. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26987. }
  26988. }
  26989. declare module "babylonjs/Materials/uniformBuffer" {
  26990. import { Nullable, FloatArray } from "babylonjs/types";
  26991. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26992. import { Engine } from "babylonjs/Engines/engine";
  26993. import { Effect } from "babylonjs/Materials/effect";
  26994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26995. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26996. /**
  26997. * Uniform buffer objects.
  26998. *
  26999. * Handles blocks of uniform on the GPU.
  27000. *
  27001. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27002. *
  27003. * For more information, please refer to :
  27004. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27005. */
  27006. export class UniformBuffer {
  27007. private _engine;
  27008. private _buffer;
  27009. private _data;
  27010. private _bufferData;
  27011. private _dynamic?;
  27012. private _uniformLocations;
  27013. private _uniformSizes;
  27014. private _uniformLocationPointer;
  27015. private _needSync;
  27016. private _noUBO;
  27017. private _currentEffect;
  27018. private static _MAX_UNIFORM_SIZE;
  27019. private static _tempBuffer;
  27020. /**
  27021. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27022. * This is dynamic to allow compat with webgl 1 and 2.
  27023. * You will need to pass the name of the uniform as well as the value.
  27024. */
  27025. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27026. /**
  27027. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27028. * This is dynamic to allow compat with webgl 1 and 2.
  27029. * You will need to pass the name of the uniform as well as the value.
  27030. */
  27031. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27032. /**
  27033. * Lambda to Update a single float in a uniform buffer.
  27034. * This is dynamic to allow compat with webgl 1 and 2.
  27035. * You will need to pass the name of the uniform as well as the value.
  27036. */
  27037. updateFloat: (name: string, x: number) => void;
  27038. /**
  27039. * Lambda to Update a vec2 of float in a uniform buffer.
  27040. * This is dynamic to allow compat with webgl 1 and 2.
  27041. * You will need to pass the name of the uniform as well as the value.
  27042. */
  27043. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27044. /**
  27045. * Lambda to Update a vec3 of float in a uniform buffer.
  27046. * This is dynamic to allow compat with webgl 1 and 2.
  27047. * You will need to pass the name of the uniform as well as the value.
  27048. */
  27049. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27050. /**
  27051. * Lambda to Update a vec4 of float in a uniform buffer.
  27052. * This is dynamic to allow compat with webgl 1 and 2.
  27053. * You will need to pass the name of the uniform as well as the value.
  27054. */
  27055. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27056. /**
  27057. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27058. * This is dynamic to allow compat with webgl 1 and 2.
  27059. * You will need to pass the name of the uniform as well as the value.
  27060. */
  27061. updateMatrix: (name: string, mat: Matrix) => void;
  27062. /**
  27063. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27064. * This is dynamic to allow compat with webgl 1 and 2.
  27065. * You will need to pass the name of the uniform as well as the value.
  27066. */
  27067. updateVector3: (name: string, vector: Vector3) => void;
  27068. /**
  27069. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27070. * This is dynamic to allow compat with webgl 1 and 2.
  27071. * You will need to pass the name of the uniform as well as the value.
  27072. */
  27073. updateVector4: (name: string, vector: Vector4) => void;
  27074. /**
  27075. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27076. * This is dynamic to allow compat with webgl 1 and 2.
  27077. * You will need to pass the name of the uniform as well as the value.
  27078. */
  27079. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27080. /**
  27081. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27082. * This is dynamic to allow compat with webgl 1 and 2.
  27083. * You will need to pass the name of the uniform as well as the value.
  27084. */
  27085. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27086. /**
  27087. * Instantiates a new Uniform buffer objects.
  27088. *
  27089. * Handles blocks of uniform on the GPU.
  27090. *
  27091. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27092. *
  27093. * For more information, please refer to :
  27094. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27095. * @param engine Define the engine the buffer is associated with
  27096. * @param data Define the data contained in the buffer
  27097. * @param dynamic Define if the buffer is updatable
  27098. */
  27099. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27100. /**
  27101. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27102. * or just falling back on setUniformXXX calls.
  27103. */
  27104. readonly useUbo: boolean;
  27105. /**
  27106. * Indicates if the WebGL underlying uniform buffer is in sync
  27107. * with the javascript cache data.
  27108. */
  27109. readonly isSync: boolean;
  27110. /**
  27111. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27112. * Also, a dynamic UniformBuffer will disable cache verification and always
  27113. * update the underlying WebGL uniform buffer to the GPU.
  27114. * @returns if Dynamic, otherwise false
  27115. */
  27116. isDynamic(): boolean;
  27117. /**
  27118. * The data cache on JS side.
  27119. * @returns the underlying data as a float array
  27120. */
  27121. getData(): Float32Array;
  27122. /**
  27123. * The underlying WebGL Uniform buffer.
  27124. * @returns the webgl buffer
  27125. */
  27126. getBuffer(): Nullable<DataBuffer>;
  27127. /**
  27128. * std140 layout specifies how to align data within an UBO structure.
  27129. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27130. * for specs.
  27131. */
  27132. private _fillAlignment;
  27133. /**
  27134. * Adds an uniform in the buffer.
  27135. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27136. * for the layout to be correct !
  27137. * @param name Name of the uniform, as used in the uniform block in the shader.
  27138. * @param size Data size, or data directly.
  27139. */
  27140. addUniform(name: string, size: number | number[]): void;
  27141. /**
  27142. * Adds a Matrix 4x4 to the uniform buffer.
  27143. * @param name Name of the uniform, as used in the uniform block in the shader.
  27144. * @param mat A 4x4 matrix.
  27145. */
  27146. addMatrix(name: string, mat: Matrix): void;
  27147. /**
  27148. * Adds a vec2 to the uniform buffer.
  27149. * @param name Name of the uniform, as used in the uniform block in the shader.
  27150. * @param x Define the x component value of the vec2
  27151. * @param y Define the y component value of the vec2
  27152. */
  27153. addFloat2(name: string, x: number, y: number): void;
  27154. /**
  27155. * Adds a vec3 to the uniform buffer.
  27156. * @param name Name of the uniform, as used in the uniform block in the shader.
  27157. * @param x Define the x component value of the vec3
  27158. * @param y Define the y component value of the vec3
  27159. * @param z Define the z component value of the vec3
  27160. */
  27161. addFloat3(name: string, x: number, y: number, z: number): void;
  27162. /**
  27163. * Adds a vec3 to the uniform buffer.
  27164. * @param name Name of the uniform, as used in the uniform block in the shader.
  27165. * @param color Define the vec3 from a Color
  27166. */
  27167. addColor3(name: string, color: Color3): void;
  27168. /**
  27169. * Adds a vec4 to the uniform buffer.
  27170. * @param name Name of the uniform, as used in the uniform block in the shader.
  27171. * @param color Define the rgb components from a Color
  27172. * @param alpha Define the a component of the vec4
  27173. */
  27174. addColor4(name: string, color: Color3, alpha: number): void;
  27175. /**
  27176. * Adds a vec3 to the uniform buffer.
  27177. * @param name Name of the uniform, as used in the uniform block in the shader.
  27178. * @param vector Define the vec3 components from a Vector
  27179. */
  27180. addVector3(name: string, vector: Vector3): void;
  27181. /**
  27182. * Adds a Matrix 3x3 to the uniform buffer.
  27183. * @param name Name of the uniform, as used in the uniform block in the shader.
  27184. */
  27185. addMatrix3x3(name: string): void;
  27186. /**
  27187. * Adds a Matrix 2x2 to the uniform buffer.
  27188. * @param name Name of the uniform, as used in the uniform block in the shader.
  27189. */
  27190. addMatrix2x2(name: string): void;
  27191. /**
  27192. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27193. */
  27194. create(): void;
  27195. /** @hidden */
  27196. _rebuild(): void;
  27197. /**
  27198. * Updates the WebGL Uniform Buffer on the GPU.
  27199. * If the `dynamic` flag is set to true, no cache comparison is done.
  27200. * Otherwise, the buffer will be updated only if the cache differs.
  27201. */
  27202. update(): void;
  27203. /**
  27204. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27205. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27206. * @param data Define the flattened data
  27207. * @param size Define the size of the data.
  27208. */
  27209. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27210. private _updateMatrix3x3ForUniform;
  27211. private _updateMatrix3x3ForEffect;
  27212. private _updateMatrix2x2ForEffect;
  27213. private _updateMatrix2x2ForUniform;
  27214. private _updateFloatForEffect;
  27215. private _updateFloatForUniform;
  27216. private _updateFloat2ForEffect;
  27217. private _updateFloat2ForUniform;
  27218. private _updateFloat3ForEffect;
  27219. private _updateFloat3ForUniform;
  27220. private _updateFloat4ForEffect;
  27221. private _updateFloat4ForUniform;
  27222. private _updateMatrixForEffect;
  27223. private _updateMatrixForUniform;
  27224. private _updateVector3ForEffect;
  27225. private _updateVector3ForUniform;
  27226. private _updateVector4ForEffect;
  27227. private _updateVector4ForUniform;
  27228. private _updateColor3ForEffect;
  27229. private _updateColor3ForUniform;
  27230. private _updateColor4ForEffect;
  27231. private _updateColor4ForUniform;
  27232. /**
  27233. * Sets a sampler uniform on the effect.
  27234. * @param name Define the name of the sampler.
  27235. * @param texture Define the texture to set in the sampler
  27236. */
  27237. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27238. /**
  27239. * Directly updates the value of the uniform in the cache AND on the GPU.
  27240. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27241. * @param data Define the flattened data
  27242. */
  27243. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27244. /**
  27245. * Binds this uniform buffer to an effect.
  27246. * @param effect Define the effect to bind the buffer to
  27247. * @param name Name of the uniform block in the shader.
  27248. */
  27249. bindToEffect(effect: Effect, name: string): void;
  27250. /**
  27251. * Disposes the uniform buffer.
  27252. */
  27253. dispose(): void;
  27254. }
  27255. }
  27256. declare module "babylonjs/Audio/analyser" {
  27257. import { Scene } from "babylonjs/scene";
  27258. /**
  27259. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27261. */
  27262. export class Analyser {
  27263. /**
  27264. * Gets or sets the smoothing
  27265. * @ignorenaming
  27266. */
  27267. SMOOTHING: number;
  27268. /**
  27269. * Gets or sets the FFT table size
  27270. * @ignorenaming
  27271. */
  27272. FFT_SIZE: number;
  27273. /**
  27274. * Gets or sets the bar graph amplitude
  27275. * @ignorenaming
  27276. */
  27277. BARGRAPHAMPLITUDE: number;
  27278. /**
  27279. * Gets or sets the position of the debug canvas
  27280. * @ignorenaming
  27281. */
  27282. DEBUGCANVASPOS: {
  27283. x: number;
  27284. y: number;
  27285. };
  27286. /**
  27287. * Gets or sets the debug canvas size
  27288. * @ignorenaming
  27289. */
  27290. DEBUGCANVASSIZE: {
  27291. width: number;
  27292. height: number;
  27293. };
  27294. private _byteFreqs;
  27295. private _byteTime;
  27296. private _floatFreqs;
  27297. private _webAudioAnalyser;
  27298. private _debugCanvas;
  27299. private _debugCanvasContext;
  27300. private _scene;
  27301. private _registerFunc;
  27302. private _audioEngine;
  27303. /**
  27304. * Creates a new analyser
  27305. * @param scene defines hosting scene
  27306. */
  27307. constructor(scene: Scene);
  27308. /**
  27309. * Get the number of data values you will have to play with for the visualization
  27310. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27311. * @returns a number
  27312. */
  27313. getFrequencyBinCount(): number;
  27314. /**
  27315. * Gets the current frequency data as a byte array
  27316. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27317. * @returns a Uint8Array
  27318. */
  27319. getByteFrequencyData(): Uint8Array;
  27320. /**
  27321. * Gets the current waveform as a byte array
  27322. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27323. * @returns a Uint8Array
  27324. */
  27325. getByteTimeDomainData(): Uint8Array;
  27326. /**
  27327. * Gets the current frequency data as a float array
  27328. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27329. * @returns a Float32Array
  27330. */
  27331. getFloatFrequencyData(): Float32Array;
  27332. /**
  27333. * Renders the debug canvas
  27334. */
  27335. drawDebugCanvas(): void;
  27336. /**
  27337. * Stops rendering the debug canvas and removes it
  27338. */
  27339. stopDebugCanvas(): void;
  27340. /**
  27341. * Connects two audio nodes
  27342. * @param inputAudioNode defines first node to connect
  27343. * @param outputAudioNode defines second node to connect
  27344. */
  27345. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27346. /**
  27347. * Releases all associated resources
  27348. */
  27349. dispose(): void;
  27350. }
  27351. }
  27352. declare module "babylonjs/Audio/audioEngine" {
  27353. import { IDisposable } from "babylonjs/scene";
  27354. import { Analyser } from "babylonjs/Audio/analyser";
  27355. import { Nullable } from "babylonjs/types";
  27356. import { Observable } from "babylonjs/Misc/observable";
  27357. /**
  27358. * This represents an audio engine and it is responsible
  27359. * to play, synchronize and analyse sounds throughout the application.
  27360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27361. */
  27362. export interface IAudioEngine extends IDisposable {
  27363. /**
  27364. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27365. */
  27366. readonly canUseWebAudio: boolean;
  27367. /**
  27368. * Gets the current AudioContext if available.
  27369. */
  27370. readonly audioContext: Nullable<AudioContext>;
  27371. /**
  27372. * The master gain node defines the global audio volume of your audio engine.
  27373. */
  27374. readonly masterGain: GainNode;
  27375. /**
  27376. * Gets whether or not mp3 are supported by your browser.
  27377. */
  27378. readonly isMP3supported: boolean;
  27379. /**
  27380. * Gets whether or not ogg are supported by your browser.
  27381. */
  27382. readonly isOGGsupported: boolean;
  27383. /**
  27384. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27385. * @ignoreNaming
  27386. */
  27387. WarnedWebAudioUnsupported: boolean;
  27388. /**
  27389. * Defines if the audio engine relies on a custom unlocked button.
  27390. * In this case, the embedded button will not be displayed.
  27391. */
  27392. useCustomUnlockedButton: boolean;
  27393. /**
  27394. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27395. */
  27396. readonly unlocked: boolean;
  27397. /**
  27398. * Event raised when audio has been unlocked on the browser.
  27399. */
  27400. onAudioUnlockedObservable: Observable<AudioEngine>;
  27401. /**
  27402. * Event raised when audio has been locked on the browser.
  27403. */
  27404. onAudioLockedObservable: Observable<AudioEngine>;
  27405. /**
  27406. * Flags the audio engine in Locked state.
  27407. * This happens due to new browser policies preventing audio to autoplay.
  27408. */
  27409. lock(): void;
  27410. /**
  27411. * Unlocks the audio engine once a user action has been done on the dom.
  27412. * This is helpful to resume play once browser policies have been satisfied.
  27413. */
  27414. unlock(): void;
  27415. }
  27416. /**
  27417. * This represents the default audio engine used in babylon.
  27418. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27420. */
  27421. export class AudioEngine implements IAudioEngine {
  27422. private _audioContext;
  27423. private _audioContextInitialized;
  27424. private _muteButton;
  27425. private _hostElement;
  27426. /**
  27427. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27428. */
  27429. canUseWebAudio: boolean;
  27430. /**
  27431. * The master gain node defines the global audio volume of your audio engine.
  27432. */
  27433. masterGain: GainNode;
  27434. /**
  27435. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27436. * @ignoreNaming
  27437. */
  27438. WarnedWebAudioUnsupported: boolean;
  27439. /**
  27440. * Gets whether or not mp3 are supported by your browser.
  27441. */
  27442. isMP3supported: boolean;
  27443. /**
  27444. * Gets whether or not ogg are supported by your browser.
  27445. */
  27446. isOGGsupported: boolean;
  27447. /**
  27448. * Gets whether audio has been unlocked on the device.
  27449. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27450. * a user interaction has happened.
  27451. */
  27452. unlocked: boolean;
  27453. /**
  27454. * Defines if the audio engine relies on a custom unlocked button.
  27455. * In this case, the embedded button will not be displayed.
  27456. */
  27457. useCustomUnlockedButton: boolean;
  27458. /**
  27459. * Event raised when audio has been unlocked on the browser.
  27460. */
  27461. onAudioUnlockedObservable: Observable<AudioEngine>;
  27462. /**
  27463. * Event raised when audio has been locked on the browser.
  27464. */
  27465. onAudioLockedObservable: Observable<AudioEngine>;
  27466. /**
  27467. * Gets the current AudioContext if available.
  27468. */
  27469. readonly audioContext: Nullable<AudioContext>;
  27470. private _connectedAnalyser;
  27471. /**
  27472. * Instantiates a new audio engine.
  27473. *
  27474. * There should be only one per page as some browsers restrict the number
  27475. * of audio contexts you can create.
  27476. * @param hostElement defines the host element where to display the mute icon if necessary
  27477. */
  27478. constructor(hostElement?: Nullable<HTMLElement>);
  27479. /**
  27480. * Flags the audio engine in Locked state.
  27481. * This happens due to new browser policies preventing audio to autoplay.
  27482. */
  27483. lock(): void;
  27484. /**
  27485. * Unlocks the audio engine once a user action has been done on the dom.
  27486. * This is helpful to resume play once browser policies have been satisfied.
  27487. */
  27488. unlock(): void;
  27489. private _resumeAudioContext;
  27490. private _initializeAudioContext;
  27491. private _tryToRun;
  27492. private _triggerRunningState;
  27493. private _triggerSuspendedState;
  27494. private _displayMuteButton;
  27495. private _moveButtonToTopLeft;
  27496. private _onResize;
  27497. private _hideMuteButton;
  27498. /**
  27499. * Destroy and release the resources associated with the audio ccontext.
  27500. */
  27501. dispose(): void;
  27502. /**
  27503. * Gets the global volume sets on the master gain.
  27504. * @returns the global volume if set or -1 otherwise
  27505. */
  27506. getGlobalVolume(): number;
  27507. /**
  27508. * Sets the global volume of your experience (sets on the master gain).
  27509. * @param newVolume Defines the new global volume of the application
  27510. */
  27511. setGlobalVolume(newVolume: number): void;
  27512. /**
  27513. * Connect the audio engine to an audio analyser allowing some amazing
  27514. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27516. * @param analyser The analyser to connect to the engine
  27517. */
  27518. connectToAnalyser(analyser: Analyser): void;
  27519. }
  27520. }
  27521. declare module "babylonjs/Loading/loadingScreen" {
  27522. /**
  27523. * Interface used to present a loading screen while loading a scene
  27524. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27525. */
  27526. export interface ILoadingScreen {
  27527. /**
  27528. * Function called to display the loading screen
  27529. */
  27530. displayLoadingUI: () => void;
  27531. /**
  27532. * Function called to hide the loading screen
  27533. */
  27534. hideLoadingUI: () => void;
  27535. /**
  27536. * Gets or sets the color to use for the background
  27537. */
  27538. loadingUIBackgroundColor: string;
  27539. /**
  27540. * Gets or sets the text to display while loading
  27541. */
  27542. loadingUIText: string;
  27543. }
  27544. /**
  27545. * Class used for the default loading screen
  27546. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27547. */
  27548. export class DefaultLoadingScreen implements ILoadingScreen {
  27549. private _renderingCanvas;
  27550. private _loadingText;
  27551. private _loadingDivBackgroundColor;
  27552. private _loadingDiv;
  27553. private _loadingTextDiv;
  27554. /**
  27555. * Creates a new default loading screen
  27556. * @param _renderingCanvas defines the canvas used to render the scene
  27557. * @param _loadingText defines the default text to display
  27558. * @param _loadingDivBackgroundColor defines the default background color
  27559. */
  27560. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27561. /**
  27562. * Function called to display the loading screen
  27563. */
  27564. displayLoadingUI(): void;
  27565. /**
  27566. * Function called to hide the loading screen
  27567. */
  27568. hideLoadingUI(): void;
  27569. /**
  27570. * Gets or sets the text to display while loading
  27571. */
  27572. loadingUIText: string;
  27573. /**
  27574. * Gets or sets the color to use for the background
  27575. */
  27576. loadingUIBackgroundColor: string;
  27577. private _resizeLoadingUI;
  27578. }
  27579. }
  27580. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27581. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27582. import { Engine } from "babylonjs/Engines/engine";
  27583. import { Nullable } from "babylonjs/types";
  27584. /** @hidden */
  27585. export class WebGLPipelineContext implements IPipelineContext {
  27586. engine: Engine;
  27587. program: Nullable<WebGLProgram>;
  27588. context?: WebGLRenderingContext;
  27589. vertexShader?: WebGLShader;
  27590. fragmentShader?: WebGLShader;
  27591. isParallelCompiled: boolean;
  27592. onCompiled?: () => void;
  27593. transformFeedback?: WebGLTransformFeedback | null;
  27594. readonly isAsync: boolean;
  27595. readonly isReady: boolean;
  27596. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27597. }
  27598. }
  27599. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27600. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27601. /** @hidden */
  27602. export class WebGLDataBuffer extends DataBuffer {
  27603. private _buffer;
  27604. constructor(resource: WebGLBuffer);
  27605. readonly underlyingResource: any;
  27606. }
  27607. }
  27608. declare module "babylonjs/Materials/Textures/videoTexture" {
  27609. import { Observable } from "babylonjs/Misc/observable";
  27610. import { Nullable } from "babylonjs/types";
  27611. import { Scene } from "babylonjs/scene";
  27612. import { Texture } from "babylonjs/Materials/Textures/texture";
  27613. /**
  27614. * Settings for finer control over video usage
  27615. */
  27616. export interface VideoTextureSettings {
  27617. /**
  27618. * Applies `autoplay` to video, if specified
  27619. */
  27620. autoPlay?: boolean;
  27621. /**
  27622. * Applies `loop` to video, if specified
  27623. */
  27624. loop?: boolean;
  27625. /**
  27626. * Automatically updates internal texture from video at every frame in the render loop
  27627. */
  27628. autoUpdateTexture: boolean;
  27629. /**
  27630. * Image src displayed during the video loading or until the user interacts with the video.
  27631. */
  27632. poster?: string;
  27633. }
  27634. /**
  27635. * If you want to display a video in your scene, this is the special texture for that.
  27636. * This special texture works similar to other textures, with the exception of a few parameters.
  27637. * @see https://doc.babylonjs.com/how_to/video_texture
  27638. */
  27639. export class VideoTexture extends Texture {
  27640. /**
  27641. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27642. */
  27643. readonly autoUpdateTexture: boolean;
  27644. /**
  27645. * The video instance used by the texture internally
  27646. */
  27647. readonly video: HTMLVideoElement;
  27648. private _onUserActionRequestedObservable;
  27649. /**
  27650. * Event triggerd when a dom action is required by the user to play the video.
  27651. * This happens due to recent changes in browser policies preventing video to auto start.
  27652. */
  27653. readonly onUserActionRequestedObservable: Observable<Texture>;
  27654. private _generateMipMaps;
  27655. private _engine;
  27656. private _stillImageCaptured;
  27657. private _displayingPosterTexture;
  27658. private _settings;
  27659. private _createInternalTextureOnEvent;
  27660. /**
  27661. * Creates a video texture.
  27662. * If you want to display a video in your scene, this is the special texture for that.
  27663. * This special texture works similar to other textures, with the exception of a few parameters.
  27664. * @see https://doc.babylonjs.com/how_to/video_texture
  27665. * @param name optional name, will detect from video source, if not defined
  27666. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27667. * @param scene is obviously the current scene.
  27668. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27669. * @param invertY is false by default but can be used to invert video on Y axis
  27670. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27671. * @param settings allows finer control over video usage
  27672. */
  27673. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27674. private _getName;
  27675. private _getVideo;
  27676. private _createInternalTexture;
  27677. private reset;
  27678. /**
  27679. * @hidden Internal method to initiate `update`.
  27680. */
  27681. _rebuild(): void;
  27682. /**
  27683. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27684. */
  27685. update(): void;
  27686. /**
  27687. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27688. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27689. */
  27690. updateTexture(isVisible: boolean): void;
  27691. protected _updateInternalTexture: () => void;
  27692. /**
  27693. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27694. * @param url New url.
  27695. */
  27696. updateURL(url: string): void;
  27697. /**
  27698. * Dispose the texture and release its associated resources.
  27699. */
  27700. dispose(): void;
  27701. /**
  27702. * Creates a video texture straight from a stream.
  27703. * @param scene Define the scene the texture should be created in
  27704. * @param stream Define the stream the texture should be created from
  27705. * @returns The created video texture as a promise
  27706. */
  27707. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27708. /**
  27709. * Creates a video texture straight from your WebCam video feed.
  27710. * @param scene Define the scene the texture should be created in
  27711. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27712. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27713. * @returns The created video texture as a promise
  27714. */
  27715. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27716. minWidth: number;
  27717. maxWidth: number;
  27718. minHeight: number;
  27719. maxHeight: number;
  27720. deviceId: string;
  27721. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27722. /**
  27723. * Creates a video texture straight from your WebCam video feed.
  27724. * @param scene Define the scene the texture should be created in
  27725. * @param onReady Define a callback to triggered once the texture will be ready
  27726. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27727. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27728. */
  27729. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27730. minWidth: number;
  27731. maxWidth: number;
  27732. minHeight: number;
  27733. maxHeight: number;
  27734. deviceId: string;
  27735. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27736. }
  27737. }
  27738. declare module "babylonjs/Engines/engine" {
  27739. import { Observable } from "babylonjs/Misc/observable";
  27740. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27741. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27742. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27743. import { Camera } from "babylonjs/Cameras/camera";
  27744. import { Scene } from "babylonjs/scene";
  27745. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27746. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27747. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27748. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27749. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27750. import { Material } from "babylonjs/Materials/material";
  27751. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27752. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27753. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27754. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27755. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27756. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27757. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27758. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27759. import { WebRequest } from "babylonjs/Misc/webRequest";
  27760. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27761. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27762. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27763. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27764. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27765. /**
  27766. * Interface for attribute information associated with buffer instanciation
  27767. */
  27768. export class InstancingAttributeInfo {
  27769. /**
  27770. * Index/offset of the attribute in the vertex shader
  27771. */
  27772. index: number;
  27773. /**
  27774. * size of the attribute, 1, 2, 3 or 4
  27775. */
  27776. attributeSize: number;
  27777. /**
  27778. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27779. * default is FLOAT
  27780. */
  27781. attribyteType: number;
  27782. /**
  27783. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27784. */
  27785. normalized: boolean;
  27786. /**
  27787. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27788. */
  27789. offset: number;
  27790. /**
  27791. * Name of the GLSL attribute, for debugging purpose only
  27792. */
  27793. attributeName: string;
  27794. }
  27795. /**
  27796. * Define options used to create a depth texture
  27797. */
  27798. export class DepthTextureCreationOptions {
  27799. /** Specifies whether or not a stencil should be allocated in the texture */
  27800. generateStencil?: boolean;
  27801. /** Specifies whether or not bilinear filtering is enable on the texture */
  27802. bilinearFiltering?: boolean;
  27803. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27804. comparisonFunction?: number;
  27805. /** Specifies if the created texture is a cube texture */
  27806. isCube?: boolean;
  27807. }
  27808. /**
  27809. * Class used to describe the capabilities of the engine relatively to the current browser
  27810. */
  27811. export class EngineCapabilities {
  27812. /** Maximum textures units per fragment shader */
  27813. maxTexturesImageUnits: number;
  27814. /** Maximum texture units per vertex shader */
  27815. maxVertexTextureImageUnits: number;
  27816. /** Maximum textures units in the entire pipeline */
  27817. maxCombinedTexturesImageUnits: number;
  27818. /** Maximum texture size */
  27819. maxTextureSize: number;
  27820. /** Maximum cube texture size */
  27821. maxCubemapTextureSize: number;
  27822. /** Maximum render texture size */
  27823. maxRenderTextureSize: number;
  27824. /** Maximum number of vertex attributes */
  27825. maxVertexAttribs: number;
  27826. /** Maximum number of varyings */
  27827. maxVaryingVectors: number;
  27828. /** Maximum number of uniforms per vertex shader */
  27829. maxVertexUniformVectors: number;
  27830. /** Maximum number of uniforms per fragment shader */
  27831. maxFragmentUniformVectors: number;
  27832. /** Defines if standard derivates (dx/dy) are supported */
  27833. standardDerivatives: boolean;
  27834. /** Defines if s3tc texture compression is supported */
  27835. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27836. /** Defines if pvrtc texture compression is supported */
  27837. pvrtc: any;
  27838. /** Defines if etc1 texture compression is supported */
  27839. etc1: any;
  27840. /** Defines if etc2 texture compression is supported */
  27841. etc2: any;
  27842. /** Defines if astc texture compression is supported */
  27843. astc: any;
  27844. /** Defines if float textures are supported */
  27845. textureFloat: boolean;
  27846. /** Defines if vertex array objects are supported */
  27847. vertexArrayObject: boolean;
  27848. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27849. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27850. /** Gets the maximum level of anisotropy supported */
  27851. maxAnisotropy: number;
  27852. /** Defines if instancing is supported */
  27853. instancedArrays: boolean;
  27854. /** Defines if 32 bits indices are supported */
  27855. uintIndices: boolean;
  27856. /** Defines if high precision shaders are supported */
  27857. highPrecisionShaderSupported: boolean;
  27858. /** Defines if depth reading in the fragment shader is supported */
  27859. fragmentDepthSupported: boolean;
  27860. /** Defines if float texture linear filtering is supported*/
  27861. textureFloatLinearFiltering: boolean;
  27862. /** Defines if rendering to float textures is supported */
  27863. textureFloatRender: boolean;
  27864. /** Defines if half float textures are supported*/
  27865. textureHalfFloat: boolean;
  27866. /** Defines if half float texture linear filtering is supported*/
  27867. textureHalfFloatLinearFiltering: boolean;
  27868. /** Defines if rendering to half float textures is supported */
  27869. textureHalfFloatRender: boolean;
  27870. /** Defines if textureLOD shader command is supported */
  27871. textureLOD: boolean;
  27872. /** Defines if draw buffers extension is supported */
  27873. drawBuffersExtension: boolean;
  27874. /** Defines if depth textures are supported */
  27875. depthTextureExtension: boolean;
  27876. /** Defines if float color buffer are supported */
  27877. colorBufferFloat: boolean;
  27878. /** Gets disjoint timer query extension (null if not supported) */
  27879. timerQuery: EXT_disjoint_timer_query;
  27880. /** Defines if timestamp can be used with timer query */
  27881. canUseTimestampForTimerQuery: boolean;
  27882. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27883. multiview: any;
  27884. /** Function used to let the system compiles shaders in background */
  27885. parallelShaderCompile: {
  27886. COMPLETION_STATUS_KHR: number;
  27887. };
  27888. }
  27889. /** Interface defining initialization parameters for Engine class */
  27890. export interface EngineOptions extends WebGLContextAttributes {
  27891. /**
  27892. * Defines if the engine should no exceed a specified device ratio
  27893. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27894. */
  27895. limitDeviceRatio?: number;
  27896. /**
  27897. * Defines if webvr should be enabled automatically
  27898. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27899. */
  27900. autoEnableWebVR?: boolean;
  27901. /**
  27902. * Defines if webgl2 should be turned off even if supported
  27903. * @see http://doc.babylonjs.com/features/webgl2
  27904. */
  27905. disableWebGL2Support?: boolean;
  27906. /**
  27907. * Defines if webaudio should be initialized as well
  27908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27909. */
  27910. audioEngine?: boolean;
  27911. /**
  27912. * Defines if animations should run using a deterministic lock step
  27913. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27914. */
  27915. deterministicLockstep?: boolean;
  27916. /** Defines the maximum steps to use with deterministic lock step mode */
  27917. lockstepMaxSteps?: number;
  27918. /**
  27919. * Defines that engine should ignore context lost events
  27920. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27921. */
  27922. doNotHandleContextLost?: boolean;
  27923. /**
  27924. * Defines that engine should ignore modifying touch action attribute and style
  27925. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27926. */
  27927. doNotHandleTouchAction?: boolean;
  27928. /**
  27929. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27930. */
  27931. useHighPrecisionFloats?: boolean;
  27932. }
  27933. /**
  27934. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27935. */
  27936. export class Engine {
  27937. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27938. static ExceptionList: ({
  27939. key: string;
  27940. capture: string;
  27941. captureConstraint: number;
  27942. targets: string[];
  27943. } | {
  27944. key: string;
  27945. capture: null;
  27946. captureConstraint: null;
  27947. targets: string[];
  27948. })[];
  27949. /** Gets the list of created engines */
  27950. static readonly Instances: Engine[];
  27951. /**
  27952. * Gets the latest created engine
  27953. */
  27954. static readonly LastCreatedEngine: Nullable<Engine>;
  27955. /**
  27956. * Gets the latest created scene
  27957. */
  27958. static readonly LastCreatedScene: Nullable<Scene>;
  27959. /**
  27960. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27961. * @param flag defines which part of the materials must be marked as dirty
  27962. * @param predicate defines a predicate used to filter which materials should be affected
  27963. */
  27964. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27965. /**
  27966. * Hidden
  27967. */
  27968. static _TextureLoaders: IInternalTextureLoader[];
  27969. /** Defines that alpha blending is disabled */
  27970. static readonly ALPHA_DISABLE: number;
  27971. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27972. static readonly ALPHA_ADD: number;
  27973. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27974. static readonly ALPHA_COMBINE: number;
  27975. /** Defines that alpha blending to DEST - SRC * DEST */
  27976. static readonly ALPHA_SUBTRACT: number;
  27977. /** Defines that alpha blending to SRC * DEST */
  27978. static readonly ALPHA_MULTIPLY: number;
  27979. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27980. static readonly ALPHA_MAXIMIZED: number;
  27981. /** Defines that alpha blending to SRC + DEST */
  27982. static readonly ALPHA_ONEONE: number;
  27983. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27984. static readonly ALPHA_PREMULTIPLIED: number;
  27985. /**
  27986. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27987. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27988. */
  27989. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27990. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27991. static readonly ALPHA_INTERPOLATE: number;
  27992. /**
  27993. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27994. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27995. */
  27996. static readonly ALPHA_SCREENMODE: number;
  27997. /** Defines that the ressource is not delayed*/
  27998. static readonly DELAYLOADSTATE_NONE: number;
  27999. /** Defines that the ressource was successfully delay loaded */
  28000. static readonly DELAYLOADSTATE_LOADED: number;
  28001. /** Defines that the ressource is currently delay loading */
  28002. static readonly DELAYLOADSTATE_LOADING: number;
  28003. /** Defines that the ressource is delayed and has not started loading */
  28004. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28005. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28006. static readonly NEVER: number;
  28007. /** 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 */
  28008. static readonly ALWAYS: number;
  28009. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28010. static readonly LESS: number;
  28011. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28012. static readonly EQUAL: number;
  28013. /** 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 */
  28014. static readonly LEQUAL: number;
  28015. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28016. static readonly GREATER: number;
  28017. /** 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 */
  28018. static readonly GEQUAL: number;
  28019. /** 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 */
  28020. static readonly NOTEQUAL: number;
  28021. /** Passed to stencilOperation to specify that stencil value must be kept */
  28022. static readonly KEEP: number;
  28023. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28024. static readonly REPLACE: number;
  28025. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28026. static readonly INCR: number;
  28027. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28028. static readonly DECR: number;
  28029. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28030. static readonly INVERT: number;
  28031. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28032. static readonly INCR_WRAP: number;
  28033. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28034. static readonly DECR_WRAP: number;
  28035. /** Texture is not repeating outside of 0..1 UVs */
  28036. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28037. /** Texture is repeating outside of 0..1 UVs */
  28038. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28039. /** Texture is repeating and mirrored */
  28040. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28041. /** ALPHA */
  28042. static readonly TEXTUREFORMAT_ALPHA: number;
  28043. /** LUMINANCE */
  28044. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28045. /** LUMINANCE_ALPHA */
  28046. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28047. /** RGB */
  28048. static readonly TEXTUREFORMAT_RGB: number;
  28049. /** RGBA */
  28050. static readonly TEXTUREFORMAT_RGBA: number;
  28051. /** RED */
  28052. static readonly TEXTUREFORMAT_RED: number;
  28053. /** RED (2nd reference) */
  28054. static readonly TEXTUREFORMAT_R: number;
  28055. /** RG */
  28056. static readonly TEXTUREFORMAT_RG: number;
  28057. /** RED_INTEGER */
  28058. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28059. /** RED_INTEGER (2nd reference) */
  28060. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28061. /** RG_INTEGER */
  28062. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28063. /** RGB_INTEGER */
  28064. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28065. /** RGBA_INTEGER */
  28066. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28067. /** UNSIGNED_BYTE */
  28068. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28069. /** UNSIGNED_BYTE (2nd reference) */
  28070. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28071. /** FLOAT */
  28072. static readonly TEXTURETYPE_FLOAT: number;
  28073. /** HALF_FLOAT */
  28074. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28075. /** BYTE */
  28076. static readonly TEXTURETYPE_BYTE: number;
  28077. /** SHORT */
  28078. static readonly TEXTURETYPE_SHORT: number;
  28079. /** UNSIGNED_SHORT */
  28080. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28081. /** INT */
  28082. static readonly TEXTURETYPE_INT: number;
  28083. /** UNSIGNED_INT */
  28084. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28085. /** UNSIGNED_SHORT_4_4_4_4 */
  28086. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28087. /** UNSIGNED_SHORT_5_5_5_1 */
  28088. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28089. /** UNSIGNED_SHORT_5_6_5 */
  28090. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28091. /** UNSIGNED_INT_2_10_10_10_REV */
  28092. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28093. /** UNSIGNED_INT_24_8 */
  28094. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28095. /** UNSIGNED_INT_10F_11F_11F_REV */
  28096. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28097. /** UNSIGNED_INT_5_9_9_9_REV */
  28098. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28099. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28100. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28101. /** nearest is mag = nearest and min = nearest and mip = linear */
  28102. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28103. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28104. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28105. /** Trilinear is mag = linear and min = linear and mip = linear */
  28106. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28107. /** nearest is mag = nearest and min = nearest and mip = linear */
  28108. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28109. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28110. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28111. /** Trilinear is mag = linear and min = linear and mip = linear */
  28112. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28113. /** mag = nearest and min = nearest and mip = nearest */
  28114. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28115. /** mag = nearest and min = linear and mip = nearest */
  28116. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28117. /** mag = nearest and min = linear and mip = linear */
  28118. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28119. /** mag = nearest and min = linear and mip = none */
  28120. static readonly TEXTURE_NEAREST_LINEAR: number;
  28121. /** mag = nearest and min = nearest and mip = none */
  28122. static readonly TEXTURE_NEAREST_NEAREST: number;
  28123. /** mag = linear and min = nearest and mip = nearest */
  28124. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28125. /** mag = linear and min = nearest and mip = linear */
  28126. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28127. /** mag = linear and min = linear and mip = none */
  28128. static readonly TEXTURE_LINEAR_LINEAR: number;
  28129. /** mag = linear and min = nearest and mip = none */
  28130. static readonly TEXTURE_LINEAR_NEAREST: number;
  28131. /** Explicit coordinates mode */
  28132. static readonly TEXTURE_EXPLICIT_MODE: number;
  28133. /** Spherical coordinates mode */
  28134. static readonly TEXTURE_SPHERICAL_MODE: number;
  28135. /** Planar coordinates mode */
  28136. static readonly TEXTURE_PLANAR_MODE: number;
  28137. /** Cubic coordinates mode */
  28138. static readonly TEXTURE_CUBIC_MODE: number;
  28139. /** Projection coordinates mode */
  28140. static readonly TEXTURE_PROJECTION_MODE: number;
  28141. /** Skybox coordinates mode */
  28142. static readonly TEXTURE_SKYBOX_MODE: number;
  28143. /** Inverse Cubic coordinates mode */
  28144. static readonly TEXTURE_INVCUBIC_MODE: number;
  28145. /** Equirectangular coordinates mode */
  28146. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28147. /** Equirectangular Fixed coordinates mode */
  28148. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28149. /** Equirectangular Fixed Mirrored coordinates mode */
  28150. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28151. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28152. static readonly SCALEMODE_FLOOR: number;
  28153. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28154. static readonly SCALEMODE_NEAREST: number;
  28155. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28156. static readonly SCALEMODE_CEILING: number;
  28157. /**
  28158. * Returns the current npm package of the sdk
  28159. */
  28160. static readonly NpmPackage: string;
  28161. /**
  28162. * Returns the current version of the framework
  28163. */
  28164. static readonly Version: string;
  28165. /**
  28166. * Returns a string describing the current engine
  28167. */
  28168. readonly description: string;
  28169. /**
  28170. * Gets or sets the epsilon value used by collision engine
  28171. */
  28172. static CollisionsEpsilon: number;
  28173. /**
  28174. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28175. */
  28176. static ShadersRepository: string;
  28177. /**
  28178. * Method called to create the default loading screen.
  28179. * This can be overriden in your own app.
  28180. * @param canvas The rendering canvas element
  28181. * @returns The loading screen
  28182. */
  28183. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28184. /**
  28185. * Method called to create the default rescale post process on each engine.
  28186. */
  28187. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28188. /**
  28189. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28190. */
  28191. forcePOTTextures: boolean;
  28192. /**
  28193. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28194. */
  28195. isFullscreen: boolean;
  28196. /**
  28197. * Gets a boolean indicating if the pointer is currently locked
  28198. */
  28199. isPointerLock: boolean;
  28200. /**
  28201. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28202. */
  28203. cullBackFaces: boolean;
  28204. /**
  28205. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28206. */
  28207. renderEvenInBackground: boolean;
  28208. /**
  28209. * Gets or sets a boolean indicating that cache can be kept between frames
  28210. */
  28211. preventCacheWipeBetweenFrames: boolean;
  28212. /**
  28213. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28214. **/
  28215. enableOfflineSupport: boolean;
  28216. /**
  28217. * 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)
  28218. **/
  28219. disableManifestCheck: boolean;
  28220. /**
  28221. * Gets the list of created scenes
  28222. */
  28223. scenes: Scene[];
  28224. /**
  28225. * Event raised when a new scene is created
  28226. */
  28227. onNewSceneAddedObservable: Observable<Scene>;
  28228. /**
  28229. * Gets the list of created postprocesses
  28230. */
  28231. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28232. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28233. validateShaderPrograms: boolean;
  28234. /**
  28235. * Observable event triggered each time the rendering canvas is resized
  28236. */
  28237. onResizeObservable: Observable<Engine>;
  28238. /**
  28239. * Observable event triggered each time the canvas loses focus
  28240. */
  28241. onCanvasBlurObservable: Observable<Engine>;
  28242. /**
  28243. * Observable event triggered each time the canvas gains focus
  28244. */
  28245. onCanvasFocusObservable: Observable<Engine>;
  28246. /**
  28247. * Observable event triggered each time the canvas receives pointerout event
  28248. */
  28249. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28250. /**
  28251. * Observable event triggered before each texture is initialized
  28252. */
  28253. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28254. /**
  28255. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28256. */
  28257. disableUniformBuffers: boolean;
  28258. /** @hidden */
  28259. _uniformBuffers: UniformBuffer[];
  28260. /**
  28261. * Gets a boolean indicating that the engine supports uniform buffers
  28262. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28263. */
  28264. readonly supportsUniformBuffers: boolean;
  28265. /**
  28266. * Observable raised when the engine begins a new frame
  28267. */
  28268. onBeginFrameObservable: Observable<Engine>;
  28269. /**
  28270. * If set, will be used to request the next animation frame for the render loop
  28271. */
  28272. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28273. /**
  28274. * Observable raised when the engine ends the current frame
  28275. */
  28276. onEndFrameObservable: Observable<Engine>;
  28277. /**
  28278. * Observable raised when the engine is about to compile a shader
  28279. */
  28280. onBeforeShaderCompilationObservable: Observable<Engine>;
  28281. /**
  28282. * Observable raised when the engine has jsut compiled a shader
  28283. */
  28284. onAfterShaderCompilationObservable: Observable<Engine>;
  28285. /** @hidden */
  28286. _gl: WebGLRenderingContext;
  28287. private _renderingCanvas;
  28288. private _windowIsBackground;
  28289. private _webGLVersion;
  28290. protected _highPrecisionShadersAllowed: boolean;
  28291. /** @hidden */
  28292. readonly _shouldUseHighPrecisionShader: boolean;
  28293. /**
  28294. * Gets a boolean indicating that only power of 2 textures are supported
  28295. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28296. */
  28297. readonly needPOTTextures: boolean;
  28298. /** @hidden */
  28299. _badOS: boolean;
  28300. /** @hidden */
  28301. _badDesktopOS: boolean;
  28302. /**
  28303. * Gets the audio engine
  28304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28305. * @ignorenaming
  28306. */
  28307. static audioEngine: IAudioEngine;
  28308. /**
  28309. * Default AudioEngine factory responsible of creating the Audio Engine.
  28310. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28311. */
  28312. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28313. /**
  28314. * Default offline support factory responsible of creating a tool used to store data locally.
  28315. * By default, this will create a Database object if the workload has been embedded.
  28316. */
  28317. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28318. private _onFocus;
  28319. private _onBlur;
  28320. private _onCanvasPointerOut;
  28321. private _onCanvasBlur;
  28322. private _onCanvasFocus;
  28323. private _onFullscreenChange;
  28324. private _onPointerLockChange;
  28325. private _hardwareScalingLevel;
  28326. /** @hidden */
  28327. _caps: EngineCapabilities;
  28328. private _pointerLockRequested;
  28329. private _isStencilEnable;
  28330. private _colorWrite;
  28331. private _loadingScreen;
  28332. /** @hidden */
  28333. _drawCalls: PerfCounter;
  28334. private _glVersion;
  28335. private _glRenderer;
  28336. private _glVendor;
  28337. private _videoTextureSupported;
  28338. private _renderingQueueLaunched;
  28339. private _activeRenderLoops;
  28340. private _deterministicLockstep;
  28341. private _lockstepMaxSteps;
  28342. /**
  28343. * Observable signaled when a context lost event is raised
  28344. */
  28345. onContextLostObservable: Observable<Engine>;
  28346. /**
  28347. * Observable signaled when a context restored event is raised
  28348. */
  28349. onContextRestoredObservable: Observable<Engine>;
  28350. private _onContextLost;
  28351. private _onContextRestored;
  28352. private _contextWasLost;
  28353. /** @hidden */
  28354. _doNotHandleContextLost: boolean;
  28355. /**
  28356. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28357. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28358. */
  28359. doNotHandleContextLost: boolean;
  28360. private _performanceMonitor;
  28361. private _fps;
  28362. private _deltaTime;
  28363. /**
  28364. * Turn this value on if you want to pause FPS computation when in background
  28365. */
  28366. disablePerformanceMonitorInBackground: boolean;
  28367. /**
  28368. * Gets the performance monitor attached to this engine
  28369. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28370. */
  28371. readonly performanceMonitor: PerformanceMonitor;
  28372. /**
  28373. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28374. */
  28375. disableVertexArrayObjects: boolean;
  28376. /** @hidden */
  28377. protected _depthCullingState: _DepthCullingState;
  28378. /** @hidden */
  28379. protected _stencilState: _StencilState;
  28380. /** @hidden */
  28381. protected _alphaState: _AlphaState;
  28382. /** @hidden */
  28383. protected _alphaMode: number;
  28384. /** @hidden */
  28385. _internalTexturesCache: InternalTexture[];
  28386. /** @hidden */
  28387. protected _activeChannel: number;
  28388. private _currentTextureChannel;
  28389. /** @hidden */
  28390. protected _boundTexturesCache: {
  28391. [key: string]: Nullable<InternalTexture>;
  28392. };
  28393. /** @hidden */
  28394. protected _currentEffect: Nullable<Effect>;
  28395. /** @hidden */
  28396. protected _currentProgram: Nullable<WebGLProgram>;
  28397. private _compiledEffects;
  28398. private _vertexAttribArraysEnabled;
  28399. /** @hidden */
  28400. protected _cachedViewport: Nullable<Viewport>;
  28401. private _cachedVertexArrayObject;
  28402. /** @hidden */
  28403. protected _cachedVertexBuffers: any;
  28404. /** @hidden */
  28405. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28406. /** @hidden */
  28407. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28408. /** @hidden */
  28409. _currentRenderTarget: Nullable<InternalTexture>;
  28410. private _uintIndicesCurrentlySet;
  28411. private _currentBoundBuffer;
  28412. /** @hidden */
  28413. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28414. private _currentBufferPointers;
  28415. private _currentInstanceLocations;
  28416. private _currentInstanceBuffers;
  28417. private _textureUnits;
  28418. /** @hidden */
  28419. _workingCanvas: Nullable<HTMLCanvasElement>;
  28420. /** @hidden */
  28421. _workingContext: Nullable<CanvasRenderingContext2D>;
  28422. private _rescalePostProcess;
  28423. private _dummyFramebuffer;
  28424. private _externalData;
  28425. /** @hidden */
  28426. _bindedRenderFunction: any;
  28427. private _vaoRecordInProgress;
  28428. private _mustWipeVertexAttributes;
  28429. private _emptyTexture;
  28430. private _emptyCubeTexture;
  28431. private _emptyTexture3D;
  28432. /** @hidden */
  28433. _frameHandler: number;
  28434. private _nextFreeTextureSlots;
  28435. private _maxSimultaneousTextures;
  28436. private _activeRequests;
  28437. private _texturesSupported;
  28438. /** @hidden */
  28439. _textureFormatInUse: Nullable<string>;
  28440. /**
  28441. * Gets the list of texture formats supported
  28442. */
  28443. readonly texturesSupported: Array<string>;
  28444. /**
  28445. * Gets the list of texture formats in use
  28446. */
  28447. readonly textureFormatInUse: Nullable<string>;
  28448. /**
  28449. * Gets the current viewport
  28450. */
  28451. readonly currentViewport: Nullable<Viewport>;
  28452. /**
  28453. * Gets the default empty texture
  28454. */
  28455. readonly emptyTexture: InternalTexture;
  28456. /**
  28457. * Gets the default empty 3D texture
  28458. */
  28459. readonly emptyTexture3D: InternalTexture;
  28460. /**
  28461. * Gets the default empty cube texture
  28462. */
  28463. readonly emptyCubeTexture: InternalTexture;
  28464. /**
  28465. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28466. */
  28467. readonly premultipliedAlpha: boolean;
  28468. /**
  28469. * Creates a new engine
  28470. * @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
  28471. * @param antialias defines enable antialiasing (default: false)
  28472. * @param options defines further options to be sent to the getContext() function
  28473. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28474. */
  28475. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28476. /**
  28477. * Initializes a webVR display and starts listening to display change events
  28478. * The onVRDisplayChangedObservable will be notified upon these changes
  28479. * @returns The onVRDisplayChangedObservable
  28480. */
  28481. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28482. /** @hidden */
  28483. _prepareVRComponent(): void;
  28484. /** @hidden */
  28485. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28486. /** @hidden */
  28487. _submitVRFrame(): void;
  28488. /**
  28489. * Call this function to leave webVR mode
  28490. * Will do nothing if webVR is not supported or if there is no webVR device
  28491. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28492. */
  28493. disableVR(): void;
  28494. /**
  28495. * Gets a boolean indicating that the system is in VR mode and is presenting
  28496. * @returns true if VR mode is engaged
  28497. */
  28498. isVRPresenting(): boolean;
  28499. /** @hidden */
  28500. _requestVRFrame(): void;
  28501. private _disableTouchAction;
  28502. private _rebuildInternalTextures;
  28503. private _rebuildEffects;
  28504. /**
  28505. * Gets a boolean indicating if all created effects are ready
  28506. * @returns true if all effects are ready
  28507. */
  28508. areAllEffectsReady(): boolean;
  28509. private _rebuildBuffers;
  28510. private _initGLContext;
  28511. /**
  28512. * Gets version of the current webGL context
  28513. */
  28514. readonly webGLVersion: number;
  28515. /**
  28516. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28517. */
  28518. readonly isStencilEnable: boolean;
  28519. /** @hidden */
  28520. _prepareWorkingCanvas(): void;
  28521. /**
  28522. * Reset the texture cache to empty state
  28523. */
  28524. resetTextureCache(): void;
  28525. /**
  28526. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28527. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28528. * @returns true if engine is in deterministic lock step mode
  28529. */
  28530. isDeterministicLockStep(): boolean;
  28531. /**
  28532. * Gets the max steps when engine is running in deterministic lock step
  28533. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28534. * @returns the max steps
  28535. */
  28536. getLockstepMaxSteps(): number;
  28537. /**
  28538. * Gets an object containing information about the current webGL context
  28539. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28540. */
  28541. getGlInfo(): {
  28542. vendor: string;
  28543. renderer: string;
  28544. version: string;
  28545. };
  28546. /**
  28547. * Gets current aspect ratio
  28548. * @param camera defines the camera to use to get the aspect ratio
  28549. * @param useScreen defines if screen size must be used (or the current render target if any)
  28550. * @returns a number defining the aspect ratio
  28551. */
  28552. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28553. /**
  28554. * Gets current screen aspect ratio
  28555. * @returns a number defining the aspect ratio
  28556. */
  28557. getScreenAspectRatio(): number;
  28558. /**
  28559. * Gets the current render width
  28560. * @param useScreen defines if screen size must be used (or the current render target if any)
  28561. * @returns a number defining the current render width
  28562. */
  28563. getRenderWidth(useScreen?: boolean): number;
  28564. /**
  28565. * Gets the current render height
  28566. * @param useScreen defines if screen size must be used (or the current render target if any)
  28567. * @returns a number defining the current render height
  28568. */
  28569. getRenderHeight(useScreen?: boolean): number;
  28570. /**
  28571. * Gets the HTML canvas attached with the current webGL context
  28572. * @returns a HTML canvas
  28573. */
  28574. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28575. /**
  28576. * Gets the client rect of the HTML canvas attached with the current webGL context
  28577. * @returns a client rectanglee
  28578. */
  28579. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28580. /**
  28581. * Defines the hardware scaling level.
  28582. * By default the hardware scaling level is computed from the window device ratio.
  28583. * 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.
  28584. * @param level defines the level to use
  28585. */
  28586. setHardwareScalingLevel(level: number): void;
  28587. /**
  28588. * Gets the current hardware scaling level.
  28589. * By default the hardware scaling level is computed from the window device ratio.
  28590. * 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.
  28591. * @returns a number indicating the current hardware scaling level
  28592. */
  28593. getHardwareScalingLevel(): number;
  28594. /**
  28595. * Gets the list of loaded textures
  28596. * @returns an array containing all loaded textures
  28597. */
  28598. getLoadedTexturesCache(): InternalTexture[];
  28599. /**
  28600. * Gets the object containing all engine capabilities
  28601. * @returns the EngineCapabilities object
  28602. */
  28603. getCaps(): EngineCapabilities;
  28604. /**
  28605. * Gets the current depth function
  28606. * @returns a number defining the depth function
  28607. */
  28608. getDepthFunction(): Nullable<number>;
  28609. /**
  28610. * Sets the current depth function
  28611. * @param depthFunc defines the function to use
  28612. */
  28613. setDepthFunction(depthFunc: number): void;
  28614. /**
  28615. * Sets the current depth function to GREATER
  28616. */
  28617. setDepthFunctionToGreater(): void;
  28618. /**
  28619. * Sets the current depth function to GEQUAL
  28620. */
  28621. setDepthFunctionToGreaterOrEqual(): void;
  28622. /**
  28623. * Sets the current depth function to LESS
  28624. */
  28625. setDepthFunctionToLess(): void;
  28626. private _cachedStencilBuffer;
  28627. private _cachedStencilFunction;
  28628. private _cachedStencilMask;
  28629. private _cachedStencilOperationPass;
  28630. private _cachedStencilOperationFail;
  28631. private _cachedStencilOperationDepthFail;
  28632. private _cachedStencilReference;
  28633. /**
  28634. * Caches the the state of the stencil buffer
  28635. */
  28636. cacheStencilState(): void;
  28637. /**
  28638. * Restores the state of the stencil buffer
  28639. */
  28640. restoreStencilState(): void;
  28641. /**
  28642. * Sets the current depth function to LEQUAL
  28643. */
  28644. setDepthFunctionToLessOrEqual(): void;
  28645. /**
  28646. * Gets a boolean indicating if stencil buffer is enabled
  28647. * @returns the current stencil buffer state
  28648. */
  28649. getStencilBuffer(): boolean;
  28650. /**
  28651. * Enable or disable the stencil buffer
  28652. * @param enable defines if the stencil buffer must be enabled or disabled
  28653. */
  28654. setStencilBuffer(enable: boolean): void;
  28655. /**
  28656. * Gets the current stencil mask
  28657. * @returns a number defining the new stencil mask to use
  28658. */
  28659. getStencilMask(): number;
  28660. /**
  28661. * Sets the current stencil mask
  28662. * @param mask defines the new stencil mask to use
  28663. */
  28664. setStencilMask(mask: number): void;
  28665. /**
  28666. * Gets the current stencil function
  28667. * @returns a number defining the stencil function to use
  28668. */
  28669. getStencilFunction(): number;
  28670. /**
  28671. * Gets the current stencil reference value
  28672. * @returns a number defining the stencil reference value to use
  28673. */
  28674. getStencilFunctionReference(): number;
  28675. /**
  28676. * Gets the current stencil mask
  28677. * @returns a number defining the stencil mask to use
  28678. */
  28679. getStencilFunctionMask(): number;
  28680. /**
  28681. * Sets the current stencil function
  28682. * @param stencilFunc defines the new stencil function to use
  28683. */
  28684. setStencilFunction(stencilFunc: number): void;
  28685. /**
  28686. * Sets the current stencil reference
  28687. * @param reference defines the new stencil reference to use
  28688. */
  28689. setStencilFunctionReference(reference: number): void;
  28690. /**
  28691. * Sets the current stencil mask
  28692. * @param mask defines the new stencil mask to use
  28693. */
  28694. setStencilFunctionMask(mask: number): void;
  28695. /**
  28696. * Gets the current stencil operation when stencil fails
  28697. * @returns a number defining stencil operation to use when stencil fails
  28698. */
  28699. getStencilOperationFail(): number;
  28700. /**
  28701. * Gets the current stencil operation when depth fails
  28702. * @returns a number defining stencil operation to use when depth fails
  28703. */
  28704. getStencilOperationDepthFail(): number;
  28705. /**
  28706. * Gets the current stencil operation when stencil passes
  28707. * @returns a number defining stencil operation to use when stencil passes
  28708. */
  28709. getStencilOperationPass(): number;
  28710. /**
  28711. * Sets the stencil operation to use when stencil fails
  28712. * @param operation defines the stencil operation to use when stencil fails
  28713. */
  28714. setStencilOperationFail(operation: number): void;
  28715. /**
  28716. * Sets the stencil operation to use when depth fails
  28717. * @param operation defines the stencil operation to use when depth fails
  28718. */
  28719. setStencilOperationDepthFail(operation: number): void;
  28720. /**
  28721. * Sets the stencil operation to use when stencil passes
  28722. * @param operation defines the stencil operation to use when stencil passes
  28723. */
  28724. setStencilOperationPass(operation: number): void;
  28725. /**
  28726. * Sets a boolean indicating if the dithering state is enabled or disabled
  28727. * @param value defines the dithering state
  28728. */
  28729. setDitheringState(value: boolean): void;
  28730. /**
  28731. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28732. * @param value defines the rasterizer state
  28733. */
  28734. setRasterizerState(value: boolean): void;
  28735. /**
  28736. * stop executing a render loop function and remove it from the execution array
  28737. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28738. */
  28739. stopRenderLoop(renderFunction?: () => void): void;
  28740. /** @hidden */
  28741. _renderLoop(): void;
  28742. /**
  28743. * Register and execute a render loop. The engine can have more than one render function
  28744. * @param renderFunction defines the function to continuously execute
  28745. */
  28746. runRenderLoop(renderFunction: () => void): void;
  28747. /**
  28748. * Toggle full screen mode
  28749. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28750. */
  28751. switchFullscreen(requestPointerLock: boolean): void;
  28752. /**
  28753. * Enters full screen mode
  28754. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28755. */
  28756. enterFullscreen(requestPointerLock: boolean): void;
  28757. /**
  28758. * Exits full screen mode
  28759. */
  28760. exitFullscreen(): void;
  28761. /**
  28762. * Clear the current render buffer or the current render target (if any is set up)
  28763. * @param color defines the color to use
  28764. * @param backBuffer defines if the back buffer must be cleared
  28765. * @param depth defines if the depth buffer must be cleared
  28766. * @param stencil defines if the stencil buffer must be cleared
  28767. */
  28768. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28769. /**
  28770. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28771. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28772. * @param y defines the y-coordinate of the corner of the clear rectangle
  28773. * @param width defines the width of the clear rectangle
  28774. * @param height defines the height of the clear rectangle
  28775. * @param clearColor defines the clear color
  28776. */
  28777. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28778. /**
  28779. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28780. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28781. * @param y defines the y-coordinate of the corner of the clear rectangle
  28782. * @param width defines the width of the clear rectangle
  28783. * @param height defines the height of the clear rectangle
  28784. */
  28785. enableScissor(x: number, y: number, width: number, height: number): void;
  28786. /**
  28787. * Disable previously set scissor test rectangle
  28788. */
  28789. disableScissor(): void;
  28790. private _viewportCached;
  28791. /** @hidden */
  28792. _viewport(x: number, y: number, width: number, height: number): void;
  28793. /**
  28794. * Set the WebGL's viewport
  28795. * @param viewport defines the viewport element to be used
  28796. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28797. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28798. */
  28799. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28800. /**
  28801. * Directly set the WebGL Viewport
  28802. * @param x defines the x coordinate of the viewport (in screen space)
  28803. * @param y defines the y coordinate of the viewport (in screen space)
  28804. * @param width defines the width of the viewport (in screen space)
  28805. * @param height defines the height of the viewport (in screen space)
  28806. * @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
  28807. */
  28808. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28809. /**
  28810. * Begin a new frame
  28811. */
  28812. beginFrame(): void;
  28813. /**
  28814. * Enf the current frame
  28815. */
  28816. endFrame(): void;
  28817. /**
  28818. * Resize the view according to the canvas' size
  28819. */
  28820. resize(): void;
  28821. /**
  28822. * Force a specific size of the canvas
  28823. * @param width defines the new canvas' width
  28824. * @param height defines the new canvas' height
  28825. */
  28826. setSize(width: number, height: number): void;
  28827. /**
  28828. * Binds the frame buffer to the specified texture.
  28829. * @param texture The texture to render to or null for the default canvas
  28830. * @param faceIndex The face of the texture to render to in case of cube texture
  28831. * @param requiredWidth The width of the target to render to
  28832. * @param requiredHeight The height of the target to render to
  28833. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28834. * @param depthStencilTexture The depth stencil texture to use to render
  28835. * @param lodLevel defines le lod level to bind to the frame buffer
  28836. */
  28837. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28838. /** @hidden */
  28839. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28840. /**
  28841. * Unbind the current render target texture from the webGL context
  28842. * @param texture defines the render target texture to unbind
  28843. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28844. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28845. */
  28846. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28847. /**
  28848. * Force the mipmap generation for the given render target texture
  28849. * @param texture defines the render target texture to use
  28850. */
  28851. generateMipMapsForCubemap(texture: InternalTexture): void;
  28852. /**
  28853. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28854. */
  28855. flushFramebuffer(): void;
  28856. /**
  28857. * Unbind the current render target and bind the default framebuffer
  28858. */
  28859. restoreDefaultFramebuffer(): void;
  28860. /**
  28861. * Create an uniform buffer
  28862. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28863. * @param elements defines the content of the uniform buffer
  28864. * @returns the webGL uniform buffer
  28865. */
  28866. createUniformBuffer(elements: FloatArray): DataBuffer;
  28867. /**
  28868. * Create a dynamic uniform buffer
  28869. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28870. * @param elements defines the content of the uniform buffer
  28871. * @returns the webGL uniform buffer
  28872. */
  28873. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28874. /**
  28875. * Update an existing uniform buffer
  28876. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28877. * @param uniformBuffer defines the target uniform buffer
  28878. * @param elements defines the content to update
  28879. * @param offset defines the offset in the uniform buffer where update should start
  28880. * @param count defines the size of the data to update
  28881. */
  28882. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28883. private _resetVertexBufferBinding;
  28884. /**
  28885. * Creates a vertex buffer
  28886. * @param data the data for the vertex buffer
  28887. * @returns the new WebGL static buffer
  28888. */
  28889. createVertexBuffer(data: DataArray): DataBuffer;
  28890. /**
  28891. * Creates a dynamic vertex buffer
  28892. * @param data the data for the dynamic vertex buffer
  28893. * @returns the new WebGL dynamic buffer
  28894. */
  28895. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28896. /**
  28897. * Update a dynamic index buffer
  28898. * @param indexBuffer defines the target index buffer
  28899. * @param indices defines the data to update
  28900. * @param offset defines the offset in the target index buffer where update should start
  28901. */
  28902. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28903. /**
  28904. * Updates a dynamic vertex buffer.
  28905. * @param vertexBuffer the vertex buffer to update
  28906. * @param data the data used to update the vertex buffer
  28907. * @param byteOffset the byte offset of the data
  28908. * @param byteLength the byte length of the data
  28909. */
  28910. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28911. private _resetIndexBufferBinding;
  28912. /**
  28913. * Creates a new index buffer
  28914. * @param indices defines the content of the index buffer
  28915. * @param updatable defines if the index buffer must be updatable
  28916. * @returns a new webGL buffer
  28917. */
  28918. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28919. /**
  28920. * Bind a webGL buffer to the webGL context
  28921. * @param buffer defines the buffer to bind
  28922. */
  28923. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28924. /**
  28925. * Bind an uniform buffer to the current webGL context
  28926. * @param buffer defines the buffer to bind
  28927. */
  28928. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28929. /**
  28930. * Bind a buffer to the current webGL context at a given location
  28931. * @param buffer defines the buffer to bind
  28932. * @param location defines the index where to bind the buffer
  28933. */
  28934. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28935. /**
  28936. * Bind a specific block at a given index in a specific shader program
  28937. * @param pipelineContext defines the pipeline context to use
  28938. * @param blockName defines the block name
  28939. * @param index defines the index where to bind the block
  28940. */
  28941. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28942. private bindIndexBuffer;
  28943. private bindBuffer;
  28944. /**
  28945. * update the bound buffer with the given data
  28946. * @param data defines the data to update
  28947. */
  28948. updateArrayBuffer(data: Float32Array): void;
  28949. private _vertexAttribPointer;
  28950. private _bindIndexBufferWithCache;
  28951. private _bindVertexBuffersAttributes;
  28952. /**
  28953. * Records a vertex array object
  28954. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28955. * @param vertexBuffers defines the list of vertex buffers to store
  28956. * @param indexBuffer defines the index buffer to store
  28957. * @param effect defines the effect to store
  28958. * @returns the new vertex array object
  28959. */
  28960. recordVertexArrayObject(vertexBuffers: {
  28961. [key: string]: VertexBuffer;
  28962. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28963. /**
  28964. * Bind a specific vertex array object
  28965. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28966. * @param vertexArrayObject defines the vertex array object to bind
  28967. * @param indexBuffer defines the index buffer to bind
  28968. */
  28969. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28970. /**
  28971. * Bind webGl buffers directly to the webGL context
  28972. * @param vertexBuffer defines the vertex buffer to bind
  28973. * @param indexBuffer defines the index buffer to bind
  28974. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28975. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28976. * @param effect defines the effect associated with the vertex buffer
  28977. */
  28978. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28979. private _unbindVertexArrayObject;
  28980. /**
  28981. * Bind a list of vertex buffers to the webGL context
  28982. * @param vertexBuffers defines the list of vertex buffers to bind
  28983. * @param indexBuffer defines the index buffer to bind
  28984. * @param effect defines the effect associated with the vertex buffers
  28985. */
  28986. bindBuffers(vertexBuffers: {
  28987. [key: string]: Nullable<VertexBuffer>;
  28988. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28989. /**
  28990. * Unbind all instance attributes
  28991. */
  28992. unbindInstanceAttributes(): void;
  28993. /**
  28994. * Release and free the memory of a vertex array object
  28995. * @param vao defines the vertex array object to delete
  28996. */
  28997. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28998. /** @hidden */
  28999. _releaseBuffer(buffer: DataBuffer): boolean;
  29000. /**
  29001. * Creates a webGL buffer to use with instanciation
  29002. * @param capacity defines the size of the buffer
  29003. * @returns the webGL buffer
  29004. */
  29005. createInstancesBuffer(capacity: number): DataBuffer;
  29006. /**
  29007. * Delete a webGL buffer used with instanciation
  29008. * @param buffer defines the webGL buffer to delete
  29009. */
  29010. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29011. /**
  29012. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29013. * @param instancesBuffer defines the webGL buffer to update and bind
  29014. * @param data defines the data to store in the buffer
  29015. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29016. */
  29017. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29018. /**
  29019. * Apply all cached states (depth, culling, stencil and alpha)
  29020. */
  29021. applyStates(): void;
  29022. /**
  29023. * Send a draw order
  29024. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29025. * @param indexStart defines the starting index
  29026. * @param indexCount defines the number of index to draw
  29027. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29028. */
  29029. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29030. /**
  29031. * Draw a list of points
  29032. * @param verticesStart defines the index of first vertex to draw
  29033. * @param verticesCount defines the count of vertices to draw
  29034. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29035. */
  29036. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29037. /**
  29038. * Draw a list of unindexed primitives
  29039. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29040. * @param verticesStart defines the index of first vertex to draw
  29041. * @param verticesCount defines the count of vertices to draw
  29042. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29043. */
  29044. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29045. /**
  29046. * Draw a list of indexed primitives
  29047. * @param fillMode defines the primitive to use
  29048. * @param indexStart defines the starting index
  29049. * @param indexCount defines the number of index to draw
  29050. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29051. */
  29052. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29053. /**
  29054. * Draw a list of unindexed primitives
  29055. * @param fillMode defines the primitive to use
  29056. * @param verticesStart defines the index of first vertex to draw
  29057. * @param verticesCount defines the count of vertices to draw
  29058. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29059. */
  29060. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29061. private _drawMode;
  29062. /** @hidden */
  29063. _releaseEffect(effect: Effect): void;
  29064. /** @hidden */
  29065. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29066. /**
  29067. * Create a new effect (used to store vertex/fragment shaders)
  29068. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29069. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29070. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29071. * @param samplers defines an array of string used to represent textures
  29072. * @param defines defines the string containing the defines to use to compile the shaders
  29073. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29074. * @param onCompiled defines a function to call when the effect creation is successful
  29075. * @param onError defines a function to call when the effect creation has failed
  29076. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29077. * @returns the new Effect
  29078. */
  29079. 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;
  29080. private _compileShader;
  29081. private _compileRawShader;
  29082. /**
  29083. * Directly creates a webGL program
  29084. * @param pipelineContext defines the pipeline context to attach to
  29085. * @param vertexCode defines the vertex shader code to use
  29086. * @param fragmentCode defines the fragment shader code to use
  29087. * @param context defines the webGL context to use (if not set, the current one will be used)
  29088. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29089. * @returns the new webGL program
  29090. */
  29091. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29092. /**
  29093. * Creates a webGL program
  29094. * @param pipelineContext defines the pipeline context to attach to
  29095. * @param vertexCode defines the vertex shader code to use
  29096. * @param fragmentCode defines the fragment shader code to use
  29097. * @param defines defines the string containing the defines to use to compile the shaders
  29098. * @param context defines the webGL context to use (if not set, the current one will be used)
  29099. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29100. * @returns the new webGL program
  29101. */
  29102. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29103. /**
  29104. * Creates a new pipeline context
  29105. * @returns the new pipeline
  29106. */
  29107. createPipelineContext(): WebGLPipelineContext;
  29108. private _createShaderProgram;
  29109. private _finalizePipelineContext;
  29110. /** @hidden */
  29111. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29112. /** @hidden */
  29113. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29114. /** @hidden */
  29115. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29116. /**
  29117. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29118. * @param pipelineContext defines the pipeline context to use
  29119. * @param uniformsNames defines the list of uniform names
  29120. * @returns an array of webGL uniform locations
  29121. */
  29122. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29123. /**
  29124. * Gets the lsit of active attributes for a given webGL program
  29125. * @param pipelineContext defines the pipeline context to use
  29126. * @param attributesNames defines the list of attribute names to get
  29127. * @returns an array of indices indicating the offset of each attribute
  29128. */
  29129. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29130. /**
  29131. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29132. * @param effect defines the effect to activate
  29133. */
  29134. enableEffect(effect: Nullable<Effect>): void;
  29135. /**
  29136. * Set the value of an uniform to an array of int32
  29137. * @param uniform defines the webGL uniform location where to store the value
  29138. * @param array defines the array of int32 to store
  29139. */
  29140. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29141. /**
  29142. * Set the value of an uniform to an array of int32 (stored as vec2)
  29143. * @param uniform defines the webGL uniform location where to store the value
  29144. * @param array defines the array of int32 to store
  29145. */
  29146. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29147. /**
  29148. * Set the value of an uniform to an array of int32 (stored as vec3)
  29149. * @param uniform defines the webGL uniform location where to store the value
  29150. * @param array defines the array of int32 to store
  29151. */
  29152. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29153. /**
  29154. * Set the value of an uniform to an array of int32 (stored as vec4)
  29155. * @param uniform defines the webGL uniform location where to store the value
  29156. * @param array defines the array of int32 to store
  29157. */
  29158. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29159. /**
  29160. * Set the value of an uniform to an array of float32
  29161. * @param uniform defines the webGL uniform location where to store the value
  29162. * @param array defines the array of float32 to store
  29163. */
  29164. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29165. /**
  29166. * Set the value of an uniform to an array of float32 (stored as vec2)
  29167. * @param uniform defines the webGL uniform location where to store the value
  29168. * @param array defines the array of float32 to store
  29169. */
  29170. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29171. /**
  29172. * Set the value of an uniform to an array of float32 (stored as vec3)
  29173. * @param uniform defines the webGL uniform location where to store the value
  29174. * @param array defines the array of float32 to store
  29175. */
  29176. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29177. /**
  29178. * Set the value of an uniform to an array of float32 (stored as vec4)
  29179. * @param uniform defines the webGL uniform location where to store the value
  29180. * @param array defines the array of float32 to store
  29181. */
  29182. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29183. /**
  29184. * Set the value of an uniform to an array of number
  29185. * @param uniform defines the webGL uniform location where to store the value
  29186. * @param array defines the array of number to store
  29187. */
  29188. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29189. /**
  29190. * Set the value of an uniform to an array of number (stored as vec2)
  29191. * @param uniform defines the webGL uniform location where to store the value
  29192. * @param array defines the array of number to store
  29193. */
  29194. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29195. /**
  29196. * Set the value of an uniform to an array of number (stored as vec3)
  29197. * @param uniform defines the webGL uniform location where to store the value
  29198. * @param array defines the array of number to store
  29199. */
  29200. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29201. /**
  29202. * Set the value of an uniform to an array of number (stored as vec4)
  29203. * @param uniform defines the webGL uniform location where to store the value
  29204. * @param array defines the array of number to store
  29205. */
  29206. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29207. /**
  29208. * Set the value of an uniform to an array of float32 (stored as matrices)
  29209. * @param uniform defines the webGL uniform location where to store the value
  29210. * @param matrices defines the array of float32 to store
  29211. */
  29212. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29213. /**
  29214. * Set the value of an uniform to a matrix
  29215. * @param uniform defines the webGL uniform location where to store the value
  29216. * @param matrix defines the matrix to store
  29217. */
  29218. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29219. /**
  29220. * Set the value of an uniform to a matrix (3x3)
  29221. * @param uniform defines the webGL uniform location where to store the value
  29222. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29223. */
  29224. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29225. /**
  29226. * Set the value of an uniform to a matrix (2x2)
  29227. * @param uniform defines the webGL uniform location where to store the value
  29228. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29229. */
  29230. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29231. /**
  29232. * Set the value of an uniform to a number (int)
  29233. * @param uniform defines the webGL uniform location where to store the value
  29234. * @param value defines the int number to store
  29235. */
  29236. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29237. /**
  29238. * Set the value of an uniform to a number (float)
  29239. * @param uniform defines the webGL uniform location where to store the value
  29240. * @param value defines the float number to store
  29241. */
  29242. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29243. /**
  29244. * Set the value of an uniform to a vec2
  29245. * @param uniform defines the webGL uniform location where to store the value
  29246. * @param x defines the 1st component of the value
  29247. * @param y defines the 2nd component of the value
  29248. */
  29249. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29250. /**
  29251. * Set the value of an uniform to a vec3
  29252. * @param uniform defines the webGL uniform location where to store the value
  29253. * @param x defines the 1st component of the value
  29254. * @param y defines the 2nd component of the value
  29255. * @param z defines the 3rd component of the value
  29256. */
  29257. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29258. /**
  29259. * Set the value of an uniform to a boolean
  29260. * @param uniform defines the webGL uniform location where to store the value
  29261. * @param bool defines the boolean to store
  29262. */
  29263. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29264. /**
  29265. * Set the value of an uniform to a vec4
  29266. * @param uniform defines the webGL uniform location where to store the value
  29267. * @param x defines the 1st component of the value
  29268. * @param y defines the 2nd component of the value
  29269. * @param z defines the 3rd component of the value
  29270. * @param w defines the 4th component of the value
  29271. */
  29272. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29273. /**
  29274. * Set the value of an uniform to a Color3
  29275. * @param uniform defines the webGL uniform location where to store the value
  29276. * @param color3 defines the color to store
  29277. */
  29278. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29279. /**
  29280. * Set the value of an uniform to a Color3 and an alpha value
  29281. * @param uniform defines the webGL uniform location where to store the value
  29282. * @param color3 defines the color to store
  29283. * @param alpha defines the alpha component to store
  29284. */
  29285. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29286. /**
  29287. * Sets a Color4 on a uniform variable
  29288. * @param uniform defines the uniform location
  29289. * @param color4 defines the value to be set
  29290. */
  29291. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29292. /**
  29293. * Set various states to the webGL context
  29294. * @param culling defines backface culling state
  29295. * @param zOffset defines the value to apply to zOffset (0 by default)
  29296. * @param force defines if states must be applied even if cache is up to date
  29297. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29298. */
  29299. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29300. /**
  29301. * Set the z offset to apply to current rendering
  29302. * @param value defines the offset to apply
  29303. */
  29304. setZOffset(value: number): void;
  29305. /**
  29306. * Gets the current value of the zOffset
  29307. * @returns the current zOffset state
  29308. */
  29309. getZOffset(): number;
  29310. /**
  29311. * Enable or disable depth buffering
  29312. * @param enable defines the state to set
  29313. */
  29314. setDepthBuffer(enable: boolean): void;
  29315. /**
  29316. * Gets a boolean indicating if depth writing is enabled
  29317. * @returns the current depth writing state
  29318. */
  29319. getDepthWrite(): boolean;
  29320. /**
  29321. * Enable or disable depth writing
  29322. * @param enable defines the state to set
  29323. */
  29324. setDepthWrite(enable: boolean): void;
  29325. /**
  29326. * Enable or disable color writing
  29327. * @param enable defines the state to set
  29328. */
  29329. setColorWrite(enable: boolean): void;
  29330. /**
  29331. * Gets a boolean indicating if color writing is enabled
  29332. * @returns the current color writing state
  29333. */
  29334. getColorWrite(): boolean;
  29335. /**
  29336. * Sets alpha constants used by some alpha blending modes
  29337. * @param r defines the red component
  29338. * @param g defines the green component
  29339. * @param b defines the blue component
  29340. * @param a defines the alpha component
  29341. */
  29342. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29343. /**
  29344. * Sets the current alpha mode
  29345. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29346. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29347. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29348. */
  29349. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29350. /**
  29351. * Gets the current alpha mode
  29352. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29353. * @returns the current alpha mode
  29354. */
  29355. getAlphaMode(): number;
  29356. /**
  29357. * Clears the list of texture accessible through engine.
  29358. * This can help preventing texture load conflict due to name collision.
  29359. */
  29360. clearInternalTexturesCache(): void;
  29361. /**
  29362. * Force the entire cache to be cleared
  29363. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29364. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29365. */
  29366. wipeCaches(bruteForce?: boolean): void;
  29367. /**
  29368. * Set the compressed texture format to use, based on the formats you have, and the formats
  29369. * supported by the hardware / browser.
  29370. *
  29371. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29372. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29373. * to API arguments needed to compressed textures. This puts the burden on the container
  29374. * generator to house the arcane code for determining these for current & future formats.
  29375. *
  29376. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29377. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29378. *
  29379. * Note: The result of this call is not taken into account when a texture is base64.
  29380. *
  29381. * @param formatsAvailable defines the list of those format families you have created
  29382. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29383. *
  29384. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29385. * @returns The extension selected.
  29386. */
  29387. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29388. /** @hidden */
  29389. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29390. min: number;
  29391. mag: number;
  29392. };
  29393. /** @hidden */
  29394. _createTexture(): WebGLTexture;
  29395. /**
  29396. * Usually called from Texture.ts.
  29397. * Passed information to create a WebGLTexture
  29398. * @param urlArg defines a value which contains one of the following:
  29399. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29400. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29401. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29402. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29403. * @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)
  29404. * @param scene needed for loading to the correct scene
  29405. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29406. * @param onLoad optional callback to be called upon successful completion
  29407. * @param onError optional callback to be called upon failure
  29408. * @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
  29409. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29410. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29411. * @param forcedExtension defines the extension to use to pick the right loader
  29412. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29413. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29414. */
  29415. 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;
  29416. private _rescaleTexture;
  29417. private _unpackFlipYCached;
  29418. /**
  29419. * In case you are sharing the context with other applications, it might
  29420. * be interested to not cache the unpack flip y state to ensure a consistent
  29421. * value would be set.
  29422. */
  29423. enableUnpackFlipYCached: boolean;
  29424. /** @hidden */
  29425. _unpackFlipY(value: boolean): void;
  29426. /** @hidden */
  29427. _getUnpackAlignement(): number;
  29428. /**
  29429. * Creates a dynamic texture
  29430. * @param width defines the width of the texture
  29431. * @param height defines the height of the texture
  29432. * @param generateMipMaps defines if the engine should generate the mip levels
  29433. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29434. * @returns the dynamic texture inside an InternalTexture
  29435. */
  29436. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29437. /**
  29438. * Update the sampling mode of a given texture
  29439. * @param samplingMode defines the required sampling mode
  29440. * @param texture defines the texture to update
  29441. */
  29442. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29443. /**
  29444. * Update the content of a dynamic texture
  29445. * @param texture defines the texture to update
  29446. * @param canvas defines the canvas containing the source
  29447. * @param invertY defines if data must be stored with Y axis inverted
  29448. * @param premulAlpha defines if alpha is stored as premultiplied
  29449. * @param format defines the format of the data
  29450. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29451. */
  29452. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29453. /**
  29454. * Update a video texture
  29455. * @param texture defines the texture to update
  29456. * @param video defines the video element to use
  29457. * @param invertY defines if data must be stored with Y axis inverted
  29458. */
  29459. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29460. /**
  29461. * Updates a depth texture Comparison Mode and Function.
  29462. * If the comparison Function is equal to 0, the mode will be set to none.
  29463. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29464. * @param texture The texture to set the comparison function for
  29465. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29466. */
  29467. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29468. /** @hidden */
  29469. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29470. width: number;
  29471. height: number;
  29472. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29473. /**
  29474. * Creates a depth stencil texture.
  29475. * This is only available in WebGL 2 or with the depth texture extension available.
  29476. * @param size The size of face edge in the texture.
  29477. * @param options The options defining the texture.
  29478. * @returns The texture
  29479. */
  29480. createDepthStencilTexture(size: number | {
  29481. width: number;
  29482. height: number;
  29483. }, options: DepthTextureCreationOptions): InternalTexture;
  29484. /**
  29485. * Creates a depth stencil texture.
  29486. * This is only available in WebGL 2 or with the depth texture extension available.
  29487. * @param size The size of face edge in the texture.
  29488. * @param options The options defining the texture.
  29489. * @returns The texture
  29490. */
  29491. private _createDepthStencilTexture;
  29492. /**
  29493. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29494. * @param renderTarget The render target to set the frame buffer for
  29495. */
  29496. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29497. /**
  29498. * Creates a new render target texture
  29499. * @param size defines the size of the texture
  29500. * @param options defines the options used to create the texture
  29501. * @returns a new render target texture stored in an InternalTexture
  29502. */
  29503. createRenderTargetTexture(size: number | {
  29504. width: number;
  29505. height: number;
  29506. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29507. /** @hidden */
  29508. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29509. /**
  29510. * Updates the sample count of a render target texture
  29511. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29512. * @param texture defines the texture to update
  29513. * @param samples defines the sample count to set
  29514. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29515. */
  29516. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29517. /** @hidden */
  29518. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29519. /** @hidden */
  29520. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29521. /** @hidden */
  29522. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29523. /** @hidden */
  29524. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29525. /**
  29526. * @hidden
  29527. */
  29528. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29529. private _prepareWebGLTextureContinuation;
  29530. private _prepareWebGLTexture;
  29531. /** @hidden */
  29532. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29533. /** @hidden */
  29534. _releaseFramebufferObjects(texture: InternalTexture): void;
  29535. /** @hidden */
  29536. _releaseTexture(texture: InternalTexture): void;
  29537. private setProgram;
  29538. private _boundUniforms;
  29539. /**
  29540. * Binds an effect to the webGL context
  29541. * @param effect defines the effect to bind
  29542. */
  29543. bindSamplers(effect: Effect): void;
  29544. private _activateCurrentTexture;
  29545. /** @hidden */
  29546. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29547. /** @hidden */
  29548. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29549. /**
  29550. * Sets a texture to the webGL context from a postprocess
  29551. * @param channel defines the channel to use
  29552. * @param postProcess defines the source postprocess
  29553. */
  29554. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29555. /**
  29556. * Binds the output of the passed in post process to the texture channel specified
  29557. * @param channel The channel the texture should be bound to
  29558. * @param postProcess The post process which's output should be bound
  29559. */
  29560. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29561. /**
  29562. * Unbind all textures from the webGL context
  29563. */
  29564. unbindAllTextures(): void;
  29565. /**
  29566. * Sets a texture to the according uniform.
  29567. * @param channel The texture channel
  29568. * @param uniform The uniform to set
  29569. * @param texture The texture to apply
  29570. */
  29571. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29572. /**
  29573. * Sets a depth stencil texture from a render target to the according uniform.
  29574. * @param channel The texture channel
  29575. * @param uniform The uniform to set
  29576. * @param texture The render target texture containing the depth stencil texture to apply
  29577. */
  29578. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29579. private _bindSamplerUniformToChannel;
  29580. private _getTextureWrapMode;
  29581. private _setTexture;
  29582. /**
  29583. * Sets an array of texture to the webGL context
  29584. * @param channel defines the channel where the texture array must be set
  29585. * @param uniform defines the associated uniform location
  29586. * @param textures defines the array of textures to bind
  29587. */
  29588. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29589. /** @hidden */
  29590. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29591. private _setTextureParameterFloat;
  29592. private _setTextureParameterInteger;
  29593. /**
  29594. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29595. * @param x defines the x coordinate of the rectangle where pixels must be read
  29596. * @param y defines the y coordinate of the rectangle where pixels must be read
  29597. * @param width defines the width of the rectangle where pixels must be read
  29598. * @param height defines the height of the rectangle where pixels must be read
  29599. * @returns a Uint8Array containing RGBA colors
  29600. */
  29601. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29602. /**
  29603. * Add an externaly attached data from its key.
  29604. * This method call will fail and return false, if such key already exists.
  29605. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29606. * @param key the unique key that identifies the data
  29607. * @param data the data object to associate to the key for this Engine instance
  29608. * @return true if no such key were already present and the data was added successfully, false otherwise
  29609. */
  29610. addExternalData<T>(key: string, data: T): boolean;
  29611. /**
  29612. * Get an externaly attached data from its key
  29613. * @param key the unique key that identifies the data
  29614. * @return the associated data, if present (can be null), or undefined if not present
  29615. */
  29616. getExternalData<T>(key: string): T;
  29617. /**
  29618. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29619. * @param key the unique key that identifies the data
  29620. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29621. * @return the associated data, can be null if the factory returned null.
  29622. */
  29623. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29624. /**
  29625. * Remove an externaly attached data from the Engine instance
  29626. * @param key the unique key that identifies the data
  29627. * @return true if the data was successfully removed, false if it doesn't exist
  29628. */
  29629. removeExternalData(key: string): boolean;
  29630. /**
  29631. * Unbind all vertex attributes from the webGL context
  29632. */
  29633. unbindAllAttributes(): void;
  29634. /**
  29635. * 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
  29636. */
  29637. releaseEffects(): void;
  29638. /**
  29639. * Dispose and release all associated resources
  29640. */
  29641. dispose(): void;
  29642. /**
  29643. * Display the loading screen
  29644. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29645. */
  29646. displayLoadingUI(): void;
  29647. /**
  29648. * Hide the loading screen
  29649. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29650. */
  29651. hideLoadingUI(): void;
  29652. /**
  29653. * Gets the current loading screen object
  29654. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29655. */
  29656. /**
  29657. * Sets the current loading screen object
  29658. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29659. */
  29660. loadingScreen: ILoadingScreen;
  29661. /**
  29662. * Sets the current loading screen text
  29663. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29664. */
  29665. loadingUIText: string;
  29666. /**
  29667. * Sets the current loading screen background color
  29668. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29669. */
  29670. loadingUIBackgroundColor: string;
  29671. /**
  29672. * Attach a new callback raised when context lost event is fired
  29673. * @param callback defines the callback to call
  29674. */
  29675. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29676. /**
  29677. * Attach a new callback raised when context restored event is fired
  29678. * @param callback defines the callback to call
  29679. */
  29680. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29681. /**
  29682. * Gets the source code of the vertex shader associated with a specific webGL program
  29683. * @param program defines the program to use
  29684. * @returns a string containing the source code of the vertex shader associated with the program
  29685. */
  29686. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29687. /**
  29688. * Gets the source code of the fragment shader associated with a specific webGL program
  29689. * @param program defines the program to use
  29690. * @returns a string containing the source code of the fragment shader associated with the program
  29691. */
  29692. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29693. /**
  29694. * Get the current error code of the webGL context
  29695. * @returns the error code
  29696. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29697. */
  29698. getError(): number;
  29699. /**
  29700. * Gets the current framerate
  29701. * @returns a number representing the framerate
  29702. */
  29703. getFps(): number;
  29704. /**
  29705. * Gets the time spent between current and previous frame
  29706. * @returns a number representing the delta time in ms
  29707. */
  29708. getDeltaTime(): number;
  29709. private _measureFps;
  29710. /** @hidden */
  29711. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29712. private _canRenderToFloatFramebuffer;
  29713. private _canRenderToHalfFloatFramebuffer;
  29714. private _canRenderToFramebuffer;
  29715. /** @hidden */
  29716. _getWebGLTextureType(type: number): number;
  29717. /** @hidden */
  29718. _getInternalFormat(format: number): number;
  29719. /** @hidden */
  29720. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29721. /** @hidden */
  29722. _getRGBAMultiSampleBufferFormat(type: number): number;
  29723. /** @hidden */
  29724. _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;
  29725. /** @hidden */
  29726. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29727. /**
  29728. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29729. * @returns true if the engine can be created
  29730. * @ignorenaming
  29731. */
  29732. static isSupported(): boolean;
  29733. }
  29734. }
  29735. declare module "babylonjs/Materials/effect" {
  29736. import { Observable } from "babylonjs/Misc/observable";
  29737. import { Nullable } from "babylonjs/types";
  29738. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29739. import { IDisposable } from "babylonjs/scene";
  29740. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29741. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29742. import { Engine } from "babylonjs/Engines/engine";
  29743. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29745. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29746. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29748. /**
  29749. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29750. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29751. */
  29752. export class EffectFallbacks {
  29753. private _defines;
  29754. private _currentRank;
  29755. private _maxRank;
  29756. private _mesh;
  29757. /**
  29758. * Removes the fallback from the bound mesh.
  29759. */
  29760. unBindMesh(): void;
  29761. /**
  29762. * Adds a fallback on the specified property.
  29763. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29764. * @param define The name of the define in the shader
  29765. */
  29766. addFallback(rank: number, define: string): void;
  29767. /**
  29768. * Sets the mesh to use CPU skinning when needing to fallback.
  29769. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29770. * @param mesh The mesh to use the fallbacks.
  29771. */
  29772. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29773. /**
  29774. * Checks to see if more fallbacks are still availible.
  29775. */
  29776. readonly isMoreFallbacks: boolean;
  29777. /**
  29778. * Removes the defines that shoould be removed when falling back.
  29779. * @param currentDefines defines the current define statements for the shader.
  29780. * @param effect defines the current effect we try to compile
  29781. * @returns The resulting defines with defines of the current rank removed.
  29782. */
  29783. reduce(currentDefines: string, effect: Effect): string;
  29784. }
  29785. /**
  29786. * Options to be used when creating an effect.
  29787. */
  29788. export class EffectCreationOptions {
  29789. /**
  29790. * Atrributes that will be used in the shader.
  29791. */
  29792. attributes: string[];
  29793. /**
  29794. * Uniform varible names that will be set in the shader.
  29795. */
  29796. uniformsNames: string[];
  29797. /**
  29798. * Uniform buffer varible names that will be set in the shader.
  29799. */
  29800. uniformBuffersNames: string[];
  29801. /**
  29802. * Sampler texture variable names that will be set in the shader.
  29803. */
  29804. samplers: string[];
  29805. /**
  29806. * Define statements that will be set in the shader.
  29807. */
  29808. defines: any;
  29809. /**
  29810. * Possible fallbacks for this effect to improve performance when needed.
  29811. */
  29812. fallbacks: Nullable<EffectFallbacks>;
  29813. /**
  29814. * Callback that will be called when the shader is compiled.
  29815. */
  29816. onCompiled: Nullable<(effect: Effect) => void>;
  29817. /**
  29818. * Callback that will be called if an error occurs during shader compilation.
  29819. */
  29820. onError: Nullable<(effect: Effect, errors: string) => void>;
  29821. /**
  29822. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29823. */
  29824. indexParameters: any;
  29825. /**
  29826. * Max number of lights that can be used in the shader.
  29827. */
  29828. maxSimultaneousLights: number;
  29829. /**
  29830. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29831. */
  29832. transformFeedbackVaryings: Nullable<string[]>;
  29833. }
  29834. /**
  29835. * Effect containing vertex and fragment shader that can be executed on an object.
  29836. */
  29837. export class Effect implements IDisposable {
  29838. /**
  29839. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29840. */
  29841. static ShadersRepository: string;
  29842. /**
  29843. * Name of the effect.
  29844. */
  29845. name: any;
  29846. /**
  29847. * String container all the define statements that should be set on the shader.
  29848. */
  29849. defines: string;
  29850. /**
  29851. * Callback that will be called when the shader is compiled.
  29852. */
  29853. onCompiled: Nullable<(effect: Effect) => void>;
  29854. /**
  29855. * Callback that will be called if an error occurs during shader compilation.
  29856. */
  29857. onError: Nullable<(effect: Effect, errors: string) => void>;
  29858. /**
  29859. * Callback that will be called when effect is bound.
  29860. */
  29861. onBind: Nullable<(effect: Effect) => void>;
  29862. /**
  29863. * Unique ID of the effect.
  29864. */
  29865. uniqueId: number;
  29866. /**
  29867. * Observable that will be called when the shader is compiled.
  29868. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29869. */
  29870. onCompileObservable: Observable<Effect>;
  29871. /**
  29872. * Observable that will be called if an error occurs during shader compilation.
  29873. */
  29874. onErrorObservable: Observable<Effect>;
  29875. /** @hidden */
  29876. _onBindObservable: Nullable<Observable<Effect>>;
  29877. /**
  29878. * Observable that will be called when effect is bound.
  29879. */
  29880. readonly onBindObservable: Observable<Effect>;
  29881. /** @hidden */
  29882. _bonesComputationForcedToCPU: boolean;
  29883. private static _uniqueIdSeed;
  29884. private _engine;
  29885. private _uniformBuffersNames;
  29886. private _uniformsNames;
  29887. private _samplerList;
  29888. private _samplers;
  29889. private _isReady;
  29890. private _compilationError;
  29891. private _attributesNames;
  29892. private _attributes;
  29893. private _uniforms;
  29894. /**
  29895. * Key for the effect.
  29896. * @hidden
  29897. */
  29898. _key: string;
  29899. private _indexParameters;
  29900. private _fallbacks;
  29901. private _vertexSourceCode;
  29902. private _fragmentSourceCode;
  29903. private _vertexSourceCodeOverride;
  29904. private _fragmentSourceCodeOverride;
  29905. private _transformFeedbackVaryings;
  29906. /**
  29907. * Compiled shader to webGL program.
  29908. * @hidden
  29909. */
  29910. _pipelineContext: Nullable<IPipelineContext>;
  29911. private _valueCache;
  29912. private static _baseCache;
  29913. /**
  29914. * Instantiates an effect.
  29915. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29916. * @param baseName Name of the effect.
  29917. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29918. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29919. * @param samplers List of sampler variables that will be passed to the shader.
  29920. * @param engine Engine to be used to render the effect
  29921. * @param defines Define statements to be added to the shader.
  29922. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29923. * @param onCompiled Callback that will be called when the shader is compiled.
  29924. * @param onError Callback that will be called if an error occurs during shader compilation.
  29925. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29926. */
  29927. 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);
  29928. /**
  29929. * Unique key for this effect
  29930. */
  29931. readonly key: string;
  29932. /**
  29933. * If the effect has been compiled and prepared.
  29934. * @returns if the effect is compiled and prepared.
  29935. */
  29936. isReady(): boolean;
  29937. /**
  29938. * The engine the effect was initialized with.
  29939. * @returns the engine.
  29940. */
  29941. getEngine(): Engine;
  29942. /**
  29943. * The pipeline context for this effect
  29944. * @returns the associated pipeline context
  29945. */
  29946. getPipelineContext(): Nullable<IPipelineContext>;
  29947. /**
  29948. * The set of names of attribute variables for the shader.
  29949. * @returns An array of attribute names.
  29950. */
  29951. getAttributesNames(): string[];
  29952. /**
  29953. * Returns the attribute at the given index.
  29954. * @param index The index of the attribute.
  29955. * @returns The location of the attribute.
  29956. */
  29957. getAttributeLocation(index: number): number;
  29958. /**
  29959. * Returns the attribute based on the name of the variable.
  29960. * @param name of the attribute to look up.
  29961. * @returns the attribute location.
  29962. */
  29963. getAttributeLocationByName(name: string): number;
  29964. /**
  29965. * The number of attributes.
  29966. * @returns the numnber of attributes.
  29967. */
  29968. getAttributesCount(): number;
  29969. /**
  29970. * Gets the index of a uniform variable.
  29971. * @param uniformName of the uniform to look up.
  29972. * @returns the index.
  29973. */
  29974. getUniformIndex(uniformName: string): number;
  29975. /**
  29976. * Returns the attribute based on the name of the variable.
  29977. * @param uniformName of the uniform to look up.
  29978. * @returns the location of the uniform.
  29979. */
  29980. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29981. /**
  29982. * Returns an array of sampler variable names
  29983. * @returns The array of sampler variable neames.
  29984. */
  29985. getSamplers(): string[];
  29986. /**
  29987. * The error from the last compilation.
  29988. * @returns the error string.
  29989. */
  29990. getCompilationError(): string;
  29991. /**
  29992. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29993. * @param func The callback to be used.
  29994. */
  29995. executeWhenCompiled(func: (effect: Effect) => void): void;
  29996. private _checkIsReady;
  29997. /** @hidden */
  29998. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29999. /** @hidden */
  30000. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30001. /** @hidden */
  30002. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30003. private _processShaderConversion;
  30004. private _processIncludes;
  30005. private _processPrecision;
  30006. /**
  30007. * Recompiles the webGL program
  30008. * @param vertexSourceCode The source code for the vertex shader.
  30009. * @param fragmentSourceCode The source code for the fragment shader.
  30010. * @param onCompiled Callback called when completed.
  30011. * @param onError Callback called on error.
  30012. * @hidden
  30013. */
  30014. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30015. /**
  30016. * Prepares the effect
  30017. * @hidden
  30018. */
  30019. _prepareEffect(): void;
  30020. /**
  30021. * Checks if the effect is supported. (Must be called after compilation)
  30022. */
  30023. readonly isSupported: boolean;
  30024. /**
  30025. * Binds a texture to the engine to be used as output of the shader.
  30026. * @param channel Name of the output variable.
  30027. * @param texture Texture to bind.
  30028. * @hidden
  30029. */
  30030. _bindTexture(channel: string, texture: InternalTexture): void;
  30031. /**
  30032. * Sets a texture on the engine to be used in the shader.
  30033. * @param channel Name of the sampler variable.
  30034. * @param texture Texture to set.
  30035. */
  30036. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30037. /**
  30038. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30039. * @param channel Name of the sampler variable.
  30040. * @param texture Texture to set.
  30041. */
  30042. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30043. /**
  30044. * Sets an array of textures on the engine to be used in the shader.
  30045. * @param channel Name of the variable.
  30046. * @param textures Textures to set.
  30047. */
  30048. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30049. /**
  30050. * 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)
  30051. * @param channel Name of the sampler variable.
  30052. * @param postProcess Post process to get the input texture from.
  30053. */
  30054. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30055. /**
  30056. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30057. * 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)
  30058. * @param channel Name of the sampler variable.
  30059. * @param postProcess Post process to get the output texture from.
  30060. */
  30061. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30062. /** @hidden */
  30063. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30064. /** @hidden */
  30065. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30066. /** @hidden */
  30067. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30068. /** @hidden */
  30069. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30070. /**
  30071. * Binds a buffer to a uniform.
  30072. * @param buffer Buffer to bind.
  30073. * @param name Name of the uniform variable to bind to.
  30074. */
  30075. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30076. /**
  30077. * Binds block to a uniform.
  30078. * @param blockName Name of the block to bind.
  30079. * @param index Index to bind.
  30080. */
  30081. bindUniformBlock(blockName: string, index: number): void;
  30082. /**
  30083. * Sets an interger value on a uniform variable.
  30084. * @param uniformName Name of the variable.
  30085. * @param value Value to be set.
  30086. * @returns this effect.
  30087. */
  30088. setInt(uniformName: string, value: number): Effect;
  30089. /**
  30090. * Sets an int array on a uniform variable.
  30091. * @param uniformName Name of the variable.
  30092. * @param array array to be set.
  30093. * @returns this effect.
  30094. */
  30095. setIntArray(uniformName: string, array: Int32Array): Effect;
  30096. /**
  30097. * 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)
  30098. * @param uniformName Name of the variable.
  30099. * @param array array to be set.
  30100. * @returns this effect.
  30101. */
  30102. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30103. /**
  30104. * 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)
  30105. * @param uniformName Name of the variable.
  30106. * @param array array to be set.
  30107. * @returns this effect.
  30108. */
  30109. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30110. /**
  30111. * 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)
  30112. * @param uniformName Name of the variable.
  30113. * @param array array to be set.
  30114. * @returns this effect.
  30115. */
  30116. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30117. /**
  30118. * Sets an float array on a uniform variable.
  30119. * @param uniformName Name of the variable.
  30120. * @param array array to be set.
  30121. * @returns this effect.
  30122. */
  30123. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30124. /**
  30125. * 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)
  30126. * @param uniformName Name of the variable.
  30127. * @param array array to be set.
  30128. * @returns this effect.
  30129. */
  30130. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30131. /**
  30132. * 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)
  30133. * @param uniformName Name of the variable.
  30134. * @param array array to be set.
  30135. * @returns this effect.
  30136. */
  30137. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30138. /**
  30139. * 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)
  30140. * @param uniformName Name of the variable.
  30141. * @param array array to be set.
  30142. * @returns this effect.
  30143. */
  30144. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30145. /**
  30146. * Sets an array on a uniform variable.
  30147. * @param uniformName Name of the variable.
  30148. * @param array array to be set.
  30149. * @returns this effect.
  30150. */
  30151. setArray(uniformName: string, array: number[]): Effect;
  30152. /**
  30153. * 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)
  30154. * @param uniformName Name of the variable.
  30155. * @param array array to be set.
  30156. * @returns this effect.
  30157. */
  30158. setArray2(uniformName: string, array: number[]): Effect;
  30159. /**
  30160. * 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)
  30161. * @param uniformName Name of the variable.
  30162. * @param array array to be set.
  30163. * @returns this effect.
  30164. */
  30165. setArray3(uniformName: string, array: number[]): Effect;
  30166. /**
  30167. * 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)
  30168. * @param uniformName Name of the variable.
  30169. * @param array array to be set.
  30170. * @returns this effect.
  30171. */
  30172. setArray4(uniformName: string, array: number[]): Effect;
  30173. /**
  30174. * Sets matrices on a uniform variable.
  30175. * @param uniformName Name of the variable.
  30176. * @param matrices matrices to be set.
  30177. * @returns this effect.
  30178. */
  30179. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30180. /**
  30181. * Sets matrix on a uniform variable.
  30182. * @param uniformName Name of the variable.
  30183. * @param matrix matrix to be set.
  30184. * @returns this effect.
  30185. */
  30186. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30187. /**
  30188. * 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)
  30189. * @param uniformName Name of the variable.
  30190. * @param matrix matrix to be set.
  30191. * @returns this effect.
  30192. */
  30193. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30194. /**
  30195. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30196. * @param uniformName Name of the variable.
  30197. * @param matrix matrix to be set.
  30198. * @returns this effect.
  30199. */
  30200. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30201. /**
  30202. * Sets a float on a uniform variable.
  30203. * @param uniformName Name of the variable.
  30204. * @param value value to be set.
  30205. * @returns this effect.
  30206. */
  30207. setFloat(uniformName: string, value: number): Effect;
  30208. /**
  30209. * Sets a boolean on a uniform variable.
  30210. * @param uniformName Name of the variable.
  30211. * @param bool value to be set.
  30212. * @returns this effect.
  30213. */
  30214. setBool(uniformName: string, bool: boolean): Effect;
  30215. /**
  30216. * Sets a Vector2 on a uniform variable.
  30217. * @param uniformName Name of the variable.
  30218. * @param vector2 vector2 to be set.
  30219. * @returns this effect.
  30220. */
  30221. setVector2(uniformName: string, vector2: Vector2): Effect;
  30222. /**
  30223. * Sets a float2 on a uniform variable.
  30224. * @param uniformName Name of the variable.
  30225. * @param x First float in float2.
  30226. * @param y Second float in float2.
  30227. * @returns this effect.
  30228. */
  30229. setFloat2(uniformName: string, x: number, y: number): Effect;
  30230. /**
  30231. * Sets a Vector3 on a uniform variable.
  30232. * @param uniformName Name of the variable.
  30233. * @param vector3 Value to be set.
  30234. * @returns this effect.
  30235. */
  30236. setVector3(uniformName: string, vector3: Vector3): Effect;
  30237. /**
  30238. * Sets a float3 on a uniform variable.
  30239. * @param uniformName Name of the variable.
  30240. * @param x First float in float3.
  30241. * @param y Second float in float3.
  30242. * @param z Third float in float3.
  30243. * @returns this effect.
  30244. */
  30245. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30246. /**
  30247. * Sets a Vector4 on a uniform variable.
  30248. * @param uniformName Name of the variable.
  30249. * @param vector4 Value to be set.
  30250. * @returns this effect.
  30251. */
  30252. setVector4(uniformName: string, vector4: Vector4): Effect;
  30253. /**
  30254. * Sets a float4 on a uniform variable.
  30255. * @param uniformName Name of the variable.
  30256. * @param x First float in float4.
  30257. * @param y Second float in float4.
  30258. * @param z Third float in float4.
  30259. * @param w Fourth float in float4.
  30260. * @returns this effect.
  30261. */
  30262. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30263. /**
  30264. * Sets a Color3 on a uniform variable.
  30265. * @param uniformName Name of the variable.
  30266. * @param color3 Value to be set.
  30267. * @returns this effect.
  30268. */
  30269. setColor3(uniformName: string, color3: Color3): Effect;
  30270. /**
  30271. * Sets a Color4 on a uniform variable.
  30272. * @param uniformName Name of the variable.
  30273. * @param color3 Value to be set.
  30274. * @param alpha Alpha value to be set.
  30275. * @returns this effect.
  30276. */
  30277. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30278. /**
  30279. * Sets a Color4 on a uniform variable
  30280. * @param uniformName defines the name of the variable
  30281. * @param color4 defines the value to be set
  30282. * @returns this effect.
  30283. */
  30284. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30285. /** Release all associated resources */
  30286. dispose(): void;
  30287. /**
  30288. * This function will add a new shader to the shader store
  30289. * @param name the name of the shader
  30290. * @param pixelShader optional pixel shader content
  30291. * @param vertexShader optional vertex shader content
  30292. */
  30293. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30294. /**
  30295. * Store of each shader (The can be looked up using effect.key)
  30296. */
  30297. static ShadersStore: {
  30298. [key: string]: string;
  30299. };
  30300. /**
  30301. * Store of each included file for a shader (The can be looked up using effect.key)
  30302. */
  30303. static IncludesShadersStore: {
  30304. [key: string]: string;
  30305. };
  30306. /**
  30307. * Resets the cache of effects.
  30308. */
  30309. static ResetCache(): void;
  30310. }
  30311. }
  30312. declare module "babylonjs/Materials/colorCurves" {
  30313. import { Effect } from "babylonjs/Materials/effect";
  30314. /**
  30315. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30316. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30317. * 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;
  30318. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30319. */
  30320. export class ColorCurves {
  30321. private _dirty;
  30322. private _tempColor;
  30323. private _globalCurve;
  30324. private _highlightsCurve;
  30325. private _midtonesCurve;
  30326. private _shadowsCurve;
  30327. private _positiveCurve;
  30328. private _negativeCurve;
  30329. private _globalHue;
  30330. private _globalDensity;
  30331. private _globalSaturation;
  30332. private _globalExposure;
  30333. /**
  30334. * Gets the global Hue value.
  30335. * 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).
  30336. */
  30337. /**
  30338. * Sets the global Hue value.
  30339. * 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).
  30340. */
  30341. globalHue: number;
  30342. /**
  30343. * Gets the global Density value.
  30344. * 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.
  30345. * Values less than zero provide a filter of opposite hue.
  30346. */
  30347. /**
  30348. * Sets the global Density value.
  30349. * 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.
  30350. * Values less than zero provide a filter of opposite hue.
  30351. */
  30352. globalDensity: number;
  30353. /**
  30354. * Gets the global Saturation value.
  30355. * 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.
  30356. */
  30357. /**
  30358. * Sets the global Saturation value.
  30359. * 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.
  30360. */
  30361. globalSaturation: number;
  30362. /**
  30363. * Gets the global Exposure value.
  30364. * 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.
  30365. */
  30366. /**
  30367. * Sets the global Exposure value.
  30368. * 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.
  30369. */
  30370. globalExposure: number;
  30371. private _highlightsHue;
  30372. private _highlightsDensity;
  30373. private _highlightsSaturation;
  30374. private _highlightsExposure;
  30375. /**
  30376. * Gets the highlights Hue value.
  30377. * 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).
  30378. */
  30379. /**
  30380. * Sets the highlights Hue value.
  30381. * 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).
  30382. */
  30383. highlightsHue: number;
  30384. /**
  30385. * Gets the highlights Density value.
  30386. * 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.
  30387. * Values less than zero provide a filter of opposite hue.
  30388. */
  30389. /**
  30390. * Sets the highlights Density value.
  30391. * 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.
  30392. * Values less than zero provide a filter of opposite hue.
  30393. */
  30394. highlightsDensity: number;
  30395. /**
  30396. * Gets the highlights Saturation value.
  30397. * 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.
  30398. */
  30399. /**
  30400. * Sets the highlights Saturation value.
  30401. * 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.
  30402. */
  30403. highlightsSaturation: number;
  30404. /**
  30405. * Gets the highlights Exposure value.
  30406. * 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.
  30407. */
  30408. /**
  30409. * Sets the highlights Exposure value.
  30410. * 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.
  30411. */
  30412. highlightsExposure: number;
  30413. private _midtonesHue;
  30414. private _midtonesDensity;
  30415. private _midtonesSaturation;
  30416. private _midtonesExposure;
  30417. /**
  30418. * Gets the midtones Hue value.
  30419. * 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).
  30420. */
  30421. /**
  30422. * Sets the midtones Hue value.
  30423. * 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).
  30424. */
  30425. midtonesHue: number;
  30426. /**
  30427. * Gets the midtones Density value.
  30428. * 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.
  30429. * Values less than zero provide a filter of opposite hue.
  30430. */
  30431. /**
  30432. * Sets the midtones Density value.
  30433. * 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.
  30434. * Values less than zero provide a filter of opposite hue.
  30435. */
  30436. midtonesDensity: number;
  30437. /**
  30438. * Gets the midtones Saturation value.
  30439. * 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.
  30440. */
  30441. /**
  30442. * Sets the midtones Saturation value.
  30443. * 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.
  30444. */
  30445. midtonesSaturation: number;
  30446. /**
  30447. * Gets the midtones Exposure value.
  30448. * 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.
  30449. */
  30450. /**
  30451. * Sets the midtones Exposure value.
  30452. * 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.
  30453. */
  30454. midtonesExposure: number;
  30455. private _shadowsHue;
  30456. private _shadowsDensity;
  30457. private _shadowsSaturation;
  30458. private _shadowsExposure;
  30459. /**
  30460. * Gets the shadows Hue value.
  30461. * 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).
  30462. */
  30463. /**
  30464. * Sets the shadows Hue value.
  30465. * 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).
  30466. */
  30467. shadowsHue: number;
  30468. /**
  30469. * Gets the shadows Density value.
  30470. * 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.
  30471. * Values less than zero provide a filter of opposite hue.
  30472. */
  30473. /**
  30474. * Sets the shadows Density value.
  30475. * 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.
  30476. * Values less than zero provide a filter of opposite hue.
  30477. */
  30478. shadowsDensity: number;
  30479. /**
  30480. * Gets the shadows Saturation value.
  30481. * 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.
  30482. */
  30483. /**
  30484. * Sets the shadows Saturation value.
  30485. * 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.
  30486. */
  30487. shadowsSaturation: number;
  30488. /**
  30489. * Gets the shadows Exposure value.
  30490. * 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.
  30491. */
  30492. /**
  30493. * Sets the shadows Exposure value.
  30494. * 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.
  30495. */
  30496. shadowsExposure: number;
  30497. /**
  30498. * Returns the class name
  30499. * @returns The class name
  30500. */
  30501. getClassName(): string;
  30502. /**
  30503. * Binds the color curves to the shader.
  30504. * @param colorCurves The color curve to bind
  30505. * @param effect The effect to bind to
  30506. * @param positiveUniform The positive uniform shader parameter
  30507. * @param neutralUniform The neutral uniform shader parameter
  30508. * @param negativeUniform The negative uniform shader parameter
  30509. */
  30510. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30511. /**
  30512. * Prepare the list of uniforms associated with the ColorCurves effects.
  30513. * @param uniformsList The list of uniforms used in the effect
  30514. */
  30515. static PrepareUniforms(uniformsList: string[]): void;
  30516. /**
  30517. * Returns color grading data based on a hue, density, saturation and exposure value.
  30518. * @param filterHue The hue of the color filter.
  30519. * @param filterDensity The density of the color filter.
  30520. * @param saturation The saturation.
  30521. * @param exposure The exposure.
  30522. * @param result The result data container.
  30523. */
  30524. private getColorGradingDataToRef;
  30525. /**
  30526. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30527. * @param value The input slider value in range [-100,100].
  30528. * @returns Adjusted value.
  30529. */
  30530. private static applyColorGradingSliderNonlinear;
  30531. /**
  30532. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30533. * @param hue The hue (H) input.
  30534. * @param saturation The saturation (S) input.
  30535. * @param brightness The brightness (B) input.
  30536. * @result An RGBA color represented as Vector4.
  30537. */
  30538. private static fromHSBToRef;
  30539. /**
  30540. * Returns a value clamped between min and max
  30541. * @param value The value to clamp
  30542. * @param min The minimum of value
  30543. * @param max The maximum of value
  30544. * @returns The clamped value.
  30545. */
  30546. private static clamp;
  30547. /**
  30548. * Clones the current color curve instance.
  30549. * @return The cloned curves
  30550. */
  30551. clone(): ColorCurves;
  30552. /**
  30553. * Serializes the current color curve instance to a json representation.
  30554. * @return a JSON representation
  30555. */
  30556. serialize(): any;
  30557. /**
  30558. * Parses the color curve from a json representation.
  30559. * @param source the JSON source to parse
  30560. * @return The parsed curves
  30561. */
  30562. static Parse(source: any): ColorCurves;
  30563. }
  30564. }
  30565. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30566. import { Observable } from "babylonjs/Misc/observable";
  30567. import { Nullable } from "babylonjs/types";
  30568. import { Color4 } from "babylonjs/Maths/math";
  30569. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30570. import { Effect } from "babylonjs/Materials/effect";
  30571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30572. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30573. /**
  30574. * Interface to follow in your material defines to integrate easily the
  30575. * Image proccessing functions.
  30576. * @hidden
  30577. */
  30578. export interface IImageProcessingConfigurationDefines {
  30579. IMAGEPROCESSING: boolean;
  30580. VIGNETTE: boolean;
  30581. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30582. VIGNETTEBLENDMODEOPAQUE: boolean;
  30583. TONEMAPPING: boolean;
  30584. TONEMAPPING_ACES: boolean;
  30585. CONTRAST: boolean;
  30586. EXPOSURE: boolean;
  30587. COLORCURVES: boolean;
  30588. COLORGRADING: boolean;
  30589. COLORGRADING3D: boolean;
  30590. SAMPLER3DGREENDEPTH: boolean;
  30591. SAMPLER3DBGRMAP: boolean;
  30592. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30593. }
  30594. /**
  30595. * @hidden
  30596. */
  30597. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30598. IMAGEPROCESSING: boolean;
  30599. VIGNETTE: boolean;
  30600. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30601. VIGNETTEBLENDMODEOPAQUE: boolean;
  30602. TONEMAPPING: boolean;
  30603. TONEMAPPING_ACES: boolean;
  30604. CONTRAST: boolean;
  30605. COLORCURVES: boolean;
  30606. COLORGRADING: boolean;
  30607. COLORGRADING3D: boolean;
  30608. SAMPLER3DGREENDEPTH: boolean;
  30609. SAMPLER3DBGRMAP: boolean;
  30610. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30611. EXPOSURE: boolean;
  30612. constructor();
  30613. }
  30614. /**
  30615. * This groups together the common properties used for image processing either in direct forward pass
  30616. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30617. * or not.
  30618. */
  30619. export class ImageProcessingConfiguration {
  30620. /**
  30621. * Default tone mapping applied in BabylonJS.
  30622. */
  30623. static readonly TONEMAPPING_STANDARD: number;
  30624. /**
  30625. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30626. * to other engines rendering to increase portability.
  30627. */
  30628. static readonly TONEMAPPING_ACES: number;
  30629. /**
  30630. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30631. */
  30632. colorCurves: Nullable<ColorCurves>;
  30633. private _colorCurvesEnabled;
  30634. /**
  30635. * Gets wether the color curves effect is enabled.
  30636. */
  30637. /**
  30638. * Sets wether the color curves effect is enabled.
  30639. */
  30640. colorCurvesEnabled: boolean;
  30641. private _colorGradingTexture;
  30642. /**
  30643. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30644. */
  30645. /**
  30646. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30647. */
  30648. colorGradingTexture: Nullable<BaseTexture>;
  30649. private _colorGradingEnabled;
  30650. /**
  30651. * Gets wether the color grading effect is enabled.
  30652. */
  30653. /**
  30654. * Sets wether the color grading effect is enabled.
  30655. */
  30656. colorGradingEnabled: boolean;
  30657. private _colorGradingWithGreenDepth;
  30658. /**
  30659. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30660. */
  30661. /**
  30662. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30663. */
  30664. colorGradingWithGreenDepth: boolean;
  30665. private _colorGradingBGR;
  30666. /**
  30667. * Gets wether the color grading texture contains BGR values.
  30668. */
  30669. /**
  30670. * Sets wether the color grading texture contains BGR values.
  30671. */
  30672. colorGradingBGR: boolean;
  30673. /** @hidden */
  30674. _exposure: number;
  30675. /**
  30676. * Gets the Exposure used in the effect.
  30677. */
  30678. /**
  30679. * Sets the Exposure used in the effect.
  30680. */
  30681. exposure: number;
  30682. private _toneMappingEnabled;
  30683. /**
  30684. * Gets wether the tone mapping effect is enabled.
  30685. */
  30686. /**
  30687. * Sets wether the tone mapping effect is enabled.
  30688. */
  30689. toneMappingEnabled: boolean;
  30690. private _toneMappingType;
  30691. /**
  30692. * Gets the type of tone mapping effect.
  30693. */
  30694. /**
  30695. * Sets the type of tone mapping effect used in BabylonJS.
  30696. */
  30697. toneMappingType: number;
  30698. protected _contrast: number;
  30699. /**
  30700. * Gets the contrast used in the effect.
  30701. */
  30702. /**
  30703. * Sets the contrast used in the effect.
  30704. */
  30705. contrast: number;
  30706. /**
  30707. * Vignette stretch size.
  30708. */
  30709. vignetteStretch: number;
  30710. /**
  30711. * Vignette centre X Offset.
  30712. */
  30713. vignetteCentreX: number;
  30714. /**
  30715. * Vignette centre Y Offset.
  30716. */
  30717. vignetteCentreY: number;
  30718. /**
  30719. * Vignette weight or intensity of the vignette effect.
  30720. */
  30721. vignetteWeight: number;
  30722. /**
  30723. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30724. * if vignetteEnabled is set to true.
  30725. */
  30726. vignetteColor: Color4;
  30727. /**
  30728. * Camera field of view used by the Vignette effect.
  30729. */
  30730. vignetteCameraFov: number;
  30731. private _vignetteBlendMode;
  30732. /**
  30733. * Gets the vignette blend mode allowing different kind of effect.
  30734. */
  30735. /**
  30736. * Sets the vignette blend mode allowing different kind of effect.
  30737. */
  30738. vignetteBlendMode: number;
  30739. private _vignetteEnabled;
  30740. /**
  30741. * Gets wether the vignette effect is enabled.
  30742. */
  30743. /**
  30744. * Sets wether the vignette effect is enabled.
  30745. */
  30746. vignetteEnabled: boolean;
  30747. private _applyByPostProcess;
  30748. /**
  30749. * Gets wether the image processing is applied through a post process or not.
  30750. */
  30751. /**
  30752. * Sets wether the image processing is applied through a post process or not.
  30753. */
  30754. applyByPostProcess: boolean;
  30755. private _isEnabled;
  30756. /**
  30757. * Gets wether the image processing is enabled or not.
  30758. */
  30759. /**
  30760. * Sets wether the image processing is enabled or not.
  30761. */
  30762. isEnabled: boolean;
  30763. /**
  30764. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30765. */
  30766. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30767. /**
  30768. * Method called each time the image processing information changes requires to recompile the effect.
  30769. */
  30770. protected _updateParameters(): void;
  30771. /**
  30772. * Gets the current class name.
  30773. * @return "ImageProcessingConfiguration"
  30774. */
  30775. getClassName(): string;
  30776. /**
  30777. * Prepare the list of uniforms associated with the Image Processing effects.
  30778. * @param uniforms The list of uniforms used in the effect
  30779. * @param defines the list of defines currently in use
  30780. */
  30781. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30782. /**
  30783. * Prepare the list of samplers associated with the Image Processing effects.
  30784. * @param samplersList The list of uniforms used in the effect
  30785. * @param defines the list of defines currently in use
  30786. */
  30787. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30788. /**
  30789. * Prepare the list of defines associated to the shader.
  30790. * @param defines the list of defines to complete
  30791. * @param forPostProcess Define if we are currently in post process mode or not
  30792. */
  30793. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30794. /**
  30795. * Returns true if all the image processing information are ready.
  30796. * @returns True if ready, otherwise, false
  30797. */
  30798. isReady(): boolean;
  30799. /**
  30800. * Binds the image processing to the shader.
  30801. * @param effect The effect to bind to
  30802. * @param aspectRatio Define the current aspect ratio of the effect
  30803. */
  30804. bind(effect: Effect, aspectRatio?: number): void;
  30805. /**
  30806. * Clones the current image processing instance.
  30807. * @return The cloned image processing
  30808. */
  30809. clone(): ImageProcessingConfiguration;
  30810. /**
  30811. * Serializes the current image processing instance to a json representation.
  30812. * @return a JSON representation
  30813. */
  30814. serialize(): any;
  30815. /**
  30816. * Parses the image processing from a json representation.
  30817. * @param source the JSON source to parse
  30818. * @return The parsed image processing
  30819. */
  30820. static Parse(source: any): ImageProcessingConfiguration;
  30821. private static _VIGNETTEMODE_MULTIPLY;
  30822. private static _VIGNETTEMODE_OPAQUE;
  30823. /**
  30824. * Used to apply the vignette as a mix with the pixel color.
  30825. */
  30826. static readonly VIGNETTEMODE_MULTIPLY: number;
  30827. /**
  30828. * Used to apply the vignette as a replacement of the pixel color.
  30829. */
  30830. static readonly VIGNETTEMODE_OPAQUE: number;
  30831. }
  30832. }
  30833. declare module "babylonjs/Materials/fresnelParameters" {
  30834. import { Color3 } from "babylonjs/Maths/math";
  30835. /**
  30836. * This represents all the required information to add a fresnel effect on a material:
  30837. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30838. */
  30839. export class FresnelParameters {
  30840. private _isEnabled;
  30841. /**
  30842. * Define if the fresnel effect is enable or not.
  30843. */
  30844. isEnabled: boolean;
  30845. /**
  30846. * Define the color used on edges (grazing angle)
  30847. */
  30848. leftColor: Color3;
  30849. /**
  30850. * Define the color used on center
  30851. */
  30852. rightColor: Color3;
  30853. /**
  30854. * Define bias applied to computed fresnel term
  30855. */
  30856. bias: number;
  30857. /**
  30858. * Defined the power exponent applied to fresnel term
  30859. */
  30860. power: number;
  30861. /**
  30862. * Clones the current fresnel and its valuues
  30863. * @returns a clone fresnel configuration
  30864. */
  30865. clone(): FresnelParameters;
  30866. /**
  30867. * Serializes the current fresnel parameters to a JSON representation.
  30868. * @return the JSON serialization
  30869. */
  30870. serialize(): any;
  30871. /**
  30872. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30873. * @param parsedFresnelParameters Define the JSON representation
  30874. * @returns the parsed parameters
  30875. */
  30876. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30877. }
  30878. }
  30879. declare module "babylonjs/Misc/decorators" {
  30880. import { Nullable } from "babylonjs/types";
  30881. import { Scene } from "babylonjs/scene";
  30882. import { IAnimatable } from "babylonjs/Misc/tools";
  30883. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30884. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30885. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30886. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30887. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30888. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30889. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30890. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30891. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30892. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30893. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30894. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30895. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30896. /**
  30897. * Decorator used to define property that can be serialized as reference to a camera
  30898. * @param sourceName defines the name of the property to decorate
  30899. */
  30900. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30901. /**
  30902. * Class used to help serialization objects
  30903. */
  30904. export class SerializationHelper {
  30905. /** hidden */
  30906. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30907. /** hidden */
  30908. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30909. /** hidden */
  30910. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30911. /** hidden */
  30912. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30913. /**
  30914. * Appends the serialized animations from the source animations
  30915. * @param source Source containing the animations
  30916. * @param destination Target to store the animations
  30917. */
  30918. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30919. /**
  30920. * Static function used to serialized a specific entity
  30921. * @param entity defines the entity to serialize
  30922. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30923. * @returns a JSON compatible object representing the serialization of the entity
  30924. */
  30925. static Serialize<T>(entity: T, serializationObject?: any): any;
  30926. /**
  30927. * Creates a new entity from a serialization data object
  30928. * @param creationFunction defines a function used to instanciated the new entity
  30929. * @param source defines the source serialization data
  30930. * @param scene defines the hosting scene
  30931. * @param rootUrl defines the root url for resources
  30932. * @returns a new entity
  30933. */
  30934. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30935. /**
  30936. * Clones an object
  30937. * @param creationFunction defines the function used to instanciate the new object
  30938. * @param source defines the source object
  30939. * @returns the cloned object
  30940. */
  30941. static Clone<T>(creationFunction: () => T, source: T): T;
  30942. /**
  30943. * Instanciates a new object based on a source one (some data will be shared between both object)
  30944. * @param creationFunction defines the function used to instanciate the new object
  30945. * @param source defines the source object
  30946. * @returns the new object
  30947. */
  30948. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30949. }
  30950. }
  30951. declare module "babylonjs/Cameras/camera" {
  30952. import { SmartArray } from "babylonjs/Misc/smartArray";
  30953. import { Observable } from "babylonjs/Misc/observable";
  30954. import { Nullable } from "babylonjs/types";
  30955. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30956. import { Scene } from "babylonjs/scene";
  30957. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30958. import { Node } from "babylonjs/node";
  30959. import { Mesh } from "babylonjs/Meshes/mesh";
  30960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30961. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30962. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30963. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30964. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30965. import { Ray } from "babylonjs/Culling/ray";
  30966. /**
  30967. * This is the base class of all the camera used in the application.
  30968. * @see http://doc.babylonjs.com/features/cameras
  30969. */
  30970. export class Camera extends Node {
  30971. /** @hidden */
  30972. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30973. /**
  30974. * This is the default projection mode used by the cameras.
  30975. * It helps recreating a feeling of perspective and better appreciate depth.
  30976. * This is the best way to simulate real life cameras.
  30977. */
  30978. static readonly PERSPECTIVE_CAMERA: number;
  30979. /**
  30980. * This helps creating camera with an orthographic mode.
  30981. * 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.
  30982. */
  30983. static readonly ORTHOGRAPHIC_CAMERA: number;
  30984. /**
  30985. * This is the default FOV mode for perspective cameras.
  30986. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30987. */
  30988. static readonly FOVMODE_VERTICAL_FIXED: number;
  30989. /**
  30990. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30991. */
  30992. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30993. /**
  30994. * This specifies ther is no need for a camera rig.
  30995. * Basically only one eye is rendered corresponding to the camera.
  30996. */
  30997. static readonly RIG_MODE_NONE: number;
  30998. /**
  30999. * Simulates a camera Rig with one blue eye and one red eye.
  31000. * This can be use with 3d blue and red glasses.
  31001. */
  31002. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31003. /**
  31004. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31005. */
  31006. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31007. /**
  31008. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31009. */
  31010. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31011. /**
  31012. * Defines that both eyes of the camera will be rendered over under each other.
  31013. */
  31014. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31015. /**
  31016. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31017. */
  31018. static readonly RIG_MODE_VR: number;
  31019. /**
  31020. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31021. */
  31022. static readonly RIG_MODE_WEBVR: number;
  31023. /**
  31024. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31025. */
  31026. static readonly RIG_MODE_CUSTOM: number;
  31027. /**
  31028. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31029. */
  31030. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31031. /**
  31032. * Define the input manager associated with the camera.
  31033. */
  31034. inputs: CameraInputsManager<Camera>;
  31035. /** @hidden */
  31036. _position: Vector3;
  31037. /**
  31038. * Define the current local position of the camera in the scene
  31039. */
  31040. position: Vector3;
  31041. /**
  31042. * The vector the camera should consider as up.
  31043. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31044. */
  31045. upVector: Vector3;
  31046. /**
  31047. * Define the current limit on the left side for an orthographic camera
  31048. * In scene unit
  31049. */
  31050. orthoLeft: Nullable<number>;
  31051. /**
  31052. * Define the current limit on the right side for an orthographic camera
  31053. * In scene unit
  31054. */
  31055. orthoRight: Nullable<number>;
  31056. /**
  31057. * Define the current limit on the bottom side for an orthographic camera
  31058. * In scene unit
  31059. */
  31060. orthoBottom: Nullable<number>;
  31061. /**
  31062. * Define the current limit on the top side for an orthographic camera
  31063. * In scene unit
  31064. */
  31065. orthoTop: Nullable<number>;
  31066. /**
  31067. * Field Of View is set in Radians. (default is 0.8)
  31068. */
  31069. fov: number;
  31070. /**
  31071. * Define the minimum distance the camera can see from.
  31072. * This is important to note that the depth buffer are not infinite and the closer it starts
  31073. * the more your scene might encounter depth fighting issue.
  31074. */
  31075. minZ: number;
  31076. /**
  31077. * Define the maximum distance the camera can see to.
  31078. * This is important to note that the depth buffer are not infinite and the further it end
  31079. * the more your scene might encounter depth fighting issue.
  31080. */
  31081. maxZ: number;
  31082. /**
  31083. * Define the default inertia of the camera.
  31084. * This helps giving a smooth feeling to the camera movement.
  31085. */
  31086. inertia: number;
  31087. /**
  31088. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31089. */
  31090. mode: number;
  31091. /**
  31092. * Define wether the camera is intermediate.
  31093. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31094. */
  31095. isIntermediate: boolean;
  31096. /**
  31097. * Define the viewport of the camera.
  31098. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31099. */
  31100. viewport: Viewport;
  31101. /**
  31102. * Restricts the camera to viewing objects with the same layerMask.
  31103. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31104. */
  31105. layerMask: number;
  31106. /**
  31107. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31108. */
  31109. fovMode: number;
  31110. /**
  31111. * Rig mode of the camera.
  31112. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31113. * This is normally controlled byt the camera themselves as internal use.
  31114. */
  31115. cameraRigMode: number;
  31116. /**
  31117. * Defines the distance between both "eyes" in case of a RIG
  31118. */
  31119. interaxialDistance: number;
  31120. /**
  31121. * Defines if stereoscopic rendering is done side by side or over under.
  31122. */
  31123. isStereoscopicSideBySide: boolean;
  31124. /**
  31125. * 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
  31126. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31127. * else in the scene.
  31128. */
  31129. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31130. /**
  31131. * When set, the camera will render to this render target instead of the default canvas
  31132. */
  31133. outputRenderTarget: Nullable<RenderTargetTexture>;
  31134. /**
  31135. * Observable triggered when the camera view matrix has changed.
  31136. */
  31137. onViewMatrixChangedObservable: Observable<Camera>;
  31138. /**
  31139. * Observable triggered when the camera Projection matrix has changed.
  31140. */
  31141. onProjectionMatrixChangedObservable: Observable<Camera>;
  31142. /**
  31143. * Observable triggered when the inputs have been processed.
  31144. */
  31145. onAfterCheckInputsObservable: Observable<Camera>;
  31146. /**
  31147. * Observable triggered when reset has been called and applied to the camera.
  31148. */
  31149. onRestoreStateObservable: Observable<Camera>;
  31150. /** @hidden */
  31151. _cameraRigParams: any;
  31152. /** @hidden */
  31153. _rigCameras: Camera[];
  31154. /** @hidden */
  31155. _rigPostProcess: Nullable<PostProcess>;
  31156. protected _webvrViewMatrix: Matrix;
  31157. /** @hidden */
  31158. _skipRendering: boolean;
  31159. /** @hidden */
  31160. _projectionMatrix: Matrix;
  31161. /** @hidden */
  31162. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31163. /** @hidden */
  31164. _activeMeshes: SmartArray<AbstractMesh>;
  31165. protected _globalPosition: Vector3;
  31166. /** hidden */
  31167. _computedViewMatrix: Matrix;
  31168. private _doNotComputeProjectionMatrix;
  31169. private _transformMatrix;
  31170. private _frustumPlanes;
  31171. private _refreshFrustumPlanes;
  31172. private _storedFov;
  31173. private _stateStored;
  31174. /**
  31175. * Instantiates a new camera object.
  31176. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31177. * @see http://doc.babylonjs.com/features/cameras
  31178. * @param name Defines the name of the camera in the scene
  31179. * @param position Defines the position of the camera
  31180. * @param scene Defines the scene the camera belongs too
  31181. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31182. */
  31183. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31184. /**
  31185. * Store current camera state (fov, position, etc..)
  31186. * @returns the camera
  31187. */
  31188. storeState(): Camera;
  31189. /**
  31190. * Restores the camera state values if it has been stored. You must call storeState() first
  31191. */
  31192. protected _restoreStateValues(): boolean;
  31193. /**
  31194. * Restored camera state. You must call storeState() first.
  31195. * @returns true if restored and false otherwise
  31196. */
  31197. restoreState(): boolean;
  31198. /**
  31199. * Gets the class name of the camera.
  31200. * @returns the class name
  31201. */
  31202. getClassName(): string;
  31203. /** @hidden */
  31204. readonly _isCamera: boolean;
  31205. /**
  31206. * Gets a string representation of the camera useful for debug purpose.
  31207. * @param fullDetails Defines that a more verboe level of logging is required
  31208. * @returns the string representation
  31209. */
  31210. toString(fullDetails?: boolean): string;
  31211. /**
  31212. * Gets the current world space position of the camera.
  31213. */
  31214. readonly globalPosition: Vector3;
  31215. /**
  31216. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31217. * @returns the active meshe list
  31218. */
  31219. getActiveMeshes(): SmartArray<AbstractMesh>;
  31220. /**
  31221. * Check wether a mesh is part of the current active mesh list of the camera
  31222. * @param mesh Defines the mesh to check
  31223. * @returns true if active, false otherwise
  31224. */
  31225. isActiveMesh(mesh: Mesh): boolean;
  31226. /**
  31227. * Is this camera ready to be used/rendered
  31228. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31229. * @return true if the camera is ready
  31230. */
  31231. isReady(completeCheck?: boolean): boolean;
  31232. /** @hidden */
  31233. _initCache(): void;
  31234. /** @hidden */
  31235. _updateCache(ignoreParentClass?: boolean): void;
  31236. /** @hidden */
  31237. _isSynchronized(): boolean;
  31238. /** @hidden */
  31239. _isSynchronizedViewMatrix(): boolean;
  31240. /** @hidden */
  31241. _isSynchronizedProjectionMatrix(): boolean;
  31242. /**
  31243. * Attach the input controls to a specific dom element to get the input from.
  31244. * @param element Defines the element the controls should be listened from
  31245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31246. */
  31247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31248. /**
  31249. * Detach the current controls from the specified dom element.
  31250. * @param element Defines the element to stop listening the inputs from
  31251. */
  31252. detachControl(element: HTMLElement): void;
  31253. /**
  31254. * Update the camera state according to the different inputs gathered during the frame.
  31255. */
  31256. update(): void;
  31257. /** @hidden */
  31258. _checkInputs(): void;
  31259. /** @hidden */
  31260. readonly rigCameras: Camera[];
  31261. /**
  31262. * Gets the post process used by the rig cameras
  31263. */
  31264. readonly rigPostProcess: Nullable<PostProcess>;
  31265. /**
  31266. * Internal, gets the first post proces.
  31267. * @returns the first post process to be run on this camera.
  31268. */
  31269. _getFirstPostProcess(): Nullable<PostProcess>;
  31270. private _cascadePostProcessesToRigCams;
  31271. /**
  31272. * Attach a post process to the camera.
  31273. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31274. * @param postProcess The post process to attach to the camera
  31275. * @param insertAt The position of the post process in case several of them are in use in the scene
  31276. * @returns the position the post process has been inserted at
  31277. */
  31278. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31279. /**
  31280. * Detach a post process to the camera.
  31281. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31282. * @param postProcess The post process to detach from the camera
  31283. */
  31284. detachPostProcess(postProcess: PostProcess): void;
  31285. /**
  31286. * Gets the current world matrix of the camera
  31287. */
  31288. getWorldMatrix(): Matrix;
  31289. /** @hidden */
  31290. _getViewMatrix(): Matrix;
  31291. /**
  31292. * Gets the current view matrix of the camera.
  31293. * @param force forces the camera to recompute the matrix without looking at the cached state
  31294. * @returns the view matrix
  31295. */
  31296. getViewMatrix(force?: boolean): Matrix;
  31297. /**
  31298. * Freeze the projection matrix.
  31299. * It will prevent the cache check of the camera projection compute and can speed up perf
  31300. * if no parameter of the camera are meant to change
  31301. * @param projection Defines manually a projection if necessary
  31302. */
  31303. freezeProjectionMatrix(projection?: Matrix): void;
  31304. /**
  31305. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31306. */
  31307. unfreezeProjectionMatrix(): void;
  31308. /**
  31309. * Gets the current projection matrix of the camera.
  31310. * @param force forces the camera to recompute the matrix without looking at the cached state
  31311. * @returns the projection matrix
  31312. */
  31313. getProjectionMatrix(force?: boolean): Matrix;
  31314. /**
  31315. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31316. * @returns a Matrix
  31317. */
  31318. getTransformationMatrix(): Matrix;
  31319. private _updateFrustumPlanes;
  31320. /**
  31321. * Checks if a cullable object (mesh...) is in the camera frustum
  31322. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31323. * @param target The object to check
  31324. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31325. * @returns true if the object is in frustum otherwise false
  31326. */
  31327. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31328. /**
  31329. * Checks if a cullable object (mesh...) is in the camera frustum
  31330. * Unlike isInFrustum this cheks the full bounding box
  31331. * @param target The object to check
  31332. * @returns true if the object is in frustum otherwise false
  31333. */
  31334. isCompletelyInFrustum(target: ICullable): boolean;
  31335. /**
  31336. * Gets a ray in the forward direction from the camera.
  31337. * @param length Defines the length of the ray to create
  31338. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31339. * @param origin Defines the start point of the ray which defaults to the camera position
  31340. * @returns the forward ray
  31341. */
  31342. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31343. /**
  31344. * Releases resources associated with this node.
  31345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31347. */
  31348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31349. /** @hidden */
  31350. _isLeftCamera: boolean;
  31351. /**
  31352. * Gets the left camera of a rig setup in case of Rigged Camera
  31353. */
  31354. readonly isLeftCamera: boolean;
  31355. /** @hidden */
  31356. _isRightCamera: boolean;
  31357. /**
  31358. * Gets the right camera of a rig setup in case of Rigged Camera
  31359. */
  31360. readonly isRightCamera: boolean;
  31361. /**
  31362. * Gets the left camera of a rig setup in case of Rigged Camera
  31363. */
  31364. readonly leftCamera: Nullable<FreeCamera>;
  31365. /**
  31366. * Gets the right camera of a rig setup in case of Rigged Camera
  31367. */
  31368. readonly rightCamera: Nullable<FreeCamera>;
  31369. /**
  31370. * Gets the left camera target of a rig setup in case of Rigged Camera
  31371. * @returns the target position
  31372. */
  31373. getLeftTarget(): Nullable<Vector3>;
  31374. /**
  31375. * Gets the right camera target of a rig setup in case of Rigged Camera
  31376. * @returns the target position
  31377. */
  31378. getRightTarget(): Nullable<Vector3>;
  31379. /**
  31380. * @hidden
  31381. */
  31382. setCameraRigMode(mode: number, rigParams: any): void;
  31383. /** @hidden */
  31384. static _setStereoscopicRigMode(camera: Camera): void;
  31385. /** @hidden */
  31386. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31387. /** @hidden */
  31388. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31389. /** @hidden */
  31390. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31391. /** @hidden */
  31392. _getVRProjectionMatrix(): Matrix;
  31393. protected _updateCameraRotationMatrix(): void;
  31394. protected _updateWebVRCameraRotationMatrix(): void;
  31395. /**
  31396. * This function MUST be overwritten by the different WebVR cameras available.
  31397. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31398. * @hidden
  31399. */
  31400. _getWebVRProjectionMatrix(): Matrix;
  31401. /**
  31402. * This function MUST be overwritten by the different WebVR cameras available.
  31403. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31404. * @hidden
  31405. */
  31406. _getWebVRViewMatrix(): Matrix;
  31407. /** @hidden */
  31408. setCameraRigParameter(name: string, value: any): void;
  31409. /**
  31410. * needs to be overridden by children so sub has required properties to be copied
  31411. * @hidden
  31412. */
  31413. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31414. /**
  31415. * May need to be overridden by children
  31416. * @hidden
  31417. */
  31418. _updateRigCameras(): void;
  31419. /** @hidden */
  31420. _setupInputs(): void;
  31421. /**
  31422. * Serialiaze the camera setup to a json represention
  31423. * @returns the JSON representation
  31424. */
  31425. serialize(): any;
  31426. /**
  31427. * Clones the current camera.
  31428. * @param name The cloned camera name
  31429. * @returns the cloned camera
  31430. */
  31431. clone(name: string): Camera;
  31432. /**
  31433. * Gets the direction of the camera relative to a given local axis.
  31434. * @param localAxis Defines the reference axis to provide a relative direction.
  31435. * @return the direction
  31436. */
  31437. getDirection(localAxis: Vector3): Vector3;
  31438. /**
  31439. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31440. * @param localAxis Defines the reference axis to provide a relative direction.
  31441. * @param result Defines the vector to store the result in
  31442. */
  31443. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31444. /**
  31445. * Gets a camera constructor for a given camera type
  31446. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31447. * @param name The name of the camera the result will be able to instantiate
  31448. * @param scene The scene the result will construct the camera in
  31449. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31450. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31451. * @returns a factory method to construc the camera
  31452. */
  31453. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31454. /**
  31455. * Compute the world matrix of the camera.
  31456. * @returns the camera workd matrix
  31457. */
  31458. computeWorldMatrix(): Matrix;
  31459. /**
  31460. * Parse a JSON and creates the camera from the parsed information
  31461. * @param parsedCamera The JSON to parse
  31462. * @param scene The scene to instantiate the camera in
  31463. * @returns the newly constructed camera
  31464. */
  31465. static Parse(parsedCamera: any, scene: Scene): Camera;
  31466. }
  31467. }
  31468. declare module "babylonjs/Misc/tools" {
  31469. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31470. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31471. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31472. import { Observable } from "babylonjs/Misc/observable";
  31473. import { DomManagement } from "babylonjs/Misc/domManagement";
  31474. import { WebRequest } from "babylonjs/Misc/webRequest";
  31475. import { Camera } from "babylonjs/Cameras/camera";
  31476. import { Engine } from "babylonjs/Engines/engine";
  31477. import { Animation } from "babylonjs/Animations/animation";
  31478. /**
  31479. * Interface for any object that can request an animation frame
  31480. */
  31481. export interface ICustomAnimationFrameRequester {
  31482. /**
  31483. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31484. */
  31485. renderFunction?: Function;
  31486. /**
  31487. * Called to request the next frame to render to
  31488. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31489. */
  31490. requestAnimationFrame: Function;
  31491. /**
  31492. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31493. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31494. */
  31495. requestID?: number;
  31496. }
  31497. /**
  31498. * Interface containing an array of animations
  31499. */
  31500. export interface IAnimatable {
  31501. /**
  31502. * Array of animations
  31503. */
  31504. animations: Nullable<Array<Animation>>;
  31505. }
  31506. /** Interface used by value gradients (color, factor, ...) */
  31507. export interface IValueGradient {
  31508. /**
  31509. * Gets or sets the gradient value (between 0 and 1)
  31510. */
  31511. gradient: number;
  31512. }
  31513. /** Class used to store color4 gradient */
  31514. export class ColorGradient implements IValueGradient {
  31515. /**
  31516. * Gets or sets the gradient value (between 0 and 1)
  31517. */
  31518. gradient: number;
  31519. /**
  31520. * Gets or sets first associated color
  31521. */
  31522. color1: Color4;
  31523. /**
  31524. * Gets or sets second associated color
  31525. */
  31526. color2?: Color4;
  31527. /**
  31528. * Will get a color picked randomly between color1 and color2.
  31529. * If color2 is undefined then color1 will be used
  31530. * @param result defines the target Color4 to store the result in
  31531. */
  31532. getColorToRef(result: Color4): void;
  31533. }
  31534. /** Class used to store color 3 gradient */
  31535. export class Color3Gradient implements IValueGradient {
  31536. /**
  31537. * Gets or sets the gradient value (between 0 and 1)
  31538. */
  31539. gradient: number;
  31540. /**
  31541. * Gets or sets the associated color
  31542. */
  31543. color: Color3;
  31544. }
  31545. /** Class used to store factor gradient */
  31546. export class FactorGradient implements IValueGradient {
  31547. /**
  31548. * Gets or sets the gradient value (between 0 and 1)
  31549. */
  31550. gradient: number;
  31551. /**
  31552. * Gets or sets first associated factor
  31553. */
  31554. factor1: number;
  31555. /**
  31556. * Gets or sets second associated factor
  31557. */
  31558. factor2?: number;
  31559. /**
  31560. * Will get a number picked randomly between factor1 and factor2.
  31561. * If factor2 is undefined then factor1 will be used
  31562. * @returns the picked number
  31563. */
  31564. getFactor(): number;
  31565. }
  31566. /**
  31567. * @ignore
  31568. * Application error to support additional information when loading a file
  31569. */
  31570. export class LoadFileError extends Error {
  31571. /** defines the optional web request */
  31572. request?: WebRequest | undefined;
  31573. private static _setPrototypeOf;
  31574. /**
  31575. * Creates a new LoadFileError
  31576. * @param message defines the message of the error
  31577. * @param request defines the optional web request
  31578. */
  31579. constructor(message: string,
  31580. /** defines the optional web request */
  31581. request?: WebRequest | undefined);
  31582. }
  31583. /**
  31584. * Class used to define a retry strategy when error happens while loading assets
  31585. */
  31586. export class RetryStrategy {
  31587. /**
  31588. * Function used to defines an exponential back off strategy
  31589. * @param maxRetries defines the maximum number of retries (3 by default)
  31590. * @param baseInterval defines the interval between retries
  31591. * @returns the strategy function to use
  31592. */
  31593. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31594. }
  31595. /**
  31596. * File request interface
  31597. */
  31598. export interface IFileRequest {
  31599. /**
  31600. * Raised when the request is complete (success or error).
  31601. */
  31602. onCompleteObservable: Observable<IFileRequest>;
  31603. /**
  31604. * Aborts the request for a file.
  31605. */
  31606. abort: () => void;
  31607. }
  31608. /**
  31609. * Class containing a set of static utilities functions
  31610. */
  31611. export class Tools {
  31612. /**
  31613. * Gets or sets the base URL to use to load assets
  31614. */
  31615. static BaseUrl: string;
  31616. /**
  31617. * Enable/Disable Custom HTTP Request Headers globally.
  31618. * default = false
  31619. * @see CustomRequestHeaders
  31620. */
  31621. static UseCustomRequestHeaders: boolean;
  31622. /**
  31623. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31624. * i.e. when loading files, where the server/service expects an Authorization header
  31625. */
  31626. static CustomRequestHeaders: {
  31627. [key: string]: string;
  31628. };
  31629. /**
  31630. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31631. */
  31632. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31633. /**
  31634. * Default behaviour for cors in the application.
  31635. * It can be a string if the expected behavior is identical in the entire app.
  31636. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31637. */
  31638. static CorsBehavior: string | ((url: string | string[]) => string);
  31639. /**
  31640. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31641. * @ignorenaming
  31642. */
  31643. static UseFallbackTexture: boolean;
  31644. /**
  31645. * Use this object to register external classes like custom textures or material
  31646. * to allow the laoders to instantiate them
  31647. */
  31648. static RegisteredExternalClasses: {
  31649. [key: string]: Object;
  31650. };
  31651. /**
  31652. * Texture content used if a texture cannot loaded
  31653. * @ignorenaming
  31654. */
  31655. static fallbackTexture: string;
  31656. /**
  31657. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31658. * @param u defines the coordinate on X axis
  31659. * @param v defines the coordinate on Y axis
  31660. * @param width defines the width of the source data
  31661. * @param height defines the height of the source data
  31662. * @param pixels defines the source byte array
  31663. * @param color defines the output color
  31664. */
  31665. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31666. /**
  31667. * Interpolates between a and b via alpha
  31668. * @param a The lower value (returned when alpha = 0)
  31669. * @param b The upper value (returned when alpha = 1)
  31670. * @param alpha The interpolation-factor
  31671. * @return The mixed value
  31672. */
  31673. static Mix(a: number, b: number, alpha: number): number;
  31674. /**
  31675. * Tries to instantiate a new object from a given class name
  31676. * @param className defines the class name to instantiate
  31677. * @returns the new object or null if the system was not able to do the instantiation
  31678. */
  31679. static Instantiate(className: string): any;
  31680. /**
  31681. * Provides a slice function that will work even on IE
  31682. * @param data defines the array to slice
  31683. * @param start defines the start of the data (optional)
  31684. * @param end defines the end of the data (optional)
  31685. * @returns the new sliced array
  31686. */
  31687. static Slice<T>(data: T, start?: number, end?: number): T;
  31688. /**
  31689. * Polyfill for setImmediate
  31690. * @param action defines the action to execute after the current execution block
  31691. */
  31692. static SetImmediate(action: () => void): void;
  31693. /**
  31694. * Function indicating if a number is an exponent of 2
  31695. * @param value defines the value to test
  31696. * @returns true if the value is an exponent of 2
  31697. */
  31698. static IsExponentOfTwo(value: number): boolean;
  31699. private static _tmpFloatArray;
  31700. /**
  31701. * Returns the nearest 32-bit single precision float representation of a Number
  31702. * @param value A Number. If the parameter is of a different type, it will get converted
  31703. * to a number or to NaN if it cannot be converted
  31704. * @returns number
  31705. */
  31706. static FloatRound(value: number): number;
  31707. /**
  31708. * Find the next highest power of two.
  31709. * @param x Number to start search from.
  31710. * @return Next highest power of two.
  31711. */
  31712. static CeilingPOT(x: number): number;
  31713. /**
  31714. * Find the next lowest power of two.
  31715. * @param x Number to start search from.
  31716. * @return Next lowest power of two.
  31717. */
  31718. static FloorPOT(x: number): number;
  31719. /**
  31720. * Find the nearest power of two.
  31721. * @param x Number to start search from.
  31722. * @return Next nearest power of two.
  31723. */
  31724. static NearestPOT(x: number): number;
  31725. /**
  31726. * Get the closest exponent of two
  31727. * @param value defines the value to approximate
  31728. * @param max defines the maximum value to return
  31729. * @param mode defines how to define the closest value
  31730. * @returns closest exponent of two of the given value
  31731. */
  31732. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31733. /**
  31734. * Extracts the filename from a path
  31735. * @param path defines the path to use
  31736. * @returns the filename
  31737. */
  31738. static GetFilename(path: string): string;
  31739. /**
  31740. * Extracts the "folder" part of a path (everything before the filename).
  31741. * @param uri The URI to extract the info from
  31742. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31743. * @returns The "folder" part of the path
  31744. */
  31745. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31746. /**
  31747. * Extracts text content from a DOM element hierarchy
  31748. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31749. */
  31750. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31751. /**
  31752. * Convert an angle in radians to degrees
  31753. * @param angle defines the angle to convert
  31754. * @returns the angle in degrees
  31755. */
  31756. static ToDegrees(angle: number): number;
  31757. /**
  31758. * Convert an angle in degrees to radians
  31759. * @param angle defines the angle to convert
  31760. * @returns the angle in radians
  31761. */
  31762. static ToRadians(angle: number): number;
  31763. /**
  31764. * Encode a buffer to a base64 string
  31765. * @param buffer defines the buffer to encode
  31766. * @returns the encoded string
  31767. */
  31768. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31769. /**
  31770. * Extracts minimum and maximum values from a list of indexed positions
  31771. * @param positions defines the positions to use
  31772. * @param indices defines the indices to the positions
  31773. * @param indexStart defines the start index
  31774. * @param indexCount defines the end index
  31775. * @param bias defines bias value to add to the result
  31776. * @return minimum and maximum values
  31777. */
  31778. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31779. minimum: Vector3;
  31780. maximum: Vector3;
  31781. };
  31782. /**
  31783. * Extracts minimum and maximum values from a list of positions
  31784. * @param positions defines the positions to use
  31785. * @param start defines the start index in the positions array
  31786. * @param count defines the number of positions to handle
  31787. * @param bias defines bias value to add to the result
  31788. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31789. * @return minimum and maximum values
  31790. */
  31791. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31792. minimum: Vector3;
  31793. maximum: Vector3;
  31794. };
  31795. /**
  31796. * Returns an array if obj is not an array
  31797. * @param obj defines the object to evaluate as an array
  31798. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31799. * @returns either obj directly if obj is an array or a new array containing obj
  31800. */
  31801. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31802. /**
  31803. * Gets the pointer prefix to use
  31804. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31805. */
  31806. static GetPointerPrefix(): string;
  31807. /**
  31808. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31809. * @param func - the function to be called
  31810. * @param requester - the object that will request the next frame. Falls back to window.
  31811. * @returns frame number
  31812. */
  31813. static QueueNewFrame(func: () => void, requester?: any): number;
  31814. /**
  31815. * Ask the browser to promote the current element to fullscreen rendering mode
  31816. * @param element defines the DOM element to promote
  31817. */
  31818. static RequestFullscreen(element: HTMLElement): void;
  31819. /**
  31820. * Asks the browser to exit fullscreen mode
  31821. */
  31822. static ExitFullscreen(): void;
  31823. /**
  31824. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31825. * @param url define the url we are trying
  31826. * @param element define the dom element where to configure the cors policy
  31827. */
  31828. static SetCorsBehavior(url: string | string[], element: {
  31829. crossOrigin: string | null;
  31830. }): void;
  31831. /**
  31832. * Removes unwanted characters from an url
  31833. * @param url defines the url to clean
  31834. * @returns the cleaned url
  31835. */
  31836. static CleanUrl(url: string): string;
  31837. /**
  31838. * Gets or sets a function used to pre-process url before using them to load assets
  31839. */
  31840. static PreprocessUrl: (url: string) => string;
  31841. /**
  31842. * Loads an image as an HTMLImageElement.
  31843. * @param input url string, ArrayBuffer, or Blob to load
  31844. * @param onLoad callback called when the image successfully loads
  31845. * @param onError callback called when the image fails to load
  31846. * @param offlineProvider offline provider for caching
  31847. * @returns the HTMLImageElement of the loaded image
  31848. */
  31849. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31850. /**
  31851. * Loads a file
  31852. * @param url url string, ArrayBuffer, or Blob to load
  31853. * @param onSuccess callback called when the file successfully loads
  31854. * @param onProgress callback called while file is loading (if the server supports this mode)
  31855. * @param offlineProvider defines the offline provider for caching
  31856. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31857. * @param onError callback called when the file fails to load
  31858. * @returns a file request object
  31859. */
  31860. 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;
  31861. /**
  31862. * Load a script (identified by an url). When the url returns, the
  31863. * content of this file is added into a new script element, attached to the DOM (body element)
  31864. * @param scriptUrl defines the url of the script to laod
  31865. * @param onSuccess defines the callback called when the script is loaded
  31866. * @param onError defines the callback to call if an error occurs
  31867. * @param scriptId defines the id of the script element
  31868. */
  31869. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31870. /**
  31871. * Load an asynchronous script (identified by an url). When the url returns, the
  31872. * content of this file is added into a new script element, attached to the DOM (body element)
  31873. * @param scriptUrl defines the url of the script to laod
  31874. * @param scriptId defines the id of the script element
  31875. * @returns a promise request object
  31876. */
  31877. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31878. /**
  31879. * Loads a file from a blob
  31880. * @param fileToLoad defines the blob to use
  31881. * @param callback defines the callback to call when data is loaded
  31882. * @param progressCallback defines the callback to call during loading process
  31883. * @returns a file request object
  31884. */
  31885. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31886. /**
  31887. * Loads a file
  31888. * @param fileToLoad defines the file to load
  31889. * @param callback defines the callback to call when data is loaded
  31890. * @param progressCallBack defines the callback to call during loading process
  31891. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31892. * @returns a file request object
  31893. */
  31894. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31895. /**
  31896. * Creates a data url from a given string content
  31897. * @param content defines the content to convert
  31898. * @returns the new data url link
  31899. */
  31900. static FileAsURL(content: string): string;
  31901. /**
  31902. * Format the given number to a specific decimal format
  31903. * @param value defines the number to format
  31904. * @param decimals defines the number of decimals to use
  31905. * @returns the formatted string
  31906. */
  31907. static Format(value: number, decimals?: number): string;
  31908. /**
  31909. * Checks if a given vector is inside a specific range
  31910. * @param v defines the vector to test
  31911. * @param min defines the minimum range
  31912. * @param max defines the maximum range
  31913. */
  31914. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31915. /**
  31916. * Tries to copy an object by duplicating every property
  31917. * @param source defines the source object
  31918. * @param destination defines the target object
  31919. * @param doNotCopyList defines a list of properties to avoid
  31920. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31921. */
  31922. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31923. /**
  31924. * Gets a boolean indicating if the given object has no own property
  31925. * @param obj defines the object to test
  31926. * @returns true if object has no own property
  31927. */
  31928. static IsEmpty(obj: any): boolean;
  31929. /**
  31930. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31931. * @param str Source string
  31932. * @param suffix Suffix to search for in the source string
  31933. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31934. */
  31935. static EndsWith(str: string, suffix: string): boolean;
  31936. /**
  31937. * Function used to register events at window level
  31938. * @param events defines the events to register
  31939. */
  31940. static RegisterTopRootEvents(events: {
  31941. name: string;
  31942. handler: Nullable<(e: FocusEvent) => any>;
  31943. }[]): void;
  31944. /**
  31945. * Function used to unregister events from window level
  31946. * @param events defines the events to unregister
  31947. */
  31948. static UnregisterTopRootEvents(events: {
  31949. name: string;
  31950. handler: Nullable<(e: FocusEvent) => any>;
  31951. }[]): void;
  31952. /**
  31953. * @ignore
  31954. */
  31955. static _ScreenshotCanvas: HTMLCanvasElement;
  31956. /**
  31957. * Dumps the current bound framebuffer
  31958. * @param width defines the rendering width
  31959. * @param height defines the rendering height
  31960. * @param engine defines the hosting engine
  31961. * @param successCallback defines the callback triggered once the data are available
  31962. * @param mimeType defines the mime type of the result
  31963. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31964. */
  31965. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31966. /**
  31967. * Converts the canvas data to blob.
  31968. * This acts as a polyfill for browsers not supporting the to blob function.
  31969. * @param canvas Defines the canvas to extract the data from
  31970. * @param successCallback Defines the callback triggered once the data are available
  31971. * @param mimeType Defines the mime type of the result
  31972. */
  31973. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31974. /**
  31975. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31976. * @param successCallback defines the callback triggered once the data are available
  31977. * @param mimeType defines the mime type of the result
  31978. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31979. */
  31980. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31981. /**
  31982. * Downloads a blob in the browser
  31983. * @param blob defines the blob to download
  31984. * @param fileName defines the name of the downloaded file
  31985. */
  31986. static Download(blob: Blob, fileName: string): void;
  31987. /**
  31988. * Captures a screenshot of the current rendering
  31989. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31990. * @param engine defines the rendering engine
  31991. * @param camera defines the source camera
  31992. * @param size This parameter can be set to a single number or to an object with the
  31993. * following (optional) properties: precision, width, height. If a single number is passed,
  31994. * it will be used for both width and height. If an object is passed, the screenshot size
  31995. * will be derived from the parameters. The precision property is a multiplier allowing
  31996. * rendering at a higher or lower resolution
  31997. * @param successCallback defines the callback receives a single parameter which contains the
  31998. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31999. * src parameter of an <img> to display it
  32000. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32001. * Check your browser for supported MIME types
  32002. */
  32003. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32004. /**
  32005. * Generates an image screenshot from the specified camera.
  32006. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32007. * @param engine The engine to use for rendering
  32008. * @param camera The camera to use for rendering
  32009. * @param size This parameter can be set to a single number or to an object with the
  32010. * following (optional) properties: precision, width, height. If a single number is passed,
  32011. * it will be used for both width and height. If an object is passed, the screenshot size
  32012. * will be derived from the parameters. The precision property is a multiplier allowing
  32013. * rendering at a higher or lower resolution
  32014. * @param successCallback The callback receives a single parameter which contains the
  32015. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32016. * src parameter of an <img> to display it
  32017. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32018. * Check your browser for supported MIME types
  32019. * @param samples Texture samples (default: 1)
  32020. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32021. * @param fileName A name for for the downloaded file.
  32022. */
  32023. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32024. /**
  32025. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32026. * Be aware Math.random() could cause collisions, but:
  32027. * "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"
  32028. * @returns a pseudo random id
  32029. */
  32030. static RandomId(): string;
  32031. /**
  32032. * Test if the given uri is a base64 string
  32033. * @param uri The uri to test
  32034. * @return True if the uri is a base64 string or false otherwise
  32035. */
  32036. static IsBase64(uri: string): boolean;
  32037. /**
  32038. * Decode the given base64 uri.
  32039. * @param uri The uri to decode
  32040. * @return The decoded base64 data.
  32041. */
  32042. static DecodeBase64(uri: string): ArrayBuffer;
  32043. /**
  32044. * Gets the absolute url.
  32045. * @param url the input url
  32046. * @return the absolute url
  32047. */
  32048. static GetAbsoluteUrl(url: string): string;
  32049. /**
  32050. * No log
  32051. */
  32052. static readonly NoneLogLevel: number;
  32053. /**
  32054. * Only message logs
  32055. */
  32056. static readonly MessageLogLevel: number;
  32057. /**
  32058. * Only warning logs
  32059. */
  32060. static readonly WarningLogLevel: number;
  32061. /**
  32062. * Only error logs
  32063. */
  32064. static readonly ErrorLogLevel: number;
  32065. /**
  32066. * All logs
  32067. */
  32068. static readonly AllLogLevel: number;
  32069. /**
  32070. * Gets a value indicating the number of loading errors
  32071. * @ignorenaming
  32072. */
  32073. static readonly errorsCount: number;
  32074. /**
  32075. * Callback called when a new log is added
  32076. */
  32077. static OnNewCacheEntry: (entry: string) => void;
  32078. /**
  32079. * Log a message to the console
  32080. * @param message defines the message to log
  32081. */
  32082. static Log(message: string): void;
  32083. /**
  32084. * Write a warning message to the console
  32085. * @param message defines the message to log
  32086. */
  32087. static Warn(message: string): void;
  32088. /**
  32089. * Write an error message to the console
  32090. * @param message defines the message to log
  32091. */
  32092. static Error(message: string): void;
  32093. /**
  32094. * Gets current log cache (list of logs)
  32095. */
  32096. static readonly LogCache: string;
  32097. /**
  32098. * Clears the log cache
  32099. */
  32100. static ClearLogCache(): void;
  32101. /**
  32102. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32103. */
  32104. static LogLevels: number;
  32105. /**
  32106. * Checks if the loaded document was accessed via `file:`-Protocol.
  32107. * @returns boolean
  32108. */
  32109. static IsFileURL(): boolean;
  32110. /**
  32111. * Checks if the window object exists
  32112. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32113. */
  32114. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32115. /**
  32116. * No performance log
  32117. */
  32118. static readonly PerformanceNoneLogLevel: number;
  32119. /**
  32120. * Use user marks to log performance
  32121. */
  32122. static readonly PerformanceUserMarkLogLevel: number;
  32123. /**
  32124. * Log performance to the console
  32125. */
  32126. static readonly PerformanceConsoleLogLevel: number;
  32127. private static _performance;
  32128. /**
  32129. * Sets the current performance log level
  32130. */
  32131. static PerformanceLogLevel: number;
  32132. private static _StartPerformanceCounterDisabled;
  32133. private static _EndPerformanceCounterDisabled;
  32134. private static _StartUserMark;
  32135. private static _EndUserMark;
  32136. private static _StartPerformanceConsole;
  32137. private static _EndPerformanceConsole;
  32138. /**
  32139. * Starts a performance counter
  32140. */
  32141. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32142. /**
  32143. * Ends a specific performance coutner
  32144. */
  32145. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32146. /**
  32147. * Gets either window.performance.now() if supported or Date.now() else
  32148. */
  32149. static readonly Now: number;
  32150. /**
  32151. * This method will return the name of the class used to create the instance of the given object.
  32152. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32153. * @param object the object to get the class name from
  32154. * @param isType defines if the object is actually a type
  32155. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32156. */
  32157. static GetClassName(object: any, isType?: boolean): string;
  32158. /**
  32159. * Gets the first element of an array satisfying a given predicate
  32160. * @param array defines the array to browse
  32161. * @param predicate defines the predicate to use
  32162. * @returns null if not found or the element
  32163. */
  32164. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32165. /**
  32166. * This method will return the name of the full name of the class, including its owning module (if any).
  32167. * 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).
  32168. * @param object the object to get the class name from
  32169. * @param isType defines if the object is actually a type
  32170. * @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.
  32171. * @ignorenaming
  32172. */
  32173. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32174. /**
  32175. * Returns a promise that resolves after the given amount of time.
  32176. * @param delay Number of milliseconds to delay
  32177. * @returns Promise that resolves after the given amount of time
  32178. */
  32179. static DelayAsync(delay: number): Promise<void>;
  32180. /**
  32181. * Gets the current gradient from an array of IValueGradient
  32182. * @param ratio defines the current ratio to get
  32183. * @param gradients defines the array of IValueGradient
  32184. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32185. */
  32186. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32187. }
  32188. /**
  32189. * This class is used to track a performance counter which is number based.
  32190. * The user has access to many properties which give statistics of different nature.
  32191. *
  32192. * The implementer can track two kinds of Performance Counter: time and count.
  32193. * 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.
  32194. * 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.
  32195. */
  32196. export class PerfCounter {
  32197. /**
  32198. * Gets or sets a global boolean to turn on and off all the counters
  32199. */
  32200. static Enabled: boolean;
  32201. /**
  32202. * Returns the smallest value ever
  32203. */
  32204. readonly min: number;
  32205. /**
  32206. * Returns the biggest value ever
  32207. */
  32208. readonly max: number;
  32209. /**
  32210. * Returns the average value since the performance counter is running
  32211. */
  32212. readonly average: number;
  32213. /**
  32214. * Returns the average value of the last second the counter was monitored
  32215. */
  32216. readonly lastSecAverage: number;
  32217. /**
  32218. * Returns the current value
  32219. */
  32220. readonly current: number;
  32221. /**
  32222. * Gets the accumulated total
  32223. */
  32224. readonly total: number;
  32225. /**
  32226. * Gets the total value count
  32227. */
  32228. readonly count: number;
  32229. /**
  32230. * Creates a new counter
  32231. */
  32232. constructor();
  32233. /**
  32234. * Call this method to start monitoring a new frame.
  32235. * 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.
  32236. */
  32237. fetchNewFrame(): void;
  32238. /**
  32239. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32240. * @param newCount the count value to add to the monitored count
  32241. * @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.
  32242. */
  32243. addCount(newCount: number, fetchResult: boolean): void;
  32244. /**
  32245. * Start monitoring this performance counter
  32246. */
  32247. beginMonitoring(): void;
  32248. /**
  32249. * Compute the time lapsed since the previous beginMonitoring() call.
  32250. * @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
  32251. */
  32252. endMonitoring(newFrame?: boolean): void;
  32253. private _fetchResult;
  32254. private _startMonitoringTime;
  32255. private _min;
  32256. private _max;
  32257. private _average;
  32258. private _current;
  32259. private _totalValueCount;
  32260. private _totalAccumulated;
  32261. private _lastSecAverage;
  32262. private _lastSecAccumulated;
  32263. private _lastSecTime;
  32264. private _lastSecValueCount;
  32265. }
  32266. /**
  32267. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32268. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32269. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32270. * @param name The name of the class, case should be preserved
  32271. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32272. */
  32273. export function className(name: string, module?: string): (target: Object) => void;
  32274. /**
  32275. * An implementation of a loop for asynchronous functions.
  32276. */
  32277. export class AsyncLoop {
  32278. /**
  32279. * Defines the number of iterations for the loop
  32280. */
  32281. iterations: number;
  32282. /**
  32283. * Defines the current index of the loop.
  32284. */
  32285. index: number;
  32286. private _done;
  32287. private _fn;
  32288. private _successCallback;
  32289. /**
  32290. * Constructor.
  32291. * @param iterations the number of iterations.
  32292. * @param func the function to run each iteration
  32293. * @param successCallback the callback that will be called upon succesful execution
  32294. * @param offset starting offset.
  32295. */
  32296. constructor(
  32297. /**
  32298. * Defines the number of iterations for the loop
  32299. */
  32300. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32301. /**
  32302. * Execute the next iteration. Must be called after the last iteration was finished.
  32303. */
  32304. executeNext(): void;
  32305. /**
  32306. * Break the loop and run the success callback.
  32307. */
  32308. breakLoop(): void;
  32309. /**
  32310. * Create and run an async loop.
  32311. * @param iterations the number of iterations.
  32312. * @param fn the function to run each iteration
  32313. * @param successCallback the callback that will be called upon succesful execution
  32314. * @param offset starting offset.
  32315. * @returns the created async loop object
  32316. */
  32317. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32318. /**
  32319. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32320. * @param iterations total number of iterations
  32321. * @param syncedIterations number of synchronous iterations in each async iteration.
  32322. * @param fn the function to call each iteration.
  32323. * @param callback a success call back that will be called when iterating stops.
  32324. * @param breakFunction a break condition (optional)
  32325. * @param timeout timeout settings for the setTimeout function. default - 0.
  32326. * @returns the created async loop object
  32327. */
  32328. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32329. }
  32330. }
  32331. declare module "babylonjs/Collisions/collisionCoordinator" {
  32332. import { Nullable } from "babylonjs/types";
  32333. import { Scene } from "babylonjs/scene";
  32334. import { Vector3 } from "babylonjs/Maths/math";
  32335. import { Collider } from "babylonjs/Collisions/collider";
  32336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32337. /** @hidden */
  32338. export interface ICollisionCoordinator {
  32339. createCollider(): Collider;
  32340. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32341. init(scene: Scene): void;
  32342. }
  32343. /** @hidden */
  32344. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32345. private _scene;
  32346. private _scaledPosition;
  32347. private _scaledVelocity;
  32348. private _finalPosition;
  32349. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32350. createCollider(): Collider;
  32351. init(scene: Scene): void;
  32352. private _collideWithWorld;
  32353. }
  32354. }
  32355. declare module "babylonjs/Inputs/scene.inputManager" {
  32356. import { Nullable } from "babylonjs/types";
  32357. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32358. import { Vector2 } from "babylonjs/Maths/math";
  32359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32360. import { Scene } from "babylonjs/scene";
  32361. /**
  32362. * Class used to manage all inputs for the scene.
  32363. */
  32364. export class InputManager {
  32365. /** The distance in pixel that you have to move to prevent some events */
  32366. static DragMovementThreshold: number;
  32367. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32368. static LongPressDelay: number;
  32369. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32370. static DoubleClickDelay: number;
  32371. /** If you need to check double click without raising a single click at first click, enable this flag */
  32372. static ExclusiveDoubleClickMode: boolean;
  32373. private _wheelEventName;
  32374. private _onPointerMove;
  32375. private _onPointerDown;
  32376. private _onPointerUp;
  32377. private _initClickEvent;
  32378. private _initActionManager;
  32379. private _delayedSimpleClick;
  32380. private _delayedSimpleClickTimeout;
  32381. private _previousDelayedSimpleClickTimeout;
  32382. private _meshPickProceed;
  32383. private _previousButtonPressed;
  32384. private _currentPickResult;
  32385. private _previousPickResult;
  32386. private _totalPointersPressed;
  32387. private _doubleClickOccured;
  32388. private _pointerOverMesh;
  32389. private _pickedDownMesh;
  32390. private _pickedUpMesh;
  32391. private _pointerX;
  32392. private _pointerY;
  32393. private _unTranslatedPointerX;
  32394. private _unTranslatedPointerY;
  32395. private _startingPointerPosition;
  32396. private _previousStartingPointerPosition;
  32397. private _startingPointerTime;
  32398. private _previousStartingPointerTime;
  32399. private _pointerCaptures;
  32400. private _onKeyDown;
  32401. private _onKeyUp;
  32402. private _onCanvasFocusObserver;
  32403. private _onCanvasBlurObserver;
  32404. private _scene;
  32405. /**
  32406. * Creates a new InputManager
  32407. * @param scene defines the hosting scene
  32408. */
  32409. constructor(scene: Scene);
  32410. /**
  32411. * Gets the mesh that is currently under the pointer
  32412. */
  32413. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32414. /**
  32415. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32416. */
  32417. readonly unTranslatedPointer: Vector2;
  32418. /**
  32419. * Gets or sets the current on-screen X position of the pointer
  32420. */
  32421. pointerX: number;
  32422. /**
  32423. * Gets or sets the current on-screen Y position of the pointer
  32424. */
  32425. pointerY: number;
  32426. private _updatePointerPosition;
  32427. private _processPointerMove;
  32428. private _setRayOnPointerInfo;
  32429. private _checkPrePointerObservable;
  32430. /**
  32431. * Use this method to simulate a pointer move on a mesh
  32432. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32433. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32434. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32435. */
  32436. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32437. /**
  32438. * Use this method to simulate a pointer down on a mesh
  32439. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32440. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32441. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32442. */
  32443. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32444. private _processPointerDown;
  32445. /** @hidden */
  32446. _isPointerSwiping(): boolean;
  32447. /**
  32448. * Use this method to simulate a pointer up on a mesh
  32449. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32450. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32451. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32452. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32453. */
  32454. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32455. private _processPointerUp;
  32456. /**
  32457. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32458. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32459. * @returns true if the pointer was captured
  32460. */
  32461. isPointerCaptured(pointerId?: number): boolean;
  32462. /**
  32463. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32464. * @param attachUp defines if you want to attach events to pointerup
  32465. * @param attachDown defines if you want to attach events to pointerdown
  32466. * @param attachMove defines if you want to attach events to pointermove
  32467. */
  32468. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32469. /**
  32470. * Detaches all event handlers
  32471. */
  32472. detachControl(): void;
  32473. /**
  32474. * Force the value of meshUnderPointer
  32475. * @param mesh defines the mesh to use
  32476. */
  32477. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32478. /**
  32479. * Gets the mesh under the pointer
  32480. * @returns a Mesh or null if no mesh is under the pointer
  32481. */
  32482. getPointerOverMesh(): Nullable<AbstractMesh>;
  32483. }
  32484. }
  32485. declare module "babylonjs/Animations/animationGroup" {
  32486. import { Animatable } from "babylonjs/Animations/animatable";
  32487. import { Animation } from "babylonjs/Animations/animation";
  32488. import { Scene, IDisposable } from "babylonjs/scene";
  32489. import { Observable } from "babylonjs/Misc/observable";
  32490. import { Nullable } from "babylonjs/types";
  32491. /**
  32492. * This class defines the direct association between an animation and a target
  32493. */
  32494. export class TargetedAnimation {
  32495. /**
  32496. * Animation to perform
  32497. */
  32498. animation: Animation;
  32499. /**
  32500. * Target to animate
  32501. */
  32502. target: any;
  32503. }
  32504. /**
  32505. * Use this class to create coordinated animations on multiple targets
  32506. */
  32507. export class AnimationGroup implements IDisposable {
  32508. /** The name of the animation group */
  32509. name: string;
  32510. private _scene;
  32511. private _targetedAnimations;
  32512. private _animatables;
  32513. private _from;
  32514. private _to;
  32515. private _isStarted;
  32516. private _isPaused;
  32517. private _speedRatio;
  32518. /**
  32519. * Gets or sets the unique id of the node
  32520. */
  32521. uniqueId: number;
  32522. /**
  32523. * This observable will notify when one animation have ended
  32524. */
  32525. onAnimationEndObservable: Observable<TargetedAnimation>;
  32526. /**
  32527. * Observer raised when one animation loops
  32528. */
  32529. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32530. /**
  32531. * This observable will notify when all animations have ended.
  32532. */
  32533. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32534. /**
  32535. * This observable will notify when all animations have paused.
  32536. */
  32537. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32538. /**
  32539. * This observable will notify when all animations are playing.
  32540. */
  32541. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32542. /**
  32543. * Gets the first frame
  32544. */
  32545. readonly from: number;
  32546. /**
  32547. * Gets the last frame
  32548. */
  32549. readonly to: number;
  32550. /**
  32551. * Define if the animations are started
  32552. */
  32553. readonly isStarted: boolean;
  32554. /**
  32555. * Gets a value indicating that the current group is playing
  32556. */
  32557. readonly isPlaying: boolean;
  32558. /**
  32559. * Gets or sets the speed ratio to use for all animations
  32560. */
  32561. /**
  32562. * Gets or sets the speed ratio to use for all animations
  32563. */
  32564. speedRatio: number;
  32565. /**
  32566. * Gets the targeted animations for this animation group
  32567. */
  32568. readonly targetedAnimations: Array<TargetedAnimation>;
  32569. /**
  32570. * returning the list of animatables controlled by this animation group.
  32571. */
  32572. readonly animatables: Array<Animatable>;
  32573. /**
  32574. * Instantiates a new Animation Group.
  32575. * This helps managing several animations at once.
  32576. * @see http://doc.babylonjs.com/how_to/group
  32577. * @param name Defines the name of the group
  32578. * @param scene Defines the scene the group belongs to
  32579. */
  32580. constructor(
  32581. /** The name of the animation group */
  32582. name: string, scene?: Nullable<Scene>);
  32583. /**
  32584. * Add an animation (with its target) in the group
  32585. * @param animation defines the animation we want to add
  32586. * @param target defines the target of the animation
  32587. * @returns the TargetedAnimation object
  32588. */
  32589. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32590. /**
  32591. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32592. * It can add constant keys at begin or end
  32593. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32594. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32595. * @returns the animation group
  32596. */
  32597. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32598. /**
  32599. * Start all animations on given targets
  32600. * @param loop defines if animations must loop
  32601. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32602. * @param from defines the from key (optional)
  32603. * @param to defines the to key (optional)
  32604. * @returns the current animation group
  32605. */
  32606. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32607. /**
  32608. * Pause all animations
  32609. * @returns the animation group
  32610. */
  32611. pause(): AnimationGroup;
  32612. /**
  32613. * Play all animations to initial state
  32614. * This function will start() the animations if they were not started or will restart() them if they were paused
  32615. * @param loop defines if animations must loop
  32616. * @returns the animation group
  32617. */
  32618. play(loop?: boolean): AnimationGroup;
  32619. /**
  32620. * Reset all animations to initial state
  32621. * @returns the animation group
  32622. */
  32623. reset(): AnimationGroup;
  32624. /**
  32625. * Restart animations from key 0
  32626. * @returns the animation group
  32627. */
  32628. restart(): AnimationGroup;
  32629. /**
  32630. * Stop all animations
  32631. * @returns the animation group
  32632. */
  32633. stop(): AnimationGroup;
  32634. /**
  32635. * Set animation weight for all animatables
  32636. * @param weight defines the weight to use
  32637. * @return the animationGroup
  32638. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32639. */
  32640. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32641. /**
  32642. * Synchronize and normalize all animatables with a source animatable
  32643. * @param root defines the root animatable to synchronize with
  32644. * @return the animationGroup
  32645. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32646. */
  32647. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32648. /**
  32649. * Goes to a specific frame in this animation group
  32650. * @param frame the frame number to go to
  32651. * @return the animationGroup
  32652. */
  32653. goToFrame(frame: number): AnimationGroup;
  32654. /**
  32655. * Dispose all associated resources
  32656. */
  32657. dispose(): void;
  32658. private _checkAnimationGroupEnded;
  32659. /**
  32660. * Clone the current animation group and returns a copy
  32661. * @param newName defines the name of the new group
  32662. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32663. * @returns the new aniamtion group
  32664. */
  32665. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32666. /**
  32667. * Returns a new AnimationGroup object parsed from the source provided.
  32668. * @param parsedAnimationGroup defines the source
  32669. * @param scene defines the scene that will receive the animationGroup
  32670. * @returns a new AnimationGroup
  32671. */
  32672. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32673. /**
  32674. * Returns the string "AnimationGroup"
  32675. * @returns "AnimationGroup"
  32676. */
  32677. getClassName(): string;
  32678. /**
  32679. * Creates a detailled string about the object
  32680. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32681. * @returns a string representing the object
  32682. */
  32683. toString(fullDetails?: boolean): string;
  32684. }
  32685. }
  32686. declare module "babylonjs/scene" {
  32687. import { Nullable } from "babylonjs/types";
  32688. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32689. import { Observable } from "babylonjs/Misc/observable";
  32690. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32691. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32692. import { Geometry } from "babylonjs/Meshes/geometry";
  32693. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32696. import { Mesh } from "babylonjs/Meshes/mesh";
  32697. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32698. import { Bone } from "babylonjs/Bones/bone";
  32699. import { Skeleton } from "babylonjs/Bones/skeleton";
  32700. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32701. import { Camera } from "babylonjs/Cameras/camera";
  32702. import { AbstractScene } from "babylonjs/abstractScene";
  32703. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32704. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32705. import { Material } from "babylonjs/Materials/material";
  32706. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32707. import { Effect } from "babylonjs/Materials/effect";
  32708. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32709. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32710. import { Light } from "babylonjs/Lights/light";
  32711. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32712. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32713. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32714. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32715. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32716. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32717. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32718. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32719. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32720. import { Engine } from "babylonjs/Engines/engine";
  32721. import { Node } from "babylonjs/node";
  32722. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32723. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32724. import { WebRequest } from "babylonjs/Misc/webRequest";
  32725. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32726. import { Ray } from "babylonjs/Culling/ray";
  32727. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32728. import { Animation } from "babylonjs/Animations/animation";
  32729. import { Animatable } from "babylonjs/Animations/animatable";
  32730. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32731. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32732. import { Collider } from "babylonjs/Collisions/collider";
  32733. /**
  32734. * Define an interface for all classes that will hold resources
  32735. */
  32736. export interface IDisposable {
  32737. /**
  32738. * Releases all held resources
  32739. */
  32740. dispose(): void;
  32741. }
  32742. /** Interface defining initialization parameters for Scene class */
  32743. export interface SceneOptions {
  32744. /**
  32745. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32746. * It will improve performance when the number of geometries becomes important.
  32747. */
  32748. useGeometryUniqueIdsMap?: boolean;
  32749. /**
  32750. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32751. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32752. */
  32753. useMaterialMeshMap?: boolean;
  32754. /**
  32755. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32756. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32757. */
  32758. useClonedMeshhMap?: boolean;
  32759. }
  32760. /**
  32761. * Represents a scene to be rendered by the engine.
  32762. * @see http://doc.babylonjs.com/features/scene
  32763. */
  32764. export class Scene extends AbstractScene implements IAnimatable {
  32765. private static _uniqueIdCounter;
  32766. /** The fog is deactivated */
  32767. static readonly FOGMODE_NONE: number;
  32768. /** The fog density is following an exponential function */
  32769. static readonly FOGMODE_EXP: number;
  32770. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32771. static readonly FOGMODE_EXP2: number;
  32772. /** The fog density is following a linear function. */
  32773. static readonly FOGMODE_LINEAR: number;
  32774. /**
  32775. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32776. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32777. */
  32778. static MinDeltaTime: number;
  32779. /**
  32780. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32781. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32782. */
  32783. static MaxDeltaTime: number;
  32784. /**
  32785. * Factory used to create the default material.
  32786. * @param name The name of the material to create
  32787. * @param scene The scene to create the material for
  32788. * @returns The default material
  32789. */
  32790. static DefaultMaterialFactory(scene: Scene): Material;
  32791. /**
  32792. * Factory used to create the a collision coordinator.
  32793. * @returns The collision coordinator
  32794. */
  32795. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32796. /** @hidden */
  32797. _inputManager: InputManager;
  32798. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32799. cameraToUseForPointers: Nullable<Camera>;
  32800. /** @hidden */
  32801. readonly _isScene: boolean;
  32802. /**
  32803. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32804. */
  32805. autoClear: boolean;
  32806. /**
  32807. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32808. */
  32809. autoClearDepthAndStencil: boolean;
  32810. /**
  32811. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32812. */
  32813. clearColor: Color4;
  32814. /**
  32815. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32816. */
  32817. ambientColor: Color3;
  32818. /**
  32819. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32820. * It should only be one of the following (if not the default embedded one):
  32821. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32822. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32823. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32824. * The material properties need to be setup according to the type of texture in use.
  32825. */
  32826. environmentBRDFTexture: BaseTexture;
  32827. /** @hidden */
  32828. protected _environmentTexture: Nullable<BaseTexture>;
  32829. /**
  32830. * Texture used in all pbr material as the reflection texture.
  32831. * As in the majority of the scene they are the same (exception for multi room and so on),
  32832. * this is easier to reference from here than from all the materials.
  32833. */
  32834. /**
  32835. * Texture used in all pbr material as the reflection texture.
  32836. * As in the majority of the scene they are the same (exception for multi room and so on),
  32837. * this is easier to set here than in all the materials.
  32838. */
  32839. environmentTexture: Nullable<BaseTexture>;
  32840. /** @hidden */
  32841. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32842. /**
  32843. * Default image processing configuration used either in the rendering
  32844. * Forward main pass or through the imageProcessingPostProcess if present.
  32845. * As in the majority of the scene they are the same (exception for multi camera),
  32846. * this is easier to reference from here than from all the materials and post process.
  32847. *
  32848. * No setter as we it is a shared configuration, you can set the values instead.
  32849. */
  32850. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32851. private _forceWireframe;
  32852. /**
  32853. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32854. */
  32855. forceWireframe: boolean;
  32856. private _forcePointsCloud;
  32857. /**
  32858. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32859. */
  32860. forcePointsCloud: boolean;
  32861. /**
  32862. * Gets or sets the active clipplane 1
  32863. */
  32864. clipPlane: Nullable<Plane>;
  32865. /**
  32866. * Gets or sets the active clipplane 2
  32867. */
  32868. clipPlane2: Nullable<Plane>;
  32869. /**
  32870. * Gets or sets the active clipplane 3
  32871. */
  32872. clipPlane3: Nullable<Plane>;
  32873. /**
  32874. * Gets or sets the active clipplane 4
  32875. */
  32876. clipPlane4: Nullable<Plane>;
  32877. /**
  32878. * Gets or sets a boolean indicating if animations are enabled
  32879. */
  32880. animationsEnabled: boolean;
  32881. private _animationPropertiesOverride;
  32882. /**
  32883. * Gets or sets the animation properties override
  32884. */
  32885. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32886. /**
  32887. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32888. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32889. */
  32890. useConstantAnimationDeltaTime: boolean;
  32891. /**
  32892. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32893. * Please note that it requires to run a ray cast through the scene on every frame
  32894. */
  32895. constantlyUpdateMeshUnderPointer: boolean;
  32896. /**
  32897. * Defines the HTML cursor to use when hovering over interactive elements
  32898. */
  32899. hoverCursor: string;
  32900. /**
  32901. * Defines the HTML default cursor to use (empty by default)
  32902. */
  32903. defaultCursor: string;
  32904. /**
  32905. * This is used to call preventDefault() on pointer down
  32906. * in order to block unwanted artifacts like system double clicks
  32907. */
  32908. preventDefaultOnPointerDown: boolean;
  32909. /**
  32910. * This is used to call preventDefault() on pointer up
  32911. * in order to block unwanted artifacts like system double clicks
  32912. */
  32913. preventDefaultOnPointerUp: boolean;
  32914. /**
  32915. * Gets or sets user defined metadata
  32916. */
  32917. metadata: any;
  32918. /**
  32919. * For internal use only. Please do not use.
  32920. */
  32921. reservedDataStore: any;
  32922. /**
  32923. * Gets the name of the plugin used to load this scene (null by default)
  32924. */
  32925. loadingPluginName: string;
  32926. /**
  32927. * Use this array to add regular expressions used to disable offline support for specific urls
  32928. */
  32929. disableOfflineSupportExceptionRules: RegExp[];
  32930. /**
  32931. * An event triggered when the scene is disposed.
  32932. */
  32933. onDisposeObservable: Observable<Scene>;
  32934. private _onDisposeObserver;
  32935. /** Sets a function to be executed when this scene is disposed. */
  32936. onDispose: () => void;
  32937. /**
  32938. * An event triggered before rendering the scene (right after animations and physics)
  32939. */
  32940. onBeforeRenderObservable: Observable<Scene>;
  32941. private _onBeforeRenderObserver;
  32942. /** Sets a function to be executed before rendering this scene */
  32943. beforeRender: Nullable<() => void>;
  32944. /**
  32945. * An event triggered after rendering the scene
  32946. */
  32947. onAfterRenderObservable: Observable<Scene>;
  32948. private _onAfterRenderObserver;
  32949. /** Sets a function to be executed after rendering this scene */
  32950. afterRender: Nullable<() => void>;
  32951. /**
  32952. * An event triggered before animating the scene
  32953. */
  32954. onBeforeAnimationsObservable: Observable<Scene>;
  32955. /**
  32956. * An event triggered after animations processing
  32957. */
  32958. onAfterAnimationsObservable: Observable<Scene>;
  32959. /**
  32960. * An event triggered before draw calls are ready to be sent
  32961. */
  32962. onBeforeDrawPhaseObservable: Observable<Scene>;
  32963. /**
  32964. * An event triggered after draw calls have been sent
  32965. */
  32966. onAfterDrawPhaseObservable: Observable<Scene>;
  32967. /**
  32968. * An event triggered when the scene is ready
  32969. */
  32970. onReadyObservable: Observable<Scene>;
  32971. /**
  32972. * An event triggered before rendering a camera
  32973. */
  32974. onBeforeCameraRenderObservable: Observable<Camera>;
  32975. private _onBeforeCameraRenderObserver;
  32976. /** Sets a function to be executed before rendering a camera*/
  32977. beforeCameraRender: () => void;
  32978. /**
  32979. * An event triggered after rendering a camera
  32980. */
  32981. onAfterCameraRenderObservable: Observable<Camera>;
  32982. private _onAfterCameraRenderObserver;
  32983. /** Sets a function to be executed after rendering a camera*/
  32984. afterCameraRender: () => void;
  32985. /**
  32986. * An event triggered when active meshes evaluation is about to start
  32987. */
  32988. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32989. /**
  32990. * An event triggered when active meshes evaluation is done
  32991. */
  32992. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32993. /**
  32994. * An event triggered when particles rendering is about to start
  32995. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32996. */
  32997. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32998. /**
  32999. * An event triggered when particles rendering is done
  33000. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33001. */
  33002. onAfterParticlesRenderingObservable: Observable<Scene>;
  33003. /**
  33004. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33005. */
  33006. onDataLoadedObservable: Observable<Scene>;
  33007. /**
  33008. * An event triggered when a camera is created
  33009. */
  33010. onNewCameraAddedObservable: Observable<Camera>;
  33011. /**
  33012. * An event triggered when a camera is removed
  33013. */
  33014. onCameraRemovedObservable: Observable<Camera>;
  33015. /**
  33016. * An event triggered when a light is created
  33017. */
  33018. onNewLightAddedObservable: Observable<Light>;
  33019. /**
  33020. * An event triggered when a light is removed
  33021. */
  33022. onLightRemovedObservable: Observable<Light>;
  33023. /**
  33024. * An event triggered when a geometry is created
  33025. */
  33026. onNewGeometryAddedObservable: Observable<Geometry>;
  33027. /**
  33028. * An event triggered when a geometry is removed
  33029. */
  33030. onGeometryRemovedObservable: Observable<Geometry>;
  33031. /**
  33032. * An event triggered when a transform node is created
  33033. */
  33034. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33035. /**
  33036. * An event triggered when a transform node is removed
  33037. */
  33038. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33039. /**
  33040. * An event triggered when a mesh is created
  33041. */
  33042. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33043. /**
  33044. * An event triggered when a mesh is removed
  33045. */
  33046. onMeshRemovedObservable: Observable<AbstractMesh>;
  33047. /**
  33048. * An event triggered when a skeleton is created
  33049. */
  33050. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33051. /**
  33052. * An event triggered when a skeleton is removed
  33053. */
  33054. onSkeletonRemovedObservable: Observable<Skeleton>;
  33055. /**
  33056. * An event triggered when a material is created
  33057. */
  33058. onNewMaterialAddedObservable: Observable<Material>;
  33059. /**
  33060. * An event triggered when a material is removed
  33061. */
  33062. onMaterialRemovedObservable: Observable<Material>;
  33063. /**
  33064. * An event triggered when a texture is created
  33065. */
  33066. onNewTextureAddedObservable: Observable<BaseTexture>;
  33067. /**
  33068. * An event triggered when a texture is removed
  33069. */
  33070. onTextureRemovedObservable: Observable<BaseTexture>;
  33071. /**
  33072. * An event triggered when render targets are about to be rendered
  33073. * Can happen multiple times per frame.
  33074. */
  33075. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33076. /**
  33077. * An event triggered when render targets were rendered.
  33078. * Can happen multiple times per frame.
  33079. */
  33080. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33081. /**
  33082. * An event triggered before calculating deterministic simulation step
  33083. */
  33084. onBeforeStepObservable: Observable<Scene>;
  33085. /**
  33086. * An event triggered after calculating deterministic simulation step
  33087. */
  33088. onAfterStepObservable: Observable<Scene>;
  33089. /**
  33090. * An event triggered when the activeCamera property is updated
  33091. */
  33092. onActiveCameraChanged: Observable<Scene>;
  33093. /**
  33094. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33095. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33096. * 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)
  33097. */
  33098. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33099. /**
  33100. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33101. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33102. * 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)
  33103. */
  33104. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33105. /**
  33106. * This Observable will when a mesh has been imported into the scene.
  33107. */
  33108. onMeshImportedObservable: Observable<AbstractMesh>;
  33109. /**
  33110. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33111. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33112. */
  33113. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33114. /** @hidden */
  33115. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33116. /**
  33117. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33118. */
  33119. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33120. /**
  33121. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33122. */
  33123. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33124. /**
  33125. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33126. */
  33127. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33128. /** Callback called when a pointer move is detected */
  33129. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33130. /** Callback called when a pointer down is detected */
  33131. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33132. /** Callback called when a pointer up is detected */
  33133. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33134. /** Callback called when a pointer pick is detected */
  33135. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33136. /**
  33137. * 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).
  33138. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33139. */
  33140. onPrePointerObservable: Observable<PointerInfoPre>;
  33141. /**
  33142. * Observable event triggered each time an input event is received from the rendering canvas
  33143. */
  33144. onPointerObservable: Observable<PointerInfo>;
  33145. /**
  33146. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33147. */
  33148. readonly unTranslatedPointer: Vector2;
  33149. /**
  33150. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33151. */
  33152. static DragMovementThreshold: number;
  33153. /**
  33154. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33155. */
  33156. static LongPressDelay: number;
  33157. /**
  33158. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33159. */
  33160. static DoubleClickDelay: number;
  33161. /** If you need to check double click without raising a single click at first click, enable this flag */
  33162. static ExclusiveDoubleClickMode: boolean;
  33163. /** @hidden */
  33164. _mirroredCameraPosition: Nullable<Vector3>;
  33165. /**
  33166. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33167. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33168. */
  33169. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33170. /**
  33171. * Observable event triggered each time an keyboard event is received from the hosting window
  33172. */
  33173. onKeyboardObservable: Observable<KeyboardInfo>;
  33174. private _useRightHandedSystem;
  33175. /**
  33176. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33177. */
  33178. useRightHandedSystem: boolean;
  33179. private _timeAccumulator;
  33180. private _currentStepId;
  33181. private _currentInternalStep;
  33182. /**
  33183. * Sets the step Id used by deterministic lock step
  33184. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33185. * @param newStepId defines the step Id
  33186. */
  33187. setStepId(newStepId: number): void;
  33188. /**
  33189. * Gets the step Id used by deterministic lock step
  33190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33191. * @returns the step Id
  33192. */
  33193. getStepId(): number;
  33194. /**
  33195. * Gets the internal step used by deterministic lock step
  33196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33197. * @returns the internal step
  33198. */
  33199. getInternalStep(): number;
  33200. private _fogEnabled;
  33201. /**
  33202. * Gets or sets a boolean indicating if fog is enabled on this scene
  33203. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33204. * (Default is true)
  33205. */
  33206. fogEnabled: boolean;
  33207. private _fogMode;
  33208. /**
  33209. * Gets or sets the fog mode to use
  33210. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33211. * | mode | value |
  33212. * | --- | --- |
  33213. * | FOGMODE_NONE | 0 |
  33214. * | FOGMODE_EXP | 1 |
  33215. * | FOGMODE_EXP2 | 2 |
  33216. * | FOGMODE_LINEAR | 3 |
  33217. */
  33218. fogMode: number;
  33219. /**
  33220. * Gets or sets the fog color to use
  33221. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33222. * (Default is Color3(0.2, 0.2, 0.3))
  33223. */
  33224. fogColor: Color3;
  33225. /**
  33226. * Gets or sets the fog density to use
  33227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33228. * (Default is 0.1)
  33229. */
  33230. fogDensity: number;
  33231. /**
  33232. * Gets or sets the fog start distance to use
  33233. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33234. * (Default is 0)
  33235. */
  33236. fogStart: number;
  33237. /**
  33238. * Gets or sets the fog end distance to use
  33239. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33240. * (Default is 1000)
  33241. */
  33242. fogEnd: number;
  33243. private _shadowsEnabled;
  33244. /**
  33245. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33246. */
  33247. shadowsEnabled: boolean;
  33248. private _lightsEnabled;
  33249. /**
  33250. * Gets or sets a boolean indicating if lights are enabled on this scene
  33251. */
  33252. lightsEnabled: boolean;
  33253. /** All of the active cameras added to this scene. */
  33254. activeCameras: Camera[];
  33255. /** @hidden */
  33256. _activeCamera: Nullable<Camera>;
  33257. /** Gets or sets the current active camera */
  33258. activeCamera: Nullable<Camera>;
  33259. private _defaultMaterial;
  33260. /** The default material used on meshes when no material is affected */
  33261. /** The default material used on meshes when no material is affected */
  33262. defaultMaterial: Material;
  33263. private _texturesEnabled;
  33264. /**
  33265. * Gets or sets a boolean indicating if textures are enabled on this scene
  33266. */
  33267. texturesEnabled: boolean;
  33268. /**
  33269. * Gets or sets a boolean indicating if particles are enabled on this scene
  33270. */
  33271. particlesEnabled: boolean;
  33272. /**
  33273. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33274. */
  33275. spritesEnabled: boolean;
  33276. private _skeletonsEnabled;
  33277. /**
  33278. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33279. */
  33280. skeletonsEnabled: boolean;
  33281. /**
  33282. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33283. */
  33284. lensFlaresEnabled: boolean;
  33285. /**
  33286. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33287. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33288. */
  33289. collisionsEnabled: boolean;
  33290. private _collisionCoordinator;
  33291. /** @hidden */
  33292. readonly collisionCoordinator: ICollisionCoordinator;
  33293. /**
  33294. * Defines the gravity applied to this scene (used only for collisions)
  33295. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33296. */
  33297. gravity: Vector3;
  33298. /**
  33299. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33300. */
  33301. postProcessesEnabled: boolean;
  33302. /**
  33303. * The list of postprocesses added to the scene
  33304. */
  33305. postProcesses: PostProcess[];
  33306. /**
  33307. * Gets the current postprocess manager
  33308. */
  33309. postProcessManager: PostProcessManager;
  33310. /**
  33311. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33312. */
  33313. renderTargetsEnabled: boolean;
  33314. /**
  33315. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33316. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33317. */
  33318. dumpNextRenderTargets: boolean;
  33319. /**
  33320. * The list of user defined render targets added to the scene
  33321. */
  33322. customRenderTargets: RenderTargetTexture[];
  33323. /**
  33324. * Defines if texture loading must be delayed
  33325. * If true, textures will only be loaded when they need to be rendered
  33326. */
  33327. useDelayedTextureLoading: boolean;
  33328. /**
  33329. * Gets the list of meshes imported to the scene through SceneLoader
  33330. */
  33331. importedMeshesFiles: String[];
  33332. /**
  33333. * Gets or sets a boolean indicating if probes are enabled on this scene
  33334. */
  33335. probesEnabled: boolean;
  33336. /**
  33337. * Gets or sets the current offline provider to use to store scene data
  33338. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33339. */
  33340. offlineProvider: IOfflineProvider;
  33341. /**
  33342. * Gets or sets the action manager associated with the scene
  33343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33344. */
  33345. actionManager: AbstractActionManager;
  33346. private _meshesForIntersections;
  33347. /**
  33348. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33349. */
  33350. proceduralTexturesEnabled: boolean;
  33351. private _engine;
  33352. private _totalVertices;
  33353. /** @hidden */
  33354. _activeIndices: PerfCounter;
  33355. /** @hidden */
  33356. _activeParticles: PerfCounter;
  33357. /** @hidden */
  33358. _activeBones: PerfCounter;
  33359. private _animationRatio;
  33360. /** @hidden */
  33361. _animationTimeLast: number;
  33362. /** @hidden */
  33363. _animationTime: number;
  33364. /**
  33365. * Gets or sets a general scale for animation speed
  33366. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33367. */
  33368. animationTimeScale: number;
  33369. /** @hidden */
  33370. _cachedMaterial: Nullable<Material>;
  33371. /** @hidden */
  33372. _cachedEffect: Nullable<Effect>;
  33373. /** @hidden */
  33374. _cachedVisibility: Nullable<number>;
  33375. private _renderId;
  33376. private _frameId;
  33377. private _executeWhenReadyTimeoutId;
  33378. private _intermediateRendering;
  33379. private _viewUpdateFlag;
  33380. private _projectionUpdateFlag;
  33381. /** @hidden */
  33382. _toBeDisposed: Nullable<IDisposable>[];
  33383. private _activeRequests;
  33384. /** @hidden */
  33385. _pendingData: any[];
  33386. private _isDisposed;
  33387. /**
  33388. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33389. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33390. */
  33391. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33392. private _activeMeshes;
  33393. private _processedMaterials;
  33394. private _renderTargets;
  33395. /** @hidden */
  33396. _activeParticleSystems: SmartArray<IParticleSystem>;
  33397. private _activeSkeletons;
  33398. private _softwareSkinnedMeshes;
  33399. private _renderingManager;
  33400. /** @hidden */
  33401. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33402. private _transformMatrix;
  33403. private _sceneUbo;
  33404. /** @hidden */
  33405. _viewMatrix: Matrix;
  33406. private _projectionMatrix;
  33407. /** @hidden */
  33408. _forcedViewPosition: Nullable<Vector3>;
  33409. /** @hidden */
  33410. _frustumPlanes: Plane[];
  33411. /**
  33412. * Gets the list of frustum planes (built from the active camera)
  33413. */
  33414. readonly frustumPlanes: Plane[];
  33415. /**
  33416. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33417. * This is useful if there are more lights that the maximum simulteanous authorized
  33418. */
  33419. requireLightSorting: boolean;
  33420. /** @hidden */
  33421. readonly useMaterialMeshMap: boolean;
  33422. /** @hidden */
  33423. readonly useClonedMeshhMap: boolean;
  33424. private _externalData;
  33425. private _uid;
  33426. /**
  33427. * @hidden
  33428. * Backing store of defined scene components.
  33429. */
  33430. _components: ISceneComponent[];
  33431. /**
  33432. * @hidden
  33433. * Backing store of defined scene components.
  33434. */
  33435. _serializableComponents: ISceneSerializableComponent[];
  33436. /**
  33437. * List of components to register on the next registration step.
  33438. */
  33439. private _transientComponents;
  33440. /**
  33441. * Registers the transient components if needed.
  33442. */
  33443. private _registerTransientComponents;
  33444. /**
  33445. * @hidden
  33446. * Add a component to the scene.
  33447. * Note that the ccomponent could be registered on th next frame if this is called after
  33448. * the register component stage.
  33449. * @param component Defines the component to add to the scene
  33450. */
  33451. _addComponent(component: ISceneComponent): void;
  33452. /**
  33453. * @hidden
  33454. * Gets a component from the scene.
  33455. * @param name defines the name of the component to retrieve
  33456. * @returns the component or null if not present
  33457. */
  33458. _getComponent(name: string): Nullable<ISceneComponent>;
  33459. /**
  33460. * @hidden
  33461. * Defines the actions happening before camera updates.
  33462. */
  33463. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33464. /**
  33465. * @hidden
  33466. * Defines the actions happening before clear the canvas.
  33467. */
  33468. _beforeClearStage: Stage<SimpleStageAction>;
  33469. /**
  33470. * @hidden
  33471. * Defines the actions when collecting render targets for the frame.
  33472. */
  33473. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33474. /**
  33475. * @hidden
  33476. * Defines the actions happening for one camera in the frame.
  33477. */
  33478. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33479. /**
  33480. * @hidden
  33481. * Defines the actions happening during the per mesh ready checks.
  33482. */
  33483. _isReadyForMeshStage: Stage<MeshStageAction>;
  33484. /**
  33485. * @hidden
  33486. * Defines the actions happening before evaluate active mesh checks.
  33487. */
  33488. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33489. /**
  33490. * @hidden
  33491. * Defines the actions happening during the evaluate sub mesh checks.
  33492. */
  33493. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33494. /**
  33495. * @hidden
  33496. * Defines the actions happening during the active mesh stage.
  33497. */
  33498. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33499. /**
  33500. * @hidden
  33501. * Defines the actions happening during the per camera render target step.
  33502. */
  33503. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33504. /**
  33505. * @hidden
  33506. * Defines the actions happening just before the active camera is drawing.
  33507. */
  33508. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33509. /**
  33510. * @hidden
  33511. * Defines the actions happening just before a render target is drawing.
  33512. */
  33513. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33514. /**
  33515. * @hidden
  33516. * Defines the actions happening just before a rendering group is drawing.
  33517. */
  33518. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33519. /**
  33520. * @hidden
  33521. * Defines the actions happening just before a mesh is drawing.
  33522. */
  33523. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33524. /**
  33525. * @hidden
  33526. * Defines the actions happening just after a mesh has been drawn.
  33527. */
  33528. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33529. /**
  33530. * @hidden
  33531. * Defines the actions happening just after a rendering group has been drawn.
  33532. */
  33533. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33534. /**
  33535. * @hidden
  33536. * Defines the actions happening just after the active camera has been drawn.
  33537. */
  33538. _afterCameraDrawStage: Stage<CameraStageAction>;
  33539. /**
  33540. * @hidden
  33541. * Defines the actions happening just after a render target has been drawn.
  33542. */
  33543. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33544. /**
  33545. * @hidden
  33546. * Defines the actions happening just after rendering all cameras and computing intersections.
  33547. */
  33548. _afterRenderStage: Stage<SimpleStageAction>;
  33549. /**
  33550. * @hidden
  33551. * Defines the actions happening when a pointer move event happens.
  33552. */
  33553. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33554. /**
  33555. * @hidden
  33556. * Defines the actions happening when a pointer down event happens.
  33557. */
  33558. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33559. /**
  33560. * @hidden
  33561. * Defines the actions happening when a pointer up event happens.
  33562. */
  33563. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33564. /**
  33565. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33566. */
  33567. private geometriesByUniqueId;
  33568. /**
  33569. * Creates a new Scene
  33570. * @param engine defines the engine to use to render this scene
  33571. * @param options defines the scene options
  33572. */
  33573. constructor(engine: Engine, options?: SceneOptions);
  33574. /**
  33575. * Gets a string idenfifying the name of the class
  33576. * @returns "Scene" string
  33577. */
  33578. getClassName(): string;
  33579. private _defaultMeshCandidates;
  33580. /**
  33581. * @hidden
  33582. */
  33583. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33584. private _defaultSubMeshCandidates;
  33585. /**
  33586. * @hidden
  33587. */
  33588. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33589. /**
  33590. * Sets the default candidate providers for the scene.
  33591. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33592. * and getCollidingSubMeshCandidates to their default function
  33593. */
  33594. setDefaultCandidateProviders(): void;
  33595. /**
  33596. * Gets the mesh that is currently under the pointer
  33597. */
  33598. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33599. /**
  33600. * Gets or sets the current on-screen X position of the pointer
  33601. */
  33602. pointerX: number;
  33603. /**
  33604. * Gets or sets the current on-screen Y position of the pointer
  33605. */
  33606. pointerY: number;
  33607. /**
  33608. * Gets the cached material (ie. the latest rendered one)
  33609. * @returns the cached material
  33610. */
  33611. getCachedMaterial(): Nullable<Material>;
  33612. /**
  33613. * Gets the cached effect (ie. the latest rendered one)
  33614. * @returns the cached effect
  33615. */
  33616. getCachedEffect(): Nullable<Effect>;
  33617. /**
  33618. * Gets the cached visibility state (ie. the latest rendered one)
  33619. * @returns the cached visibility state
  33620. */
  33621. getCachedVisibility(): Nullable<number>;
  33622. /**
  33623. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33624. * @param material defines the current material
  33625. * @param effect defines the current effect
  33626. * @param visibility defines the current visibility state
  33627. * @returns true if one parameter is not cached
  33628. */
  33629. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33630. /**
  33631. * Gets the engine associated with the scene
  33632. * @returns an Engine
  33633. */
  33634. getEngine(): Engine;
  33635. /**
  33636. * Gets the total number of vertices rendered per frame
  33637. * @returns the total number of vertices rendered per frame
  33638. */
  33639. getTotalVertices(): number;
  33640. /**
  33641. * Gets the performance counter for total vertices
  33642. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33643. */
  33644. readonly totalVerticesPerfCounter: PerfCounter;
  33645. /**
  33646. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33647. * @returns the total number of active indices rendered per frame
  33648. */
  33649. getActiveIndices(): number;
  33650. /**
  33651. * Gets the performance counter for active indices
  33652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33653. */
  33654. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33655. /**
  33656. * Gets the total number of active particles rendered per frame
  33657. * @returns the total number of active particles rendered per frame
  33658. */
  33659. getActiveParticles(): number;
  33660. /**
  33661. * Gets the performance counter for active particles
  33662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33663. */
  33664. readonly activeParticlesPerfCounter: PerfCounter;
  33665. /**
  33666. * Gets the total number of active bones rendered per frame
  33667. * @returns the total number of active bones rendered per frame
  33668. */
  33669. getActiveBones(): number;
  33670. /**
  33671. * Gets the performance counter for active bones
  33672. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33673. */
  33674. readonly activeBonesPerfCounter: PerfCounter;
  33675. /**
  33676. * Gets the array of active meshes
  33677. * @returns an array of AbstractMesh
  33678. */
  33679. getActiveMeshes(): SmartArray<AbstractMesh>;
  33680. /**
  33681. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33682. * @returns a number
  33683. */
  33684. getAnimationRatio(): number;
  33685. /**
  33686. * Gets an unique Id for the current render phase
  33687. * @returns a number
  33688. */
  33689. getRenderId(): number;
  33690. /**
  33691. * Gets an unique Id for the current frame
  33692. * @returns a number
  33693. */
  33694. getFrameId(): number;
  33695. /** Call this function if you want to manually increment the render Id*/
  33696. incrementRenderId(): void;
  33697. private _createUbo;
  33698. /**
  33699. * Use this method to simulate a pointer move on a mesh
  33700. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33701. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33702. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33703. * @returns the current scene
  33704. */
  33705. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33706. /**
  33707. * Use this method to simulate a pointer down on a mesh
  33708. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33709. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33710. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33711. * @returns the current scene
  33712. */
  33713. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33714. /**
  33715. * Use this method to simulate a pointer up on a mesh
  33716. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33717. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33718. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33719. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33720. * @returns the current scene
  33721. */
  33722. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33723. /**
  33724. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33725. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33726. * @returns true if the pointer was captured
  33727. */
  33728. isPointerCaptured(pointerId?: number): boolean;
  33729. /**
  33730. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33731. * @param attachUp defines if you want to attach events to pointerup
  33732. * @param attachDown defines if you want to attach events to pointerdown
  33733. * @param attachMove defines if you want to attach events to pointermove
  33734. */
  33735. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33736. /** Detaches all event handlers*/
  33737. detachControl(): void;
  33738. /**
  33739. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33740. * Delay loaded resources are not taking in account
  33741. * @return true if all required resources are ready
  33742. */
  33743. isReady(): boolean;
  33744. /** Resets all cached information relative to material (including effect and visibility) */
  33745. resetCachedMaterial(): void;
  33746. /**
  33747. * Registers a function to be called before every frame render
  33748. * @param func defines the function to register
  33749. */
  33750. registerBeforeRender(func: () => void): void;
  33751. /**
  33752. * Unregisters a function called before every frame render
  33753. * @param func defines the function to unregister
  33754. */
  33755. unregisterBeforeRender(func: () => void): void;
  33756. /**
  33757. * Registers a function to be called after every frame render
  33758. * @param func defines the function to register
  33759. */
  33760. registerAfterRender(func: () => void): void;
  33761. /**
  33762. * Unregisters a function called after every frame render
  33763. * @param func defines the function to unregister
  33764. */
  33765. unregisterAfterRender(func: () => void): void;
  33766. private _executeOnceBeforeRender;
  33767. /**
  33768. * The provided function will run before render once and will be disposed afterwards.
  33769. * A timeout delay can be provided so that the function will be executed in N ms.
  33770. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33771. * @param func The function to be executed.
  33772. * @param timeout optional delay in ms
  33773. */
  33774. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33775. /** @hidden */
  33776. _addPendingData(data: any): void;
  33777. /** @hidden */
  33778. _removePendingData(data: any): void;
  33779. /**
  33780. * Returns the number of items waiting to be loaded
  33781. * @returns the number of items waiting to be loaded
  33782. */
  33783. getWaitingItemsCount(): number;
  33784. /**
  33785. * Returns a boolean indicating if the scene is still loading data
  33786. */
  33787. readonly isLoading: boolean;
  33788. /**
  33789. * Registers a function to be executed when the scene is ready
  33790. * @param {Function} func - the function to be executed
  33791. */
  33792. executeWhenReady(func: () => void): void;
  33793. /**
  33794. * Returns a promise that resolves when the scene is ready
  33795. * @returns A promise that resolves when the scene is ready
  33796. */
  33797. whenReadyAsync(): Promise<void>;
  33798. /** @hidden */
  33799. _checkIsReady(): void;
  33800. /**
  33801. * Gets all animatable attached to the scene
  33802. */
  33803. readonly animatables: Animatable[];
  33804. /**
  33805. * Resets the last animation time frame.
  33806. * Useful to override when animations start running when loading a scene for the first time.
  33807. */
  33808. resetLastAnimationTimeFrame(): void;
  33809. /**
  33810. * Gets the current view matrix
  33811. * @returns a Matrix
  33812. */
  33813. getViewMatrix(): Matrix;
  33814. /**
  33815. * Gets the current projection matrix
  33816. * @returns a Matrix
  33817. */
  33818. getProjectionMatrix(): Matrix;
  33819. /**
  33820. * Gets the current transform matrix
  33821. * @returns a Matrix made of View * Projection
  33822. */
  33823. getTransformMatrix(): Matrix;
  33824. /**
  33825. * Sets the current transform matrix
  33826. * @param viewL defines the View matrix to use
  33827. * @param projectionL defines the Projection matrix to use
  33828. * @param viewR defines the right View matrix to use (if provided)
  33829. * @param projectionR defines the right Projection matrix to use (if provided)
  33830. */
  33831. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33832. /**
  33833. * Gets the uniform buffer used to store scene data
  33834. * @returns a UniformBuffer
  33835. */
  33836. getSceneUniformBuffer(): UniformBuffer;
  33837. /**
  33838. * Gets an unique (relatively to the current scene) Id
  33839. * @returns an unique number for the scene
  33840. */
  33841. getUniqueId(): number;
  33842. /**
  33843. * Add a mesh to the list of scene's meshes
  33844. * @param newMesh defines the mesh to add
  33845. * @param recursive if all child meshes should also be added to the scene
  33846. */
  33847. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33848. /**
  33849. * Remove a mesh for the list of scene's meshes
  33850. * @param toRemove defines the mesh to remove
  33851. * @param recursive if all child meshes should also be removed from the scene
  33852. * @returns the index where the mesh was in the mesh list
  33853. */
  33854. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33855. /**
  33856. * Add a transform node to the list of scene's transform nodes
  33857. * @param newTransformNode defines the transform node to add
  33858. */
  33859. addTransformNode(newTransformNode: TransformNode): void;
  33860. /**
  33861. * Remove a transform node for the list of scene's transform nodes
  33862. * @param toRemove defines the transform node to remove
  33863. * @returns the index where the transform node was in the transform node list
  33864. */
  33865. removeTransformNode(toRemove: TransformNode): number;
  33866. /**
  33867. * Remove a skeleton for the list of scene's skeletons
  33868. * @param toRemove defines the skeleton to remove
  33869. * @returns the index where the skeleton was in the skeleton list
  33870. */
  33871. removeSkeleton(toRemove: Skeleton): number;
  33872. /**
  33873. * Remove a morph target for the list of scene's morph targets
  33874. * @param toRemove defines the morph target to remove
  33875. * @returns the index where the morph target was in the morph target list
  33876. */
  33877. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33878. /**
  33879. * Remove a light for the list of scene's lights
  33880. * @param toRemove defines the light to remove
  33881. * @returns the index where the light was in the light list
  33882. */
  33883. removeLight(toRemove: Light): number;
  33884. /**
  33885. * Remove a camera for the list of scene's cameras
  33886. * @param toRemove defines the camera to remove
  33887. * @returns the index where the camera was in the camera list
  33888. */
  33889. removeCamera(toRemove: Camera): number;
  33890. /**
  33891. * Remove a particle system for the list of scene's particle systems
  33892. * @param toRemove defines the particle system to remove
  33893. * @returns the index where the particle system was in the particle system list
  33894. */
  33895. removeParticleSystem(toRemove: IParticleSystem): number;
  33896. /**
  33897. * Remove a animation for the list of scene's animations
  33898. * @param toRemove defines the animation to remove
  33899. * @returns the index where the animation was in the animation list
  33900. */
  33901. removeAnimation(toRemove: Animation): number;
  33902. /**
  33903. * Will stop the animation of the given target
  33904. * @param target - the target
  33905. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33906. * @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)
  33907. */
  33908. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33909. /**
  33910. * Removes the given animation group from this scene.
  33911. * @param toRemove The animation group to remove
  33912. * @returns The index of the removed animation group
  33913. */
  33914. removeAnimationGroup(toRemove: AnimationGroup): number;
  33915. /**
  33916. * Removes the given multi-material from this scene.
  33917. * @param toRemove The multi-material to remove
  33918. * @returns The index of the removed multi-material
  33919. */
  33920. removeMultiMaterial(toRemove: MultiMaterial): number;
  33921. /**
  33922. * Removes the given material from this scene.
  33923. * @param toRemove The material to remove
  33924. * @returns The index of the removed material
  33925. */
  33926. removeMaterial(toRemove: Material): number;
  33927. /**
  33928. * Removes the given action manager from this scene.
  33929. * @param toRemove The action manager to remove
  33930. * @returns The index of the removed action manager
  33931. */
  33932. removeActionManager(toRemove: AbstractActionManager): number;
  33933. /**
  33934. * Removes the given texture from this scene.
  33935. * @param toRemove The texture to remove
  33936. * @returns The index of the removed texture
  33937. */
  33938. removeTexture(toRemove: BaseTexture): number;
  33939. /**
  33940. * Adds the given light to this scene
  33941. * @param newLight The light to add
  33942. */
  33943. addLight(newLight: Light): void;
  33944. /**
  33945. * Sorts the list list based on light priorities
  33946. */
  33947. sortLightsByPriority(): void;
  33948. /**
  33949. * Adds the given camera to this scene
  33950. * @param newCamera The camera to add
  33951. */
  33952. addCamera(newCamera: Camera): void;
  33953. /**
  33954. * Adds the given skeleton to this scene
  33955. * @param newSkeleton The skeleton to add
  33956. */
  33957. addSkeleton(newSkeleton: Skeleton): void;
  33958. /**
  33959. * Adds the given particle system to this scene
  33960. * @param newParticleSystem The particle system to add
  33961. */
  33962. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33963. /**
  33964. * Adds the given animation to this scene
  33965. * @param newAnimation The animation to add
  33966. */
  33967. addAnimation(newAnimation: Animation): void;
  33968. /**
  33969. * Adds the given animation group to this scene.
  33970. * @param newAnimationGroup The animation group to add
  33971. */
  33972. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33973. /**
  33974. * Adds the given multi-material to this scene
  33975. * @param newMultiMaterial The multi-material to add
  33976. */
  33977. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33978. /**
  33979. * Adds the given material to this scene
  33980. * @param newMaterial The material to add
  33981. */
  33982. addMaterial(newMaterial: Material): void;
  33983. /**
  33984. * Adds the given morph target to this scene
  33985. * @param newMorphTargetManager The morph target to add
  33986. */
  33987. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33988. /**
  33989. * Adds the given geometry to this scene
  33990. * @param newGeometry The geometry to add
  33991. */
  33992. addGeometry(newGeometry: Geometry): void;
  33993. /**
  33994. * Adds the given action manager to this scene
  33995. * @param newActionManager The action manager to add
  33996. */
  33997. addActionManager(newActionManager: AbstractActionManager): void;
  33998. /**
  33999. * Adds the given texture to this scene.
  34000. * @param newTexture The texture to add
  34001. */
  34002. addTexture(newTexture: BaseTexture): void;
  34003. /**
  34004. * Switch active camera
  34005. * @param newCamera defines the new active camera
  34006. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34007. */
  34008. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34009. /**
  34010. * sets the active camera of the scene using its ID
  34011. * @param id defines the camera's ID
  34012. * @return the new active camera or null if none found.
  34013. */
  34014. setActiveCameraByID(id: string): Nullable<Camera>;
  34015. /**
  34016. * sets the active camera of the scene using its name
  34017. * @param name defines the camera's name
  34018. * @returns the new active camera or null if none found.
  34019. */
  34020. setActiveCameraByName(name: string): Nullable<Camera>;
  34021. /**
  34022. * get an animation group using its name
  34023. * @param name defines the material's name
  34024. * @return the animation group or null if none found.
  34025. */
  34026. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34027. /**
  34028. * Get a material using its unique id
  34029. * @param uniqueId defines the material's unique id
  34030. * @return the material or null if none found.
  34031. */
  34032. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34033. /**
  34034. * get a material using its id
  34035. * @param id defines the material's ID
  34036. * @return the material or null if none found.
  34037. */
  34038. getMaterialByID(id: string): Nullable<Material>;
  34039. /**
  34040. * Gets a material using its name
  34041. * @param name defines the material's name
  34042. * @return the material or null if none found.
  34043. */
  34044. getMaterialByName(name: string): Nullable<Material>;
  34045. /**
  34046. * Gets a camera using its id
  34047. * @param id defines the id to look for
  34048. * @returns the camera or null if not found
  34049. */
  34050. getCameraByID(id: string): Nullable<Camera>;
  34051. /**
  34052. * Gets a camera using its unique id
  34053. * @param uniqueId defines the unique id to look for
  34054. * @returns the camera or null if not found
  34055. */
  34056. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34057. /**
  34058. * Gets a camera using its name
  34059. * @param name defines the camera's name
  34060. * @return the camera or null if none found.
  34061. */
  34062. getCameraByName(name: string): Nullable<Camera>;
  34063. /**
  34064. * Gets a bone using its id
  34065. * @param id defines the bone's id
  34066. * @return the bone or null if not found
  34067. */
  34068. getBoneByID(id: string): Nullable<Bone>;
  34069. /**
  34070. * Gets a bone using its id
  34071. * @param name defines the bone's name
  34072. * @return the bone or null if not found
  34073. */
  34074. getBoneByName(name: string): Nullable<Bone>;
  34075. /**
  34076. * Gets a light node using its name
  34077. * @param name defines the the light's name
  34078. * @return the light or null if none found.
  34079. */
  34080. getLightByName(name: string): Nullable<Light>;
  34081. /**
  34082. * Gets a light node using its id
  34083. * @param id defines the light's id
  34084. * @return the light or null if none found.
  34085. */
  34086. getLightByID(id: string): Nullable<Light>;
  34087. /**
  34088. * Gets a light node using its scene-generated unique ID
  34089. * @param uniqueId defines the light's unique id
  34090. * @return the light or null if none found.
  34091. */
  34092. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34093. /**
  34094. * Gets a particle system by id
  34095. * @param id defines the particle system id
  34096. * @return the corresponding system or null if none found
  34097. */
  34098. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34099. /**
  34100. * Gets a geometry using its ID
  34101. * @param id defines the geometry's id
  34102. * @return the geometry or null if none found.
  34103. */
  34104. getGeometryByID(id: string): Nullable<Geometry>;
  34105. private _getGeometryByUniqueID;
  34106. /**
  34107. * Add a new geometry to this scene
  34108. * @param geometry defines the geometry to be added to the scene.
  34109. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34110. * @return a boolean defining if the geometry was added or not
  34111. */
  34112. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34113. /**
  34114. * Removes an existing geometry
  34115. * @param geometry defines the geometry to be removed from the scene
  34116. * @return a boolean defining if the geometry was removed or not
  34117. */
  34118. removeGeometry(geometry: Geometry): boolean;
  34119. /**
  34120. * Gets the list of geometries attached to the scene
  34121. * @returns an array of Geometry
  34122. */
  34123. getGeometries(): Geometry[];
  34124. /**
  34125. * Gets the first added mesh found of a given ID
  34126. * @param id defines the id to search for
  34127. * @return the mesh found or null if not found at all
  34128. */
  34129. getMeshByID(id: string): Nullable<AbstractMesh>;
  34130. /**
  34131. * Gets a list of meshes using their id
  34132. * @param id defines the id to search for
  34133. * @returns a list of meshes
  34134. */
  34135. getMeshesByID(id: string): Array<AbstractMesh>;
  34136. /**
  34137. * Gets the first added transform node found of a given ID
  34138. * @param id defines the id to search for
  34139. * @return the found transform node or null if not found at all.
  34140. */
  34141. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34142. /**
  34143. * Gets a transform node with its auto-generated unique id
  34144. * @param uniqueId efines the unique id to search for
  34145. * @return the found transform node or null if not found at all.
  34146. */
  34147. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34148. /**
  34149. * Gets a list of transform nodes using their id
  34150. * @param id defines the id to search for
  34151. * @returns a list of transform nodes
  34152. */
  34153. getTransformNodesByID(id: string): Array<TransformNode>;
  34154. /**
  34155. * Gets a mesh with its auto-generated unique id
  34156. * @param uniqueId defines the unique id to search for
  34157. * @return the found mesh or null if not found at all.
  34158. */
  34159. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34160. /**
  34161. * Gets a the last added mesh using a given id
  34162. * @param id defines the id to search for
  34163. * @return the found mesh or null if not found at all.
  34164. */
  34165. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34166. /**
  34167. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34168. * @param id defines the id to search for
  34169. * @return the found node or null if not found at all
  34170. */
  34171. getLastEntryByID(id: string): Nullable<Node>;
  34172. /**
  34173. * Gets a node (Mesh, Camera, Light) using a given id
  34174. * @param id defines the id to search for
  34175. * @return the found node or null if not found at all
  34176. */
  34177. getNodeByID(id: string): Nullable<Node>;
  34178. /**
  34179. * Gets a node (Mesh, Camera, Light) using a given name
  34180. * @param name defines the name to search for
  34181. * @return the found node or null if not found at all.
  34182. */
  34183. getNodeByName(name: string): Nullable<Node>;
  34184. /**
  34185. * Gets a mesh using a given name
  34186. * @param name defines the name to search for
  34187. * @return the found mesh or null if not found at all.
  34188. */
  34189. getMeshByName(name: string): Nullable<AbstractMesh>;
  34190. /**
  34191. * Gets a transform node using a given name
  34192. * @param name defines the name to search for
  34193. * @return the found transform node or null if not found at all.
  34194. */
  34195. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34196. /**
  34197. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34198. * @param id defines the id to search for
  34199. * @return the found skeleton or null if not found at all.
  34200. */
  34201. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34202. /**
  34203. * Gets a skeleton using a given auto generated unique id
  34204. * @param uniqueId defines the unique id to search for
  34205. * @return the found skeleton or null if not found at all.
  34206. */
  34207. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34208. /**
  34209. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34210. * @param id defines the id to search for
  34211. * @return the found skeleton or null if not found at all.
  34212. */
  34213. getSkeletonById(id: string): Nullable<Skeleton>;
  34214. /**
  34215. * Gets a skeleton using a given name
  34216. * @param name defines the name to search for
  34217. * @return the found skeleton or null if not found at all.
  34218. */
  34219. getSkeletonByName(name: string): Nullable<Skeleton>;
  34220. /**
  34221. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34222. * @param id defines the id to search for
  34223. * @return the found morph target manager or null if not found at all.
  34224. */
  34225. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34226. /**
  34227. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34228. * @param id defines the id to search for
  34229. * @return the found morph target or null if not found at all.
  34230. */
  34231. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34232. /**
  34233. * Gets a boolean indicating if the given mesh is active
  34234. * @param mesh defines the mesh to look for
  34235. * @returns true if the mesh is in the active list
  34236. */
  34237. isActiveMesh(mesh: AbstractMesh): boolean;
  34238. /**
  34239. * Return a unique id as a string which can serve as an identifier for the scene
  34240. */
  34241. readonly uid: string;
  34242. /**
  34243. * Add an externaly attached data from its key.
  34244. * This method call will fail and return false, if such key already exists.
  34245. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34246. * @param key the unique key that identifies the data
  34247. * @param data the data object to associate to the key for this Engine instance
  34248. * @return true if no such key were already present and the data was added successfully, false otherwise
  34249. */
  34250. addExternalData<T>(key: string, data: T): boolean;
  34251. /**
  34252. * Get an externaly attached data from its key
  34253. * @param key the unique key that identifies the data
  34254. * @return the associated data, if present (can be null), or undefined if not present
  34255. */
  34256. getExternalData<T>(key: string): Nullable<T>;
  34257. /**
  34258. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34259. * @param key the unique key that identifies the data
  34260. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34261. * @return the associated data, can be null if the factory returned null.
  34262. */
  34263. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34264. /**
  34265. * Remove an externaly attached data from the Engine instance
  34266. * @param key the unique key that identifies the data
  34267. * @return true if the data was successfully removed, false if it doesn't exist
  34268. */
  34269. removeExternalData(key: string): boolean;
  34270. private _evaluateSubMesh;
  34271. /**
  34272. * Clear the processed materials smart array preventing retention point in material dispose.
  34273. */
  34274. freeProcessedMaterials(): void;
  34275. private _preventFreeActiveMeshesAndRenderingGroups;
  34276. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34277. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34278. * when disposing several meshes in a row or a hierarchy of meshes.
  34279. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34280. */
  34281. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34282. /**
  34283. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34284. */
  34285. freeActiveMeshes(): void;
  34286. /**
  34287. * Clear the info related to rendering groups preventing retention points during dispose.
  34288. */
  34289. freeRenderingGroups(): void;
  34290. /** @hidden */
  34291. _isInIntermediateRendering(): boolean;
  34292. /**
  34293. * Lambda returning the list of potentially active meshes.
  34294. */
  34295. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34296. /**
  34297. * Lambda returning the list of potentially active sub meshes.
  34298. */
  34299. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34300. /**
  34301. * Lambda returning the list of potentially intersecting sub meshes.
  34302. */
  34303. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34304. /**
  34305. * Lambda returning the list of potentially colliding sub meshes.
  34306. */
  34307. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34308. private _activeMeshesFrozen;
  34309. /**
  34310. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34311. * @returns the current scene
  34312. */
  34313. freezeActiveMeshes(): Scene;
  34314. /**
  34315. * Use this function to restart evaluating active meshes on every frame
  34316. * @returns the current scene
  34317. */
  34318. unfreezeActiveMeshes(): Scene;
  34319. private _evaluateActiveMeshes;
  34320. private _activeMesh;
  34321. /**
  34322. * Update the transform matrix to update from the current active camera
  34323. * @param force defines a boolean used to force the update even if cache is up to date
  34324. */
  34325. updateTransformMatrix(force?: boolean): void;
  34326. private _bindFrameBuffer;
  34327. /** @hidden */
  34328. _allowPostProcessClearColor: boolean;
  34329. /** @hidden */
  34330. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34331. private _processSubCameras;
  34332. private _checkIntersections;
  34333. /** @hidden */
  34334. _advancePhysicsEngineStep(step: number): void;
  34335. /**
  34336. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34337. */
  34338. getDeterministicFrameTime: () => number;
  34339. /** @hidden */
  34340. _animate(): void;
  34341. /** Execute all animations (for a frame) */
  34342. animate(): void;
  34343. /**
  34344. * Render the scene
  34345. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34346. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34347. */
  34348. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34349. /**
  34350. * Freeze all materials
  34351. * A frozen material will not be updatable but should be faster to render
  34352. */
  34353. freezeMaterials(): void;
  34354. /**
  34355. * Unfreeze all materials
  34356. * A frozen material will not be updatable but should be faster to render
  34357. */
  34358. unfreezeMaterials(): void;
  34359. /**
  34360. * Releases all held ressources
  34361. */
  34362. dispose(): void;
  34363. /**
  34364. * Gets if the scene is already disposed
  34365. */
  34366. readonly isDisposed: boolean;
  34367. /**
  34368. * Call this function to reduce memory footprint of the scene.
  34369. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34370. */
  34371. clearCachedVertexData(): void;
  34372. /**
  34373. * This function will remove the local cached buffer data from texture.
  34374. * It will save memory but will prevent the texture from being rebuilt
  34375. */
  34376. cleanCachedTextureBuffer(): void;
  34377. /**
  34378. * Get the world extend vectors with an optional filter
  34379. *
  34380. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34381. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34382. */
  34383. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34384. min: Vector3;
  34385. max: Vector3;
  34386. };
  34387. /**
  34388. * Creates a ray that can be used to pick in the scene
  34389. * @param x defines the x coordinate of the origin (on-screen)
  34390. * @param y defines the y coordinate of the origin (on-screen)
  34391. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34392. * @param camera defines the camera to use for the picking
  34393. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34394. * @returns a Ray
  34395. */
  34396. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34397. /**
  34398. * Creates a ray that can be used to pick in the scene
  34399. * @param x defines the x coordinate of the origin (on-screen)
  34400. * @param y defines the y coordinate of the origin (on-screen)
  34401. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34402. * @param result defines the ray where to store the picking ray
  34403. * @param camera defines the camera to use for the picking
  34404. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34405. * @returns the current scene
  34406. */
  34407. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34408. /**
  34409. * Creates a ray that can be used to pick in the scene
  34410. * @param x defines the x coordinate of the origin (on-screen)
  34411. * @param y defines the y coordinate of the origin (on-screen)
  34412. * @param camera defines the camera to use for the picking
  34413. * @returns a Ray
  34414. */
  34415. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34416. /**
  34417. * Creates a ray that can be used to pick in the scene
  34418. * @param x defines the x coordinate of the origin (on-screen)
  34419. * @param y defines the y coordinate of the origin (on-screen)
  34420. * @param result defines the ray where to store the picking ray
  34421. * @param camera defines the camera to use for the picking
  34422. * @returns the current scene
  34423. */
  34424. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34425. /** Launch a ray to try to pick a mesh in the scene
  34426. * @param x position on screen
  34427. * @param y position on screen
  34428. * @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
  34429. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34430. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34431. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34432. * @returns a PickingInfo
  34433. */
  34434. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34435. /** Use the given ray to pick a mesh in the scene
  34436. * @param ray The ray to use to pick meshes
  34437. * @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
  34438. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34439. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34440. * @returns a PickingInfo
  34441. */
  34442. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34443. /**
  34444. * Launch a ray to try to pick a mesh in the scene
  34445. * @param x X position on screen
  34446. * @param y Y position on screen
  34447. * @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
  34448. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34449. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34450. * @returns an array of PickingInfo
  34451. */
  34452. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34453. /**
  34454. * Launch a ray to try to pick a mesh in the scene
  34455. * @param ray Ray to use
  34456. * @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
  34457. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34458. * @returns an array of PickingInfo
  34459. */
  34460. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34461. /**
  34462. * Force the value of meshUnderPointer
  34463. * @param mesh defines the mesh to use
  34464. */
  34465. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34466. /**
  34467. * Gets the mesh under the pointer
  34468. * @returns a Mesh or null if no mesh is under the pointer
  34469. */
  34470. getPointerOverMesh(): Nullable<AbstractMesh>;
  34471. /** @hidden */
  34472. _rebuildGeometries(): void;
  34473. /** @hidden */
  34474. _rebuildTextures(): void;
  34475. private _getByTags;
  34476. /**
  34477. * Get a list of meshes by tags
  34478. * @param tagsQuery defines the tags query to use
  34479. * @param forEach defines a predicate used to filter results
  34480. * @returns an array of Mesh
  34481. */
  34482. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34483. /**
  34484. * Get a list of cameras by tags
  34485. * @param tagsQuery defines the tags query to use
  34486. * @param forEach defines a predicate used to filter results
  34487. * @returns an array of Camera
  34488. */
  34489. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34490. /**
  34491. * Get a list of lights by tags
  34492. * @param tagsQuery defines the tags query to use
  34493. * @param forEach defines a predicate used to filter results
  34494. * @returns an array of Light
  34495. */
  34496. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34497. /**
  34498. * Get a list of materials by tags
  34499. * @param tagsQuery defines the tags query to use
  34500. * @param forEach defines a predicate used to filter results
  34501. * @returns an array of Material
  34502. */
  34503. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34504. /**
  34505. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34506. * This allowed control for front to back rendering or reversly depending of the special needs.
  34507. *
  34508. * @param renderingGroupId The rendering group id corresponding to its index
  34509. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34510. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34511. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34512. */
  34513. 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;
  34514. /**
  34515. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34516. *
  34517. * @param renderingGroupId The rendering group id corresponding to its index
  34518. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34519. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34520. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34521. */
  34522. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34523. /**
  34524. * Gets the current auto clear configuration for one rendering group of the rendering
  34525. * manager.
  34526. * @param index the rendering group index to get the information for
  34527. * @returns The auto clear setup for the requested rendering group
  34528. */
  34529. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34530. private _blockMaterialDirtyMechanism;
  34531. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34532. blockMaterialDirtyMechanism: boolean;
  34533. /**
  34534. * Will flag all materials as dirty to trigger new shader compilation
  34535. * @param flag defines the flag used to specify which material part must be marked as dirty
  34536. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34537. */
  34538. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34539. /** @hidden */
  34540. _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;
  34541. /** @hidden */
  34542. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34543. }
  34544. }
  34545. declare module "babylonjs/assetContainer" {
  34546. import { AbstractScene } from "babylonjs/abstractScene";
  34547. import { Scene } from "babylonjs/scene";
  34548. import { Mesh } from "babylonjs/Meshes/mesh";
  34549. /**
  34550. * Set of assets to keep when moving a scene into an asset container.
  34551. */
  34552. export class KeepAssets extends AbstractScene {
  34553. }
  34554. /**
  34555. * Container with a set of assets that can be added or removed from a scene.
  34556. */
  34557. export class AssetContainer extends AbstractScene {
  34558. /**
  34559. * The scene the AssetContainer belongs to.
  34560. */
  34561. scene: Scene;
  34562. /**
  34563. * Instantiates an AssetContainer.
  34564. * @param scene The scene the AssetContainer belongs to.
  34565. */
  34566. constructor(scene: Scene);
  34567. /**
  34568. * Adds all the assets from the container to the scene.
  34569. */
  34570. addAllToScene(): void;
  34571. /**
  34572. * Removes all the assets in the container from the scene
  34573. */
  34574. removeAllFromScene(): void;
  34575. /**
  34576. * Disposes all the assets in the container
  34577. */
  34578. dispose(): void;
  34579. private _moveAssets;
  34580. /**
  34581. * Removes all the assets contained in the scene and adds them to the container.
  34582. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34583. */
  34584. moveAllFromScene(keepAssets?: KeepAssets): void;
  34585. /**
  34586. * 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.
  34587. * @returns the root mesh
  34588. */
  34589. createRootMesh(): Mesh;
  34590. }
  34591. }
  34592. declare module "babylonjs/abstractScene" {
  34593. import { Scene } from "babylonjs/scene";
  34594. import { Nullable } from "babylonjs/types";
  34595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34596. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34597. import { Geometry } from "babylonjs/Meshes/geometry";
  34598. import { Skeleton } from "babylonjs/Bones/skeleton";
  34599. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34600. import { AssetContainer } from "babylonjs/assetContainer";
  34601. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34602. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34604. import { Material } from "babylonjs/Materials/material";
  34605. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34606. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34607. import { Camera } from "babylonjs/Cameras/camera";
  34608. import { Light } from "babylonjs/Lights/light";
  34609. import { Node } from "babylonjs/node";
  34610. import { Animation } from "babylonjs/Animations/animation";
  34611. /**
  34612. * Defines how the parser contract is defined.
  34613. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34614. */
  34615. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34616. /**
  34617. * Defines how the individual parser contract is defined.
  34618. * These parser can parse an individual asset
  34619. */
  34620. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34621. /**
  34622. * Base class of the scene acting as a container for the different elements composing a scene.
  34623. * This class is dynamically extended by the different components of the scene increasing
  34624. * flexibility and reducing coupling
  34625. */
  34626. export abstract class AbstractScene {
  34627. /**
  34628. * Stores the list of available parsers in the application.
  34629. */
  34630. private static _BabylonFileParsers;
  34631. /**
  34632. * Stores the list of available individual parsers in the application.
  34633. */
  34634. private static _IndividualBabylonFileParsers;
  34635. /**
  34636. * Adds a parser in the list of available ones
  34637. * @param name Defines the name of the parser
  34638. * @param parser Defines the parser to add
  34639. */
  34640. static AddParser(name: string, parser: BabylonFileParser): void;
  34641. /**
  34642. * Gets a general parser from the list of avaialble ones
  34643. * @param name Defines the name of the parser
  34644. * @returns the requested parser or null
  34645. */
  34646. static GetParser(name: string): Nullable<BabylonFileParser>;
  34647. /**
  34648. * Adds n individual parser in the list of available ones
  34649. * @param name Defines the name of the parser
  34650. * @param parser Defines the parser to add
  34651. */
  34652. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34653. /**
  34654. * Gets an individual parser from the list of avaialble ones
  34655. * @param name Defines the name of the parser
  34656. * @returns the requested parser or null
  34657. */
  34658. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34659. /**
  34660. * Parser json data and populate both a scene and its associated container object
  34661. * @param jsonData Defines the data to parse
  34662. * @param scene Defines the scene to parse the data for
  34663. * @param container Defines the container attached to the parsing sequence
  34664. * @param rootUrl Defines the root url of the data
  34665. */
  34666. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34667. /**
  34668. * Gets the list of root nodes (ie. nodes with no parent)
  34669. */
  34670. rootNodes: Node[];
  34671. /** All of the cameras added to this scene
  34672. * @see http://doc.babylonjs.com/babylon101/cameras
  34673. */
  34674. cameras: Camera[];
  34675. /**
  34676. * All of the lights added to this scene
  34677. * @see http://doc.babylonjs.com/babylon101/lights
  34678. */
  34679. lights: Light[];
  34680. /**
  34681. * All of the (abstract) meshes added to this scene
  34682. */
  34683. meshes: AbstractMesh[];
  34684. /**
  34685. * The list of skeletons added to the scene
  34686. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34687. */
  34688. skeletons: Skeleton[];
  34689. /**
  34690. * All of the particle systems added to this scene
  34691. * @see http://doc.babylonjs.com/babylon101/particles
  34692. */
  34693. particleSystems: IParticleSystem[];
  34694. /**
  34695. * Gets a list of Animations associated with the scene
  34696. */
  34697. animations: Animation[];
  34698. /**
  34699. * All of the animation groups added to this scene
  34700. * @see http://doc.babylonjs.com/how_to/group
  34701. */
  34702. animationGroups: AnimationGroup[];
  34703. /**
  34704. * All of the multi-materials added to this scene
  34705. * @see http://doc.babylonjs.com/how_to/multi_materials
  34706. */
  34707. multiMaterials: MultiMaterial[];
  34708. /**
  34709. * All of the materials added to this scene
  34710. * In the context of a Scene, it is not supposed to be modified manually.
  34711. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34712. * Note also that the order of the Material wihin the array is not significant and might change.
  34713. * @see http://doc.babylonjs.com/babylon101/materials
  34714. */
  34715. materials: Material[];
  34716. /**
  34717. * The list of morph target managers added to the scene
  34718. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34719. */
  34720. morphTargetManagers: MorphTargetManager[];
  34721. /**
  34722. * The list of geometries used in the scene.
  34723. */
  34724. geometries: Geometry[];
  34725. /**
  34726. * All of the tranform nodes added to this scene
  34727. * In the context of a Scene, it is not supposed to be modified manually.
  34728. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34729. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34730. * @see http://doc.babylonjs.com/how_to/transformnode
  34731. */
  34732. transformNodes: TransformNode[];
  34733. /**
  34734. * ActionManagers available on the scene.
  34735. */
  34736. actionManagers: AbstractActionManager[];
  34737. /**
  34738. * Textures to keep.
  34739. */
  34740. textures: BaseTexture[];
  34741. /**
  34742. * Environment texture for the scene
  34743. */
  34744. environmentTexture: Nullable<BaseTexture>;
  34745. }
  34746. }
  34747. declare module "babylonjs/Audio/sound" {
  34748. import { Observable } from "babylonjs/Misc/observable";
  34749. import { Vector3 } from "babylonjs/Maths/math";
  34750. import { Nullable } from "babylonjs/types";
  34751. import { Scene } from "babylonjs/scene";
  34752. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34753. /**
  34754. * Defines a sound that can be played in the application.
  34755. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34757. */
  34758. export class Sound {
  34759. /**
  34760. * The name of the sound in the scene.
  34761. */
  34762. name: string;
  34763. /**
  34764. * Does the sound autoplay once loaded.
  34765. */
  34766. autoplay: boolean;
  34767. /**
  34768. * Does the sound loop after it finishes playing once.
  34769. */
  34770. loop: boolean;
  34771. /**
  34772. * Does the sound use a custom attenuation curve to simulate the falloff
  34773. * happening when the source gets further away from the camera.
  34774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34775. */
  34776. useCustomAttenuation: boolean;
  34777. /**
  34778. * The sound track id this sound belongs to.
  34779. */
  34780. soundTrackId: number;
  34781. /**
  34782. * Is this sound currently played.
  34783. */
  34784. isPlaying: boolean;
  34785. /**
  34786. * Is this sound currently paused.
  34787. */
  34788. isPaused: boolean;
  34789. /**
  34790. * Does this sound enables spatial sound.
  34791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34792. */
  34793. spatialSound: boolean;
  34794. /**
  34795. * Define the reference distance the sound should be heard perfectly.
  34796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34797. */
  34798. refDistance: number;
  34799. /**
  34800. * Define the roll off factor of spatial sounds.
  34801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34802. */
  34803. rolloffFactor: number;
  34804. /**
  34805. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34807. */
  34808. maxDistance: number;
  34809. /**
  34810. * Define the distance attenuation model the sound will follow.
  34811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34812. */
  34813. distanceModel: string;
  34814. /**
  34815. * @hidden
  34816. * Back Compat
  34817. **/
  34818. onended: () => any;
  34819. /**
  34820. * Observable event when the current playing sound finishes.
  34821. */
  34822. onEndedObservable: Observable<Sound>;
  34823. private _panningModel;
  34824. private _playbackRate;
  34825. private _streaming;
  34826. private _startTime;
  34827. private _startOffset;
  34828. private _position;
  34829. /** @hidden */
  34830. _positionInEmitterSpace: boolean;
  34831. private _localDirection;
  34832. private _volume;
  34833. private _isReadyToPlay;
  34834. private _isDirectional;
  34835. private _readyToPlayCallback;
  34836. private _audioBuffer;
  34837. private _soundSource;
  34838. private _streamingSource;
  34839. private _soundPanner;
  34840. private _soundGain;
  34841. private _inputAudioNode;
  34842. private _outputAudioNode;
  34843. private _coneInnerAngle;
  34844. private _coneOuterAngle;
  34845. private _coneOuterGain;
  34846. private _scene;
  34847. private _connectedTransformNode;
  34848. private _customAttenuationFunction;
  34849. private _registerFunc;
  34850. private _isOutputConnected;
  34851. private _htmlAudioElement;
  34852. private _urlType;
  34853. /** @hidden */
  34854. static _SceneComponentInitialization: (scene: Scene) => void;
  34855. /**
  34856. * Create a sound and attach it to a scene
  34857. * @param name Name of your sound
  34858. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34859. * @param scene defines the scene the sound belongs to
  34860. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34861. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34862. */
  34863. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34864. /**
  34865. * Release the sound and its associated resources
  34866. */
  34867. dispose(): void;
  34868. /**
  34869. * Gets if the sounds is ready to be played or not.
  34870. * @returns true if ready, otherwise false
  34871. */
  34872. isReady(): boolean;
  34873. private _soundLoaded;
  34874. /**
  34875. * Sets the data of the sound from an audiobuffer
  34876. * @param audioBuffer The audioBuffer containing the data
  34877. */
  34878. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34879. /**
  34880. * Updates the current sounds options such as maxdistance, loop...
  34881. * @param options A JSON object containing values named as the object properties
  34882. */
  34883. updateOptions(options: any): void;
  34884. private _createSpatialParameters;
  34885. private _updateSpatialParameters;
  34886. /**
  34887. * Switch the panning model to HRTF:
  34888. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34889. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34890. */
  34891. switchPanningModelToHRTF(): void;
  34892. /**
  34893. * Switch the panning model to Equal Power:
  34894. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34896. */
  34897. switchPanningModelToEqualPower(): void;
  34898. private _switchPanningModel;
  34899. /**
  34900. * Connect this sound to a sound track audio node like gain...
  34901. * @param soundTrackAudioNode the sound track audio node to connect to
  34902. */
  34903. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34904. /**
  34905. * Transform this sound into a directional source
  34906. * @param coneInnerAngle Size of the inner cone in degree
  34907. * @param coneOuterAngle Size of the outer cone in degree
  34908. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34909. */
  34910. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34911. /**
  34912. * Gets or sets the inner angle for the directional cone.
  34913. */
  34914. /**
  34915. * Gets or sets the inner angle for the directional cone.
  34916. */
  34917. directionalConeInnerAngle: number;
  34918. /**
  34919. * Gets or sets the outer angle for the directional cone.
  34920. */
  34921. /**
  34922. * Gets or sets the outer angle for the directional cone.
  34923. */
  34924. directionalConeOuterAngle: number;
  34925. /**
  34926. * Sets the position of the emitter if spatial sound is enabled
  34927. * @param newPosition Defines the new posisiton
  34928. */
  34929. setPosition(newPosition: Vector3): void;
  34930. /**
  34931. * Sets the local direction of the emitter if spatial sound is enabled
  34932. * @param newLocalDirection Defines the new local direction
  34933. */
  34934. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34935. private _updateDirection;
  34936. /** @hidden */
  34937. updateDistanceFromListener(): void;
  34938. /**
  34939. * Sets a new custom attenuation function for the sound.
  34940. * @param callback Defines the function used for the attenuation
  34941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34942. */
  34943. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34944. /**
  34945. * Play the sound
  34946. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34947. * @param offset (optional) Start the sound setting it at a specific time
  34948. */
  34949. play(time?: number, offset?: number): void;
  34950. private _onended;
  34951. /**
  34952. * Stop the sound
  34953. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34954. */
  34955. stop(time?: number): void;
  34956. /**
  34957. * Put the sound in pause
  34958. */
  34959. pause(): void;
  34960. /**
  34961. * Sets a dedicated volume for this sounds
  34962. * @param newVolume Define the new volume of the sound
  34963. * @param time Define in how long the sound should be at this value
  34964. */
  34965. setVolume(newVolume: number, time?: number): void;
  34966. /**
  34967. * Set the sound play back rate
  34968. * @param newPlaybackRate Define the playback rate the sound should be played at
  34969. */
  34970. setPlaybackRate(newPlaybackRate: number): void;
  34971. /**
  34972. * Gets the volume of the sound.
  34973. * @returns the volume of the sound
  34974. */
  34975. getVolume(): number;
  34976. /**
  34977. * Attach the sound to a dedicated mesh
  34978. * @param transformNode The transform node to connect the sound with
  34979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34980. */
  34981. attachToMesh(transformNode: TransformNode): void;
  34982. /**
  34983. * Detach the sound from the previously attached mesh
  34984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34985. */
  34986. detachFromMesh(): void;
  34987. private _onRegisterAfterWorldMatrixUpdate;
  34988. /**
  34989. * Clone the current sound in the scene.
  34990. * @returns the new sound clone
  34991. */
  34992. clone(): Nullable<Sound>;
  34993. /**
  34994. * Gets the current underlying audio buffer containing the data
  34995. * @returns the audio buffer
  34996. */
  34997. getAudioBuffer(): Nullable<AudioBuffer>;
  34998. /**
  34999. * Serializes the Sound in a JSON representation
  35000. * @returns the JSON representation of the sound
  35001. */
  35002. serialize(): any;
  35003. /**
  35004. * Parse a JSON representation of a sound to innstantiate in a given scene
  35005. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35006. * @param scene Define the scene the new parsed sound should be created in
  35007. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35008. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35009. * @returns the newly parsed sound
  35010. */
  35011. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35012. }
  35013. }
  35014. declare module "babylonjs/Actions/directAudioActions" {
  35015. import { Action } from "babylonjs/Actions/action";
  35016. import { Condition } from "babylonjs/Actions/condition";
  35017. import { Sound } from "babylonjs/Audio/sound";
  35018. /**
  35019. * This defines an action helpful to play a defined sound on a triggered action.
  35020. */
  35021. export class PlaySoundAction extends Action {
  35022. private _sound;
  35023. /**
  35024. * Instantiate the action
  35025. * @param triggerOptions defines the trigger options
  35026. * @param sound defines the sound to play
  35027. * @param condition defines the trigger related conditions
  35028. */
  35029. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35030. /** @hidden */
  35031. _prepare(): void;
  35032. /**
  35033. * Execute the action and play the sound.
  35034. */
  35035. execute(): void;
  35036. /**
  35037. * Serializes the actions and its related information.
  35038. * @param parent defines the object to serialize in
  35039. * @returns the serialized object
  35040. */
  35041. serialize(parent: any): any;
  35042. }
  35043. /**
  35044. * This defines an action helpful to stop a defined sound on a triggered action.
  35045. */
  35046. export class StopSoundAction extends Action {
  35047. private _sound;
  35048. /**
  35049. * Instantiate the action
  35050. * @param triggerOptions defines the trigger options
  35051. * @param sound defines the sound to stop
  35052. * @param condition defines the trigger related conditions
  35053. */
  35054. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35055. /** @hidden */
  35056. _prepare(): void;
  35057. /**
  35058. * Execute the action and stop the sound.
  35059. */
  35060. execute(): void;
  35061. /**
  35062. * Serializes the actions and its related information.
  35063. * @param parent defines the object to serialize in
  35064. * @returns the serialized object
  35065. */
  35066. serialize(parent: any): any;
  35067. }
  35068. }
  35069. declare module "babylonjs/Actions/interpolateValueAction" {
  35070. import { Action } from "babylonjs/Actions/action";
  35071. import { Condition } from "babylonjs/Actions/condition";
  35072. import { Observable } from "babylonjs/Misc/observable";
  35073. /**
  35074. * This defines an action responsible to change the value of a property
  35075. * by interpolating between its current value and the newly set one once triggered.
  35076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35077. */
  35078. export class InterpolateValueAction extends Action {
  35079. /**
  35080. * Defines the path of the property where the value should be interpolated
  35081. */
  35082. propertyPath: string;
  35083. /**
  35084. * Defines the target value at the end of the interpolation.
  35085. */
  35086. value: any;
  35087. /**
  35088. * Defines the time it will take for the property to interpolate to the value.
  35089. */
  35090. duration: number;
  35091. /**
  35092. * Defines if the other scene animations should be stopped when the action has been triggered
  35093. */
  35094. stopOtherAnimations?: boolean;
  35095. /**
  35096. * Defines a callback raised once the interpolation animation has been done.
  35097. */
  35098. onInterpolationDone?: () => void;
  35099. /**
  35100. * Observable triggered once the interpolation animation has been done.
  35101. */
  35102. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35103. private _target;
  35104. private _effectiveTarget;
  35105. private _property;
  35106. /**
  35107. * Instantiate the action
  35108. * @param triggerOptions defines the trigger options
  35109. * @param target defines the object containing the value to interpolate
  35110. * @param propertyPath defines the path to the property in the target object
  35111. * @param value defines the target value at the end of the interpolation
  35112. * @param duration deines the time it will take for the property to interpolate to the value.
  35113. * @param condition defines the trigger related conditions
  35114. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35115. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35116. */
  35117. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35118. /** @hidden */
  35119. _prepare(): void;
  35120. /**
  35121. * Execute the action starts the value interpolation.
  35122. */
  35123. execute(): void;
  35124. /**
  35125. * Serializes the actions and its related information.
  35126. * @param parent defines the object to serialize in
  35127. * @returns the serialized object
  35128. */
  35129. serialize(parent: any): any;
  35130. }
  35131. }
  35132. declare module "babylonjs/Actions/index" {
  35133. export * from "babylonjs/Actions/action";
  35134. export * from "babylonjs/Actions/actionEvent";
  35135. export * from "babylonjs/Actions/actionManager";
  35136. export * from "babylonjs/Actions/condition";
  35137. export * from "babylonjs/Actions/directActions";
  35138. export * from "babylonjs/Actions/directAudioActions";
  35139. export * from "babylonjs/Actions/interpolateValueAction";
  35140. }
  35141. declare module "babylonjs/Animations/index" {
  35142. export * from "babylonjs/Animations/animatable";
  35143. export * from "babylonjs/Animations/animation";
  35144. export * from "babylonjs/Animations/animationGroup";
  35145. export * from "babylonjs/Animations/animationPropertiesOverride";
  35146. export * from "babylonjs/Animations/easing";
  35147. export * from "babylonjs/Animations/runtimeAnimation";
  35148. export * from "babylonjs/Animations/animationEvent";
  35149. export * from "babylonjs/Animations/animationGroup";
  35150. export * from "babylonjs/Animations/animationKey";
  35151. export * from "babylonjs/Animations/animationRange";
  35152. }
  35153. declare module "babylonjs/Audio/soundTrack" {
  35154. import { Sound } from "babylonjs/Audio/sound";
  35155. import { Analyser } from "babylonjs/Audio/analyser";
  35156. import { Scene } from "babylonjs/scene";
  35157. /**
  35158. * Options allowed during the creation of a sound track.
  35159. */
  35160. export interface ISoundTrackOptions {
  35161. /**
  35162. * The volume the sound track should take during creation
  35163. */
  35164. volume?: number;
  35165. /**
  35166. * Define if the sound track is the main sound track of the scene
  35167. */
  35168. mainTrack?: boolean;
  35169. }
  35170. /**
  35171. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35172. * It will be also used in a future release to apply effects on a specific track.
  35173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35174. */
  35175. export class SoundTrack {
  35176. /**
  35177. * The unique identifier of the sound track in the scene.
  35178. */
  35179. id: number;
  35180. /**
  35181. * The list of sounds included in the sound track.
  35182. */
  35183. soundCollection: Array<Sound>;
  35184. private _outputAudioNode;
  35185. private _scene;
  35186. private _isMainTrack;
  35187. private _connectedAnalyser;
  35188. private _options;
  35189. private _isInitialized;
  35190. /**
  35191. * Creates a new sound track.
  35192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35193. * @param scene Define the scene the sound track belongs to
  35194. * @param options
  35195. */
  35196. constructor(scene: Scene, options?: ISoundTrackOptions);
  35197. private _initializeSoundTrackAudioGraph;
  35198. /**
  35199. * Release the sound track and its associated resources
  35200. */
  35201. dispose(): void;
  35202. /**
  35203. * Adds a sound to this sound track
  35204. * @param sound define the cound to add
  35205. * @ignoreNaming
  35206. */
  35207. AddSound(sound: Sound): void;
  35208. /**
  35209. * Removes a sound to this sound track
  35210. * @param sound define the cound to remove
  35211. * @ignoreNaming
  35212. */
  35213. RemoveSound(sound: Sound): void;
  35214. /**
  35215. * Set a global volume for the full sound track.
  35216. * @param newVolume Define the new volume of the sound track
  35217. */
  35218. setVolume(newVolume: number): void;
  35219. /**
  35220. * Switch the panning model to HRTF:
  35221. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35223. */
  35224. switchPanningModelToHRTF(): void;
  35225. /**
  35226. * Switch the panning model to Equal Power:
  35227. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35229. */
  35230. switchPanningModelToEqualPower(): void;
  35231. /**
  35232. * Connect the sound track to an audio analyser allowing some amazing
  35233. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35235. * @param analyser The analyser to connect to the engine
  35236. */
  35237. connectToAnalyser(analyser: Analyser): void;
  35238. }
  35239. }
  35240. declare module "babylonjs/Audio/audioSceneComponent" {
  35241. import { Sound } from "babylonjs/Audio/sound";
  35242. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35243. import { Nullable } from "babylonjs/types";
  35244. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35245. import { Scene } from "babylonjs/scene";
  35246. import { AbstractScene } from "babylonjs/abstractScene";
  35247. module "babylonjs/abstractScene" {
  35248. interface AbstractScene {
  35249. /**
  35250. * The list of sounds used in the scene.
  35251. */
  35252. sounds: Nullable<Array<Sound>>;
  35253. }
  35254. }
  35255. module "babylonjs/scene" {
  35256. interface Scene {
  35257. /**
  35258. * @hidden
  35259. * Backing field
  35260. */
  35261. _mainSoundTrack: SoundTrack;
  35262. /**
  35263. * The main sound track played by the scene.
  35264. * It cotains your primary collection of sounds.
  35265. */
  35266. mainSoundTrack: SoundTrack;
  35267. /**
  35268. * The list of sound tracks added to the scene
  35269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35270. */
  35271. soundTracks: Nullable<Array<SoundTrack>>;
  35272. /**
  35273. * Gets a sound using a given name
  35274. * @param name defines the name to search for
  35275. * @return the found sound or null if not found at all.
  35276. */
  35277. getSoundByName(name: string): Nullable<Sound>;
  35278. /**
  35279. * Gets or sets if audio support is enabled
  35280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35281. */
  35282. audioEnabled: boolean;
  35283. /**
  35284. * Gets or sets if audio will be output to headphones
  35285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35286. */
  35287. headphone: boolean;
  35288. }
  35289. }
  35290. /**
  35291. * Defines the sound scene component responsible to manage any sounds
  35292. * in a given scene.
  35293. */
  35294. export class AudioSceneComponent implements ISceneSerializableComponent {
  35295. /**
  35296. * The component name helpfull to identify the component in the list of scene components.
  35297. */
  35298. readonly name: string;
  35299. /**
  35300. * The scene the component belongs to.
  35301. */
  35302. scene: Scene;
  35303. private _audioEnabled;
  35304. /**
  35305. * Gets whether audio is enabled or not.
  35306. * Please use related enable/disable method to switch state.
  35307. */
  35308. readonly audioEnabled: boolean;
  35309. private _headphone;
  35310. /**
  35311. * Gets whether audio is outputing to headphone or not.
  35312. * Please use the according Switch methods to change output.
  35313. */
  35314. readonly headphone: boolean;
  35315. /**
  35316. * Creates a new instance of the component for the given scene
  35317. * @param scene Defines the scene to register the component in
  35318. */
  35319. constructor(scene: Scene);
  35320. /**
  35321. * Registers the component in a given scene
  35322. */
  35323. register(): void;
  35324. /**
  35325. * Rebuilds the elements related to this component in case of
  35326. * context lost for instance.
  35327. */
  35328. rebuild(): void;
  35329. /**
  35330. * Serializes the component data to the specified json object
  35331. * @param serializationObject The object to serialize to
  35332. */
  35333. serialize(serializationObject: any): void;
  35334. /**
  35335. * Adds all the element from the container to the scene
  35336. * @param container the container holding the elements
  35337. */
  35338. addFromContainer(container: AbstractScene): void;
  35339. /**
  35340. * Removes all the elements in the container from the scene
  35341. * @param container contains the elements to remove
  35342. * @param dispose if the removed element should be disposed (default: false)
  35343. */
  35344. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35345. /**
  35346. * Disposes the component and the associated ressources.
  35347. */
  35348. dispose(): void;
  35349. /**
  35350. * Disables audio in the associated scene.
  35351. */
  35352. disableAudio(): void;
  35353. /**
  35354. * Enables audio in the associated scene.
  35355. */
  35356. enableAudio(): void;
  35357. /**
  35358. * Switch audio to headphone output.
  35359. */
  35360. switchAudioModeForHeadphones(): void;
  35361. /**
  35362. * Switch audio to normal speakers.
  35363. */
  35364. switchAudioModeForNormalSpeakers(): void;
  35365. private _afterRender;
  35366. }
  35367. }
  35368. declare module "babylonjs/Audio/weightedsound" {
  35369. import { Sound } from "babylonjs/Audio/sound";
  35370. /**
  35371. * Wraps one or more Sound objects and selects one with random weight for playback.
  35372. */
  35373. export class WeightedSound {
  35374. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35375. loop: boolean;
  35376. private _coneInnerAngle;
  35377. private _coneOuterAngle;
  35378. private _volume;
  35379. /** A Sound is currently playing. */
  35380. isPlaying: boolean;
  35381. /** A Sound is currently paused. */
  35382. isPaused: boolean;
  35383. private _sounds;
  35384. private _weights;
  35385. private _currentIndex?;
  35386. /**
  35387. * Creates a new WeightedSound from the list of sounds given.
  35388. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35389. * @param sounds Array of Sounds that will be selected from.
  35390. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35391. */
  35392. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35393. /**
  35394. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35395. */
  35396. /**
  35397. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35398. */
  35399. directionalConeInnerAngle: number;
  35400. /**
  35401. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35402. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35403. */
  35404. /**
  35405. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35406. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35407. */
  35408. directionalConeOuterAngle: number;
  35409. /**
  35410. * Playback volume.
  35411. */
  35412. /**
  35413. * Playback volume.
  35414. */
  35415. volume: number;
  35416. private _onended;
  35417. /**
  35418. * Suspend playback
  35419. */
  35420. pause(): void;
  35421. /**
  35422. * Stop playback
  35423. */
  35424. stop(): void;
  35425. /**
  35426. * Start playback.
  35427. * @param startOffset Position the clip head at a specific time in seconds.
  35428. */
  35429. play(startOffset?: number): void;
  35430. }
  35431. }
  35432. declare module "babylonjs/Audio/index" {
  35433. export * from "babylonjs/Audio/analyser";
  35434. export * from "babylonjs/Audio/audioEngine";
  35435. export * from "babylonjs/Audio/audioSceneComponent";
  35436. export * from "babylonjs/Audio/sound";
  35437. export * from "babylonjs/Audio/soundTrack";
  35438. export * from "babylonjs/Audio/weightedsound";
  35439. }
  35440. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35441. import { Behavior } from "babylonjs/Behaviors/behavior";
  35442. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35443. import { BackEase } from "babylonjs/Animations/easing";
  35444. /**
  35445. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35446. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35447. */
  35448. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35449. /**
  35450. * Gets the name of the behavior.
  35451. */
  35452. readonly name: string;
  35453. /**
  35454. * The easing function used by animations
  35455. */
  35456. static EasingFunction: BackEase;
  35457. /**
  35458. * The easing mode used by animations
  35459. */
  35460. static EasingMode: number;
  35461. /**
  35462. * The duration of the animation, in milliseconds
  35463. */
  35464. transitionDuration: number;
  35465. /**
  35466. * Length of the distance animated by the transition when lower radius is reached
  35467. */
  35468. lowerRadiusTransitionRange: number;
  35469. /**
  35470. * Length of the distance animated by the transition when upper radius is reached
  35471. */
  35472. upperRadiusTransitionRange: number;
  35473. private _autoTransitionRange;
  35474. /**
  35475. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35476. */
  35477. /**
  35478. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35479. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35480. */
  35481. autoTransitionRange: boolean;
  35482. private _attachedCamera;
  35483. private _onAfterCheckInputsObserver;
  35484. private _onMeshTargetChangedObserver;
  35485. /**
  35486. * Initializes the behavior.
  35487. */
  35488. init(): void;
  35489. /**
  35490. * Attaches the behavior to its arc rotate camera.
  35491. * @param camera Defines the camera to attach the behavior to
  35492. */
  35493. attach(camera: ArcRotateCamera): void;
  35494. /**
  35495. * Detaches the behavior from its current arc rotate camera.
  35496. */
  35497. detach(): void;
  35498. private _radiusIsAnimating;
  35499. private _radiusBounceTransition;
  35500. private _animatables;
  35501. private _cachedWheelPrecision;
  35502. /**
  35503. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35504. * @param radiusLimit The limit to check against.
  35505. * @return Bool to indicate if at limit.
  35506. */
  35507. private _isRadiusAtLimit;
  35508. /**
  35509. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35510. * @param radiusDelta The delta by which to animate to. Can be negative.
  35511. */
  35512. private _applyBoundRadiusAnimation;
  35513. /**
  35514. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35515. */
  35516. protected _clearAnimationLocks(): void;
  35517. /**
  35518. * Stops and removes all animations that have been applied to the camera
  35519. */
  35520. stopAllAnimations(): void;
  35521. }
  35522. }
  35523. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35524. import { Behavior } from "babylonjs/Behaviors/behavior";
  35525. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35526. import { ExponentialEase } from "babylonjs/Animations/easing";
  35527. import { Nullable } from "babylonjs/types";
  35528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35529. import { Vector3 } from "babylonjs/Maths/math";
  35530. /**
  35531. * 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.
  35532. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35533. */
  35534. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35535. /**
  35536. * Gets the name of the behavior.
  35537. */
  35538. readonly name: string;
  35539. private _mode;
  35540. private _radiusScale;
  35541. private _positionScale;
  35542. private _defaultElevation;
  35543. private _elevationReturnTime;
  35544. private _elevationReturnWaitTime;
  35545. private _zoomStopsAnimation;
  35546. private _framingTime;
  35547. /**
  35548. * The easing function used by animations
  35549. */
  35550. static EasingFunction: ExponentialEase;
  35551. /**
  35552. * The easing mode used by animations
  35553. */
  35554. static EasingMode: number;
  35555. /**
  35556. * Sets the current mode used by the behavior
  35557. */
  35558. /**
  35559. * Gets current mode used by the behavior.
  35560. */
  35561. mode: number;
  35562. /**
  35563. * Sets the scale applied to the radius (1 by default)
  35564. */
  35565. /**
  35566. * Gets the scale applied to the radius
  35567. */
  35568. radiusScale: number;
  35569. /**
  35570. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35571. */
  35572. /**
  35573. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35574. */
  35575. positionScale: number;
  35576. /**
  35577. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35578. * behaviour is triggered, in radians.
  35579. */
  35580. /**
  35581. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35582. * behaviour is triggered, in radians.
  35583. */
  35584. defaultElevation: number;
  35585. /**
  35586. * Sets the time (in milliseconds) taken to return to the default beta position.
  35587. * Negative value indicates camera should not return to default.
  35588. */
  35589. /**
  35590. * Gets the time (in milliseconds) taken to return to the default beta position.
  35591. * Negative value indicates camera should not return to default.
  35592. */
  35593. elevationReturnTime: number;
  35594. /**
  35595. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35596. */
  35597. /**
  35598. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35599. */
  35600. elevationReturnWaitTime: number;
  35601. /**
  35602. * Sets the flag that indicates if user zooming should stop animation.
  35603. */
  35604. /**
  35605. * Gets the flag that indicates if user zooming should stop animation.
  35606. */
  35607. zoomStopsAnimation: boolean;
  35608. /**
  35609. * Sets the transition time when framing the mesh, in milliseconds
  35610. */
  35611. /**
  35612. * Gets the transition time when framing the mesh, in milliseconds
  35613. */
  35614. framingTime: number;
  35615. /**
  35616. * Define if the behavior should automatically change the configured
  35617. * camera limits and sensibilities.
  35618. */
  35619. autoCorrectCameraLimitsAndSensibility: boolean;
  35620. private _onPrePointerObservableObserver;
  35621. private _onAfterCheckInputsObserver;
  35622. private _onMeshTargetChangedObserver;
  35623. private _attachedCamera;
  35624. private _isPointerDown;
  35625. private _lastInteractionTime;
  35626. /**
  35627. * Initializes the behavior.
  35628. */
  35629. init(): void;
  35630. /**
  35631. * Attaches the behavior to its arc rotate camera.
  35632. * @param camera Defines the camera to attach the behavior to
  35633. */
  35634. attach(camera: ArcRotateCamera): void;
  35635. /**
  35636. * Detaches the behavior from its current arc rotate camera.
  35637. */
  35638. detach(): void;
  35639. private _animatables;
  35640. private _betaIsAnimating;
  35641. private _betaTransition;
  35642. private _radiusTransition;
  35643. private _vectorTransition;
  35644. /**
  35645. * Targets the given mesh and updates zoom level accordingly.
  35646. * @param mesh The mesh to target.
  35647. * @param radius Optional. If a cached radius position already exists, overrides default.
  35648. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35649. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35650. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35651. */
  35652. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35653. /**
  35654. * Targets the given mesh with its children and updates zoom level accordingly.
  35655. * @param mesh The mesh to target.
  35656. * @param radius Optional. If a cached radius position already exists, overrides default.
  35657. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35658. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35659. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35660. */
  35661. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35662. /**
  35663. * Targets the given meshes with their children and updates zoom level accordingly.
  35664. * @param meshes The mesh to target.
  35665. * @param radius Optional. If a cached radius position already exists, overrides default.
  35666. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35667. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35668. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35669. */
  35670. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35671. /**
  35672. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35673. * @param minimumWorld Determines the smaller position of the bounding box extend
  35674. * @param maximumWorld Determines the bigger position of the bounding box extend
  35675. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35676. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35677. */
  35678. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35679. /**
  35680. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35681. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35682. * frustum width.
  35683. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35684. * to fully enclose the mesh in the viewing frustum.
  35685. */
  35686. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35687. /**
  35688. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35689. * is automatically returned to its default position (expected to be above ground plane).
  35690. */
  35691. private _maintainCameraAboveGround;
  35692. /**
  35693. * Returns the frustum slope based on the canvas ratio and camera FOV
  35694. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35695. */
  35696. private _getFrustumSlope;
  35697. /**
  35698. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35699. */
  35700. private _clearAnimationLocks;
  35701. /**
  35702. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35703. */
  35704. private _applyUserInteraction;
  35705. /**
  35706. * Stops and removes all animations that have been applied to the camera
  35707. */
  35708. stopAllAnimations(): void;
  35709. /**
  35710. * Gets a value indicating if the user is moving the camera
  35711. */
  35712. readonly isUserIsMoving: boolean;
  35713. /**
  35714. * The camera can move all the way towards the mesh.
  35715. */
  35716. static IgnoreBoundsSizeMode: number;
  35717. /**
  35718. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35719. */
  35720. static FitFrustumSidesMode: number;
  35721. }
  35722. }
  35723. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35724. import { Nullable } from "babylonjs/types";
  35725. import { Camera } from "babylonjs/Cameras/camera";
  35726. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35727. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35728. /**
  35729. * Base class for Camera Pointer Inputs.
  35730. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35731. * for example usage.
  35732. */
  35733. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35734. /**
  35735. * Defines the camera the input is attached to.
  35736. */
  35737. abstract camera: Camera;
  35738. /**
  35739. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35740. */
  35741. protected _altKey: boolean;
  35742. protected _ctrlKey: boolean;
  35743. protected _metaKey: boolean;
  35744. protected _shiftKey: boolean;
  35745. /**
  35746. * Which mouse buttons were pressed at time of last mouse event.
  35747. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35748. */
  35749. protected _buttonsPressed: number;
  35750. /**
  35751. * Defines the buttons associated with the input to handle camera move.
  35752. */
  35753. buttons: number[];
  35754. /**
  35755. * Attach the input controls to a specific dom element to get the input from.
  35756. * @param element Defines the element the controls should be listened from
  35757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35758. */
  35759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35760. /**
  35761. * Detach the current controls from the specified dom element.
  35762. * @param element Defines the element to stop listening the inputs from
  35763. */
  35764. detachControl(element: Nullable<HTMLElement>): void;
  35765. /**
  35766. * Gets the class name of the current input.
  35767. * @returns the class name
  35768. */
  35769. getClassName(): string;
  35770. /**
  35771. * Get the friendly name associated with the input class.
  35772. * @returns the input friendly name
  35773. */
  35774. getSimpleName(): string;
  35775. /**
  35776. * Called on pointer POINTERDOUBLETAP event.
  35777. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35778. */
  35779. protected onDoubleTap(type: string): void;
  35780. /**
  35781. * Called on pointer POINTERMOVE event if only a single touch is active.
  35782. * Override this method to provide functionality.
  35783. */
  35784. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35785. /**
  35786. * Called on pointer POINTERMOVE event if multiple touches are active.
  35787. * Override this method to provide functionality.
  35788. */
  35789. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35790. /**
  35791. * Called on JS contextmenu event.
  35792. * Override this method to provide functionality.
  35793. */
  35794. protected onContextMenu(evt: PointerEvent): void;
  35795. /**
  35796. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35797. * press.
  35798. * Override this method to provide functionality.
  35799. */
  35800. protected onButtonDown(evt: PointerEvent): void;
  35801. /**
  35802. * Called each time a new POINTERUP event occurs. Ie, for each button
  35803. * release.
  35804. * Override this method to provide functionality.
  35805. */
  35806. protected onButtonUp(evt: PointerEvent): void;
  35807. /**
  35808. * Called when window becomes inactive.
  35809. * Override this method to provide functionality.
  35810. */
  35811. protected onLostFocus(): void;
  35812. private _pointerInput;
  35813. private _observer;
  35814. private _onLostFocus;
  35815. private pointA;
  35816. private pointB;
  35817. }
  35818. }
  35819. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35820. import { Nullable } from "babylonjs/types";
  35821. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35822. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35823. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35824. /**
  35825. * Manage the pointers inputs to control an arc rotate camera.
  35826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35827. */
  35828. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35829. /**
  35830. * Defines the camera the input is attached to.
  35831. */
  35832. camera: ArcRotateCamera;
  35833. /**
  35834. * Gets the class name of the current input.
  35835. * @returns the class name
  35836. */
  35837. getClassName(): string;
  35838. /**
  35839. * Defines the buttons associated with the input to handle camera move.
  35840. */
  35841. buttons: number[];
  35842. /**
  35843. * Defines the pointer angular sensibility along the X axis or how fast is
  35844. * the camera rotating.
  35845. */
  35846. angularSensibilityX: number;
  35847. /**
  35848. * Defines the pointer angular sensibility along the Y axis or how fast is
  35849. * the camera rotating.
  35850. */
  35851. angularSensibilityY: number;
  35852. /**
  35853. * Defines the pointer pinch precision or how fast is the camera zooming.
  35854. */
  35855. pinchPrecision: number;
  35856. /**
  35857. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35858. * from 0.
  35859. * It defines the percentage of current camera.radius to use as delta when
  35860. * pinch zoom is used.
  35861. */
  35862. pinchDeltaPercentage: number;
  35863. /**
  35864. * Defines the pointer panning sensibility or how fast is the camera moving.
  35865. */
  35866. panningSensibility: number;
  35867. /**
  35868. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35869. */
  35870. multiTouchPanning: boolean;
  35871. /**
  35872. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35873. * zoom (pinch) through multitouch.
  35874. */
  35875. multiTouchPanAndZoom: boolean;
  35876. /**
  35877. * Revers pinch action direction.
  35878. */
  35879. pinchInwards: boolean;
  35880. private _isPanClick;
  35881. private _twoFingerActivityCount;
  35882. private _isPinching;
  35883. /**
  35884. * Called on pointer POINTERMOVE event if only a single touch is active.
  35885. */
  35886. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35887. /**
  35888. * Called on pointer POINTERDOUBLETAP event.
  35889. */
  35890. protected onDoubleTap(type: string): void;
  35891. /**
  35892. * Called on pointer POINTERMOVE event if multiple touches are active.
  35893. */
  35894. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35895. /**
  35896. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35897. * press.
  35898. */
  35899. protected onButtonDown(evt: PointerEvent): void;
  35900. /**
  35901. * Called each time a new POINTERUP event occurs. Ie, for each button
  35902. * release.
  35903. */
  35904. protected onButtonUp(evt: PointerEvent): void;
  35905. /**
  35906. * Called when window becomes inactive.
  35907. */
  35908. protected onLostFocus(): void;
  35909. }
  35910. }
  35911. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35912. import { Nullable } from "babylonjs/types";
  35913. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35914. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35915. /**
  35916. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35917. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35918. */
  35919. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35920. /**
  35921. * Defines the camera the input is attached to.
  35922. */
  35923. camera: ArcRotateCamera;
  35924. /**
  35925. * Defines the list of key codes associated with the up action (increase alpha)
  35926. */
  35927. keysUp: number[];
  35928. /**
  35929. * Defines the list of key codes associated with the down action (decrease alpha)
  35930. */
  35931. keysDown: number[];
  35932. /**
  35933. * Defines the list of key codes associated with the left action (increase beta)
  35934. */
  35935. keysLeft: number[];
  35936. /**
  35937. * Defines the list of key codes associated with the right action (decrease beta)
  35938. */
  35939. keysRight: number[];
  35940. /**
  35941. * Defines the list of key codes associated with the reset action.
  35942. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35943. */
  35944. keysReset: number[];
  35945. /**
  35946. * Defines the panning sensibility of the inputs.
  35947. * (How fast is the camera paning)
  35948. */
  35949. panningSensibility: number;
  35950. /**
  35951. * Defines the zooming sensibility of the inputs.
  35952. * (How fast is the camera zooming)
  35953. */
  35954. zoomingSensibility: number;
  35955. /**
  35956. * Defines wether maintaining the alt key down switch the movement mode from
  35957. * orientation to zoom.
  35958. */
  35959. useAltToZoom: boolean;
  35960. /**
  35961. * Rotation speed of the camera
  35962. */
  35963. angularSpeed: number;
  35964. private _keys;
  35965. private _ctrlPressed;
  35966. private _altPressed;
  35967. private _onCanvasBlurObserver;
  35968. private _onKeyboardObserver;
  35969. private _engine;
  35970. private _scene;
  35971. /**
  35972. * Attach the input controls to a specific dom element to get the input from.
  35973. * @param element Defines the element the controls should be listened from
  35974. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35975. */
  35976. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35977. /**
  35978. * Detach the current controls from the specified dom element.
  35979. * @param element Defines the element to stop listening the inputs from
  35980. */
  35981. detachControl(element: Nullable<HTMLElement>): void;
  35982. /**
  35983. * Update the current camera state depending on the inputs that have been used this frame.
  35984. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35985. */
  35986. checkInputs(): void;
  35987. /**
  35988. * Gets the class name of the current intput.
  35989. * @returns the class name
  35990. */
  35991. getClassName(): string;
  35992. /**
  35993. * Get the friendly name associated with the input class.
  35994. * @returns the input friendly name
  35995. */
  35996. getSimpleName(): string;
  35997. }
  35998. }
  35999. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36000. import { Nullable } from "babylonjs/types";
  36001. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36002. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36003. /**
  36004. * Manage the mouse wheel inputs to control an arc rotate camera.
  36005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36006. */
  36007. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36008. /**
  36009. * Defines the camera the input is attached to.
  36010. */
  36011. camera: ArcRotateCamera;
  36012. /**
  36013. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36014. */
  36015. wheelPrecision: number;
  36016. /**
  36017. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36018. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36019. */
  36020. wheelDeltaPercentage: number;
  36021. private _wheel;
  36022. private _observer;
  36023. private computeDeltaFromMouseWheelLegacyEvent;
  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. export * from "babylonjs/Collisions/meshCollisionData";
  41726. }
  41727. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41728. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41729. import { Vector3, Plane } from "babylonjs/Maths/math";
  41730. import { Ray } from "babylonjs/Culling/ray";
  41731. /**
  41732. * Contains an array of blocks representing the octree
  41733. */
  41734. export interface IOctreeContainer<T> {
  41735. /**
  41736. * Blocks within the octree
  41737. */
  41738. blocks: Array<OctreeBlock<T>>;
  41739. }
  41740. /**
  41741. * Class used to store a cell in an octree
  41742. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41743. */
  41744. export class OctreeBlock<T> {
  41745. /**
  41746. * Gets the content of the current block
  41747. */
  41748. entries: T[];
  41749. /**
  41750. * Gets the list of block children
  41751. */
  41752. blocks: Array<OctreeBlock<T>>;
  41753. private _depth;
  41754. private _maxDepth;
  41755. private _capacity;
  41756. private _minPoint;
  41757. private _maxPoint;
  41758. private _boundingVectors;
  41759. private _creationFunc;
  41760. /**
  41761. * Creates a new block
  41762. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41763. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41764. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41765. * @param depth defines the current depth of this block in the octree
  41766. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41767. * @param creationFunc defines a callback to call when an element is added to the block
  41768. */
  41769. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41770. /**
  41771. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41772. */
  41773. readonly capacity: number;
  41774. /**
  41775. * Gets the minimum vector (in world space) of the block's bounding box
  41776. */
  41777. readonly minPoint: Vector3;
  41778. /**
  41779. * Gets the maximum vector (in world space) of the block's bounding box
  41780. */
  41781. readonly maxPoint: Vector3;
  41782. /**
  41783. * Add a new element to this block
  41784. * @param entry defines the element to add
  41785. */
  41786. addEntry(entry: T): void;
  41787. /**
  41788. * Remove an element from this block
  41789. * @param entry defines the element to remove
  41790. */
  41791. removeEntry(entry: T): void;
  41792. /**
  41793. * Add an array of elements to this block
  41794. * @param entries defines the array of elements to add
  41795. */
  41796. addEntries(entries: T[]): void;
  41797. /**
  41798. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41799. * @param frustumPlanes defines the frustum planes to test
  41800. * @param selection defines the array to store current content if selection is positive
  41801. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41802. */
  41803. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41804. /**
  41805. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41806. * @param sphereCenter defines the bounding sphere center
  41807. * @param sphereRadius defines the bounding sphere radius
  41808. * @param selection defines the array to store current content if selection is positive
  41809. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41810. */
  41811. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41812. /**
  41813. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41814. * @param ray defines the ray to test with
  41815. * @param selection defines the array to store current content if selection is positive
  41816. */
  41817. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41818. /**
  41819. * Subdivide the content into child blocks (this block will then be empty)
  41820. */
  41821. createInnerBlocks(): void;
  41822. /**
  41823. * @hidden
  41824. */
  41825. 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;
  41826. }
  41827. }
  41828. declare module "babylonjs/Culling/Octrees/octree" {
  41829. import { SmartArray } from "babylonjs/Misc/smartArray";
  41830. import { Vector3, Plane } from "babylonjs/Maths/math";
  41831. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41833. import { Ray } from "babylonjs/Culling/ray";
  41834. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41835. /**
  41836. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41837. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41838. */
  41839. export class Octree<T> {
  41840. /** 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.) */
  41841. maxDepth: number;
  41842. /**
  41843. * Blocks within the octree containing objects
  41844. */
  41845. blocks: Array<OctreeBlock<T>>;
  41846. /**
  41847. * Content stored in the octree
  41848. */
  41849. dynamicContent: T[];
  41850. private _maxBlockCapacity;
  41851. private _selectionContent;
  41852. private _creationFunc;
  41853. /**
  41854. * Creates a octree
  41855. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41856. * @param creationFunc function to be used to instatiate the octree
  41857. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41858. * @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.)
  41859. */
  41860. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41861. /** 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.) */
  41862. maxDepth?: number);
  41863. /**
  41864. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41865. * @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);
  41866. * @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);
  41867. * @param entries meshes to be added to the octree blocks
  41868. */
  41869. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41870. /**
  41871. * Adds a mesh to the octree
  41872. * @param entry Mesh to add to the octree
  41873. */
  41874. addMesh(entry: T): void;
  41875. /**
  41876. * Remove an element from the octree
  41877. * @param entry defines the element to remove
  41878. */
  41879. removeMesh(entry: T): void;
  41880. /**
  41881. * Selects an array of meshes within the frustum
  41882. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41883. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41884. * @returns array of meshes within the frustum
  41885. */
  41886. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41887. /**
  41888. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41889. * @param sphereCenter defines the bounding sphere center
  41890. * @param sphereRadius defines the bounding sphere radius
  41891. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41892. * @returns an array of objects that intersect the sphere
  41893. */
  41894. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41895. /**
  41896. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41897. * @param ray defines the ray to test with
  41898. * @returns array of intersected objects
  41899. */
  41900. intersectsRay(ray: Ray): SmartArray<T>;
  41901. /**
  41902. * Adds a mesh into the octree block if it intersects the block
  41903. */
  41904. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41905. /**
  41906. * Adds a submesh into the octree block if it intersects the block
  41907. */
  41908. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41909. }
  41910. }
  41911. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41912. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41913. import { Scene } from "babylonjs/scene";
  41914. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41916. import { Ray } from "babylonjs/Culling/ray";
  41917. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41918. import { Collider } from "babylonjs/Collisions/collider";
  41919. module "babylonjs/scene" {
  41920. interface Scene {
  41921. /**
  41922. * @hidden
  41923. * Backing Filed
  41924. */
  41925. _selectionOctree: Octree<AbstractMesh>;
  41926. /**
  41927. * Gets the octree used to boost mesh selection (picking)
  41928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41929. */
  41930. selectionOctree: Octree<AbstractMesh>;
  41931. /**
  41932. * Creates or updates the octree used to boost selection (picking)
  41933. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41934. * @param maxCapacity defines the maximum capacity per leaf
  41935. * @param maxDepth defines the maximum depth of the octree
  41936. * @returns an octree of AbstractMesh
  41937. */
  41938. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41939. }
  41940. }
  41941. module "babylonjs/Meshes/abstractMesh" {
  41942. interface AbstractMesh {
  41943. /**
  41944. * @hidden
  41945. * Backing Field
  41946. */
  41947. _submeshesOctree: Octree<SubMesh>;
  41948. /**
  41949. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41950. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41951. * @param maxCapacity defines the maximum size of each block (64 by default)
  41952. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41953. * @returns the new octree
  41954. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41955. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41956. */
  41957. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41958. }
  41959. }
  41960. /**
  41961. * Defines the octree scene component responsible to manage any octrees
  41962. * in a given scene.
  41963. */
  41964. export class OctreeSceneComponent {
  41965. /**
  41966. * The component name help to identify the component in the list of scene components.
  41967. */
  41968. readonly name: string;
  41969. /**
  41970. * The scene the component belongs to.
  41971. */
  41972. scene: Scene;
  41973. /**
  41974. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41975. */
  41976. readonly checksIsEnabled: boolean;
  41977. /**
  41978. * Creates a new instance of the component for the given scene
  41979. * @param scene Defines the scene to register the component in
  41980. */
  41981. constructor(scene: Scene);
  41982. /**
  41983. * Registers the component in a given scene
  41984. */
  41985. register(): void;
  41986. /**
  41987. * Return the list of active meshes
  41988. * @returns the list of active meshes
  41989. */
  41990. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41991. /**
  41992. * Return the list of active sub meshes
  41993. * @param mesh The mesh to get the candidates sub meshes from
  41994. * @returns the list of active sub meshes
  41995. */
  41996. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41997. private _tempRay;
  41998. /**
  41999. * Return the list of sub meshes intersecting with a given local ray
  42000. * @param mesh defines the mesh to find the submesh for
  42001. * @param localRay defines the ray in local space
  42002. * @returns the list of intersecting sub meshes
  42003. */
  42004. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42005. /**
  42006. * Return the list of sub meshes colliding with a collider
  42007. * @param mesh defines the mesh to find the submesh for
  42008. * @param collider defines the collider to evaluate the collision against
  42009. * @returns the list of colliding sub meshes
  42010. */
  42011. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42012. /**
  42013. * Rebuilds the elements related to this component in case of
  42014. * context lost for instance.
  42015. */
  42016. rebuild(): void;
  42017. /**
  42018. * Disposes the component and the associated ressources.
  42019. */
  42020. dispose(): void;
  42021. }
  42022. }
  42023. declare module "babylonjs/Culling/Octrees/index" {
  42024. export * from "babylonjs/Culling/Octrees/octree";
  42025. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42026. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42027. }
  42028. declare module "babylonjs/Culling/index" {
  42029. export * from "babylonjs/Culling/boundingBox";
  42030. export * from "babylonjs/Culling/boundingInfo";
  42031. export * from "babylonjs/Culling/boundingSphere";
  42032. export * from "babylonjs/Culling/Octrees/index";
  42033. export * from "babylonjs/Culling/ray";
  42034. }
  42035. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42036. import { IDisposable, Scene } from "babylonjs/scene";
  42037. import { Nullable } from "babylonjs/types";
  42038. import { Observable } from "babylonjs/Misc/observable";
  42039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42040. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42041. /**
  42042. * Renders a layer on top of an existing scene
  42043. */
  42044. export class UtilityLayerRenderer implements IDisposable {
  42045. /** the original scene that will be rendered on top of */
  42046. originalScene: Scene;
  42047. private _pointerCaptures;
  42048. private _lastPointerEvents;
  42049. private static _DefaultUtilityLayer;
  42050. private static _DefaultKeepDepthUtilityLayer;
  42051. private _sharedGizmoLight;
  42052. /**
  42053. * @hidden
  42054. * Light which used by gizmos to get light shading
  42055. */
  42056. _getSharedGizmoLight(): HemisphericLight;
  42057. /**
  42058. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42059. */
  42060. pickUtilitySceneFirst: boolean;
  42061. /**
  42062. * 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)
  42063. */
  42064. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42065. /**
  42066. * 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)
  42067. */
  42068. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42069. /**
  42070. * The scene that is rendered on top of the original scene
  42071. */
  42072. utilityLayerScene: Scene;
  42073. /**
  42074. * If the utility layer should automatically be rendered on top of existing scene
  42075. */
  42076. shouldRender: boolean;
  42077. /**
  42078. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42079. */
  42080. onlyCheckPointerDownEvents: boolean;
  42081. /**
  42082. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42083. */
  42084. processAllEvents: boolean;
  42085. /**
  42086. * Observable raised when the pointer move from the utility layer scene to the main scene
  42087. */
  42088. onPointerOutObservable: Observable<number>;
  42089. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42090. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42091. private _afterRenderObserver;
  42092. private _sceneDisposeObserver;
  42093. private _originalPointerObserver;
  42094. /**
  42095. * Instantiates a UtilityLayerRenderer
  42096. * @param originalScene the original scene that will be rendered on top of
  42097. * @param handleEvents boolean indicating if the utility layer should handle events
  42098. */
  42099. constructor(
  42100. /** the original scene that will be rendered on top of */
  42101. originalScene: Scene, handleEvents?: boolean);
  42102. private _notifyObservers;
  42103. /**
  42104. * Renders the utility layers scene on top of the original scene
  42105. */
  42106. render(): void;
  42107. /**
  42108. * Disposes of the renderer
  42109. */
  42110. dispose(): void;
  42111. private _updateCamera;
  42112. }
  42113. }
  42114. declare module "babylonjs/Gizmos/gizmo" {
  42115. import { Nullable } from "babylonjs/types";
  42116. import { IDisposable } from "babylonjs/scene";
  42117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42118. import { Mesh } from "babylonjs/Meshes/mesh";
  42119. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42120. /**
  42121. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42122. */
  42123. export class Gizmo implements IDisposable {
  42124. /** The utility layer the gizmo will be added to */
  42125. gizmoLayer: UtilityLayerRenderer;
  42126. /**
  42127. * The root mesh of the gizmo
  42128. */
  42129. _rootMesh: Mesh;
  42130. private _attachedMesh;
  42131. /**
  42132. * Ratio for the scale of the gizmo (Default: 1)
  42133. */
  42134. scaleRatio: number;
  42135. /**
  42136. * If a custom mesh has been set (Default: false)
  42137. */
  42138. protected _customMeshSet: boolean;
  42139. /**
  42140. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42141. * * When set, interactions will be enabled
  42142. */
  42143. attachedMesh: Nullable<AbstractMesh>;
  42144. /**
  42145. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42146. * @param mesh The mesh to replace the default mesh of the gizmo
  42147. */
  42148. setCustomMesh(mesh: Mesh): void;
  42149. /**
  42150. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42151. */
  42152. updateGizmoRotationToMatchAttachedMesh: boolean;
  42153. /**
  42154. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42155. */
  42156. updateGizmoPositionToMatchAttachedMesh: boolean;
  42157. /**
  42158. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42159. */
  42160. protected _updateScale: boolean;
  42161. protected _interactionsEnabled: boolean;
  42162. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42163. private _beforeRenderObserver;
  42164. private _tempVector;
  42165. /**
  42166. * Creates a gizmo
  42167. * @param gizmoLayer The utility layer the gizmo will be added to
  42168. */
  42169. constructor(
  42170. /** The utility layer the gizmo will be added to */
  42171. gizmoLayer?: UtilityLayerRenderer);
  42172. /**
  42173. * Updates the gizmo to match the attached mesh's position/rotation
  42174. */
  42175. protected _update(): void;
  42176. /**
  42177. * Disposes of the gizmo
  42178. */
  42179. dispose(): void;
  42180. }
  42181. }
  42182. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42183. import { Observable } from "babylonjs/Misc/observable";
  42184. import { Nullable } from "babylonjs/types";
  42185. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42186. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42188. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42189. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42190. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42191. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42192. import { Scene } from "babylonjs/scene";
  42193. /**
  42194. * Single axis drag gizmo
  42195. */
  42196. export class AxisDragGizmo extends Gizmo {
  42197. /**
  42198. * Drag behavior responsible for the gizmos dragging interactions
  42199. */
  42200. dragBehavior: PointerDragBehavior;
  42201. private _pointerObserver;
  42202. /**
  42203. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42204. */
  42205. snapDistance: number;
  42206. /**
  42207. * Event that fires each time the gizmo snaps to a new location.
  42208. * * snapDistance is the the change in distance
  42209. */
  42210. onSnapObservable: Observable<{
  42211. snapDistance: number;
  42212. }>;
  42213. /** @hidden */
  42214. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42215. /** @hidden */
  42216. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42217. /**
  42218. * Creates an AxisDragGizmo
  42219. * @param gizmoLayer The utility layer the gizmo will be added to
  42220. * @param dragAxis The axis which the gizmo will be able to drag on
  42221. * @param color The color of the gizmo
  42222. */
  42223. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42224. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42225. /**
  42226. * Disposes of the gizmo
  42227. */
  42228. dispose(): void;
  42229. }
  42230. }
  42231. declare module "babylonjs/Debug/axesViewer" {
  42232. import { Vector3 } from "babylonjs/Maths/math";
  42233. import { Nullable } from "babylonjs/types";
  42234. import { Scene } from "babylonjs/scene";
  42235. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42236. /**
  42237. * The Axes viewer will show 3 axes in a specific point in space
  42238. */
  42239. export class AxesViewer {
  42240. private _xAxis;
  42241. private _yAxis;
  42242. private _zAxis;
  42243. private _scaleLinesFactor;
  42244. private _instanced;
  42245. /**
  42246. * Gets the hosting scene
  42247. */
  42248. scene: Scene;
  42249. /**
  42250. * Gets or sets a number used to scale line length
  42251. */
  42252. scaleLines: number;
  42253. /** Gets the node hierarchy used to render x-axis */
  42254. readonly xAxis: TransformNode;
  42255. /** Gets the node hierarchy used to render y-axis */
  42256. readonly yAxis: TransformNode;
  42257. /** Gets the node hierarchy used to render z-axis */
  42258. readonly zAxis: TransformNode;
  42259. /**
  42260. * Creates a new AxesViewer
  42261. * @param scene defines the hosting scene
  42262. * @param scaleLines defines a number used to scale line length (1 by default)
  42263. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42264. * @param xAxis defines the node hierarchy used to render the x-axis
  42265. * @param yAxis defines the node hierarchy used to render the y-axis
  42266. * @param zAxis defines the node hierarchy used to render the z-axis
  42267. */
  42268. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42269. /**
  42270. * Force the viewer to update
  42271. * @param position defines the position of the viewer
  42272. * @param xaxis defines the x axis of the viewer
  42273. * @param yaxis defines the y axis of the viewer
  42274. * @param zaxis defines the z axis of the viewer
  42275. */
  42276. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42277. /**
  42278. * Creates an instance of this axes viewer.
  42279. * @returns a new axes viewer with instanced meshes
  42280. */
  42281. createInstance(): AxesViewer;
  42282. /** Releases resources */
  42283. dispose(): void;
  42284. private static _SetRenderingGroupId;
  42285. }
  42286. }
  42287. declare module "babylonjs/Debug/boneAxesViewer" {
  42288. import { Nullable } from "babylonjs/types";
  42289. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42290. import { Vector3 } from "babylonjs/Maths/math";
  42291. import { Mesh } from "babylonjs/Meshes/mesh";
  42292. import { Bone } from "babylonjs/Bones/bone";
  42293. import { Scene } from "babylonjs/scene";
  42294. /**
  42295. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42296. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42297. */
  42298. export class BoneAxesViewer extends AxesViewer {
  42299. /**
  42300. * Gets or sets the target mesh where to display the axes viewer
  42301. */
  42302. mesh: Nullable<Mesh>;
  42303. /**
  42304. * Gets or sets the target bone where to display the axes viewer
  42305. */
  42306. bone: Nullable<Bone>;
  42307. /** Gets current position */
  42308. pos: Vector3;
  42309. /** Gets direction of X axis */
  42310. xaxis: Vector3;
  42311. /** Gets direction of Y axis */
  42312. yaxis: Vector3;
  42313. /** Gets direction of Z axis */
  42314. zaxis: Vector3;
  42315. /**
  42316. * Creates a new BoneAxesViewer
  42317. * @param scene defines the hosting scene
  42318. * @param bone defines the target bone
  42319. * @param mesh defines the target mesh
  42320. * @param scaleLines defines a scaling factor for line length (1 by default)
  42321. */
  42322. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42323. /**
  42324. * Force the viewer to update
  42325. */
  42326. update(): void;
  42327. /** Releases resources */
  42328. dispose(): void;
  42329. }
  42330. }
  42331. declare module "babylonjs/Debug/debugLayer" {
  42332. import { Observable } from "babylonjs/Misc/observable";
  42333. import { Scene } from "babylonjs/scene";
  42334. /**
  42335. * Interface used to define scene explorer extensibility option
  42336. */
  42337. export interface IExplorerExtensibilityOption {
  42338. /**
  42339. * Define the option label
  42340. */
  42341. label: string;
  42342. /**
  42343. * Defines the action to execute on click
  42344. */
  42345. action: (entity: any) => void;
  42346. }
  42347. /**
  42348. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42349. */
  42350. export interface IExplorerExtensibilityGroup {
  42351. /**
  42352. * Defines a predicate to test if a given type mut be extended
  42353. */
  42354. predicate: (entity: any) => boolean;
  42355. /**
  42356. * Gets the list of options added to a type
  42357. */
  42358. entries: IExplorerExtensibilityOption[];
  42359. }
  42360. /**
  42361. * Interface used to define the options to use to create the Inspector
  42362. */
  42363. export interface IInspectorOptions {
  42364. /**
  42365. * Display in overlay mode (default: false)
  42366. */
  42367. overlay?: boolean;
  42368. /**
  42369. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42370. */
  42371. globalRoot?: HTMLElement;
  42372. /**
  42373. * Display the Scene explorer
  42374. */
  42375. showExplorer?: boolean;
  42376. /**
  42377. * Display the property inspector
  42378. */
  42379. showInspector?: boolean;
  42380. /**
  42381. * Display in embed mode (both panes on the right)
  42382. */
  42383. embedMode?: boolean;
  42384. /**
  42385. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42386. */
  42387. handleResize?: boolean;
  42388. /**
  42389. * Allow the panes to popup (default: true)
  42390. */
  42391. enablePopup?: boolean;
  42392. /**
  42393. * Allow the panes to be closed by users (default: true)
  42394. */
  42395. enableClose?: boolean;
  42396. /**
  42397. * Optional list of extensibility entries
  42398. */
  42399. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42400. /**
  42401. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42402. */
  42403. inspectorURL?: string;
  42404. }
  42405. module "babylonjs/scene" {
  42406. interface Scene {
  42407. /**
  42408. * @hidden
  42409. * Backing field
  42410. */
  42411. _debugLayer: DebugLayer;
  42412. /**
  42413. * Gets the debug layer (aka Inspector) associated with the scene
  42414. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42415. */
  42416. debugLayer: DebugLayer;
  42417. }
  42418. }
  42419. /**
  42420. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42421. * what is happening in your scene
  42422. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42423. */
  42424. export class DebugLayer {
  42425. /**
  42426. * Define the url to get the inspector script from.
  42427. * By default it uses the babylonjs CDN.
  42428. * @ignoreNaming
  42429. */
  42430. static InspectorURL: string;
  42431. private _scene;
  42432. private BJSINSPECTOR;
  42433. /**
  42434. * Observable triggered when a property is changed through the inspector.
  42435. */
  42436. onPropertyChangedObservable: Observable<{
  42437. object: any;
  42438. property: string;
  42439. value: any;
  42440. initialValue: any;
  42441. }>;
  42442. /**
  42443. * Instantiates a new debug layer.
  42444. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42445. * what is happening in your scene
  42446. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42447. * @param scene Defines the scene to inspect
  42448. */
  42449. constructor(scene: Scene);
  42450. /** Creates the inspector window. */
  42451. private _createInspector;
  42452. /**
  42453. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42454. * @param entity defines the entity to select
  42455. * @param lineContainerTitle defines the specific block to highlight
  42456. */
  42457. select(entity: any, lineContainerTitle?: string): void;
  42458. /** Get the inspector from bundle or global */
  42459. private _getGlobalInspector;
  42460. /**
  42461. * Get if the inspector is visible or not.
  42462. * @returns true if visible otherwise, false
  42463. */
  42464. isVisible(): boolean;
  42465. /**
  42466. * Hide the inspector and close its window.
  42467. */
  42468. hide(): void;
  42469. /**
  42470. * Launch the debugLayer.
  42471. * @param config Define the configuration of the inspector
  42472. * @return a promise fulfilled when the debug layer is visible
  42473. */
  42474. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42475. }
  42476. }
  42477. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42478. import { Nullable } from "babylonjs/types";
  42479. import { Scene } from "babylonjs/scene";
  42480. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42481. import { Mesh } from "babylonjs/Meshes/mesh";
  42482. /**
  42483. * Class containing static functions to help procedurally build meshes
  42484. */
  42485. export class BoxBuilder {
  42486. /**
  42487. * Creates a box mesh
  42488. * * The parameter `size` sets the size (float) of each box side (default 1)
  42489. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42490. * * 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)
  42491. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42495. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42496. * @param name defines the name of the mesh
  42497. * @param options defines the options used to create the mesh
  42498. * @param scene defines the hosting scene
  42499. * @returns the box mesh
  42500. */
  42501. static CreateBox(name: string, options: {
  42502. size?: number;
  42503. width?: number;
  42504. height?: number;
  42505. depth?: number;
  42506. faceUV?: Vector4[];
  42507. faceColors?: Color4[];
  42508. sideOrientation?: number;
  42509. frontUVs?: Vector4;
  42510. backUVs?: Vector4;
  42511. wrap?: boolean;
  42512. topBaseAt?: number;
  42513. bottomBaseAt?: number;
  42514. updatable?: boolean;
  42515. }, scene?: Nullable<Scene>): Mesh;
  42516. }
  42517. }
  42518. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42519. import { Vector4 } from "babylonjs/Maths/math";
  42520. import { Mesh } from "babylonjs/Meshes/mesh";
  42521. /**
  42522. * Class containing static functions to help procedurally build meshes
  42523. */
  42524. export class SphereBuilder {
  42525. /**
  42526. * Creates a sphere mesh
  42527. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42528. * * 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`)
  42529. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42530. * * 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
  42531. * * 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)
  42532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42535. * @param name defines the name of the mesh
  42536. * @param options defines the options used to create the mesh
  42537. * @param scene defines the hosting scene
  42538. * @returns the sphere mesh
  42539. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42540. */
  42541. static CreateSphere(name: string, options: {
  42542. segments?: number;
  42543. diameter?: number;
  42544. diameterX?: number;
  42545. diameterY?: number;
  42546. diameterZ?: number;
  42547. arc?: number;
  42548. slice?: number;
  42549. sideOrientation?: number;
  42550. frontUVs?: Vector4;
  42551. backUVs?: Vector4;
  42552. updatable?: boolean;
  42553. }, scene: any): Mesh;
  42554. }
  42555. }
  42556. declare module "babylonjs/Debug/physicsViewer" {
  42557. import { Nullable } from "babylonjs/types";
  42558. import { Scene } from "babylonjs/scene";
  42559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42560. import { Mesh } from "babylonjs/Meshes/mesh";
  42561. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42562. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42563. /**
  42564. * Used to show the physics impostor around the specific mesh
  42565. */
  42566. export class PhysicsViewer {
  42567. /** @hidden */
  42568. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42569. /** @hidden */
  42570. protected _meshes: Array<Nullable<AbstractMesh>>;
  42571. /** @hidden */
  42572. protected _scene: Nullable<Scene>;
  42573. /** @hidden */
  42574. protected _numMeshes: number;
  42575. /** @hidden */
  42576. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42577. private _renderFunction;
  42578. private _utilityLayer;
  42579. private _debugBoxMesh;
  42580. private _debugSphereMesh;
  42581. private _debugCylinderMesh;
  42582. private _debugMaterial;
  42583. private _debugMeshMeshes;
  42584. /**
  42585. * Creates a new PhysicsViewer
  42586. * @param scene defines the hosting scene
  42587. */
  42588. constructor(scene: Scene);
  42589. /** @hidden */
  42590. protected _updateDebugMeshes(): void;
  42591. /**
  42592. * Renders a specified physic impostor
  42593. * @param impostor defines the impostor to render
  42594. * @param targetMesh defines the mesh represented by the impostor
  42595. * @returns the new debug mesh used to render the impostor
  42596. */
  42597. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42598. /**
  42599. * Hides a specified physic impostor
  42600. * @param impostor defines the impostor to hide
  42601. */
  42602. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42603. private _getDebugMaterial;
  42604. private _getDebugBoxMesh;
  42605. private _getDebugSphereMesh;
  42606. private _getDebugCylinderMesh;
  42607. private _getDebugMeshMesh;
  42608. private _getDebugMesh;
  42609. /** Releases all resources */
  42610. dispose(): void;
  42611. }
  42612. }
  42613. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42614. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42615. import { Nullable } from "babylonjs/types";
  42616. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42617. import { Scene } from "babylonjs/scene";
  42618. /**
  42619. * Class containing static functions to help procedurally build meshes
  42620. */
  42621. export class LinesBuilder {
  42622. /**
  42623. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42624. * * 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
  42625. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42626. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42627. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42628. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42629. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42630. * * 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
  42631. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42633. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42634. * @param name defines the name of the new line system
  42635. * @param options defines the options used to create the line system
  42636. * @param scene defines the hosting scene
  42637. * @returns a new line system mesh
  42638. */
  42639. static CreateLineSystem(name: string, options: {
  42640. lines: Vector3[][];
  42641. updatable?: boolean;
  42642. instance?: Nullable<LinesMesh>;
  42643. colors?: Nullable<Color4[][]>;
  42644. useVertexAlpha?: boolean;
  42645. }, scene: Nullable<Scene>): LinesMesh;
  42646. /**
  42647. * Creates a line mesh
  42648. * 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
  42649. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42650. * * The parameter `points` is an array successive Vector3
  42651. * * 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
  42652. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42653. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42654. * * When updating an instance, remember that only point positions can change, not the number of points
  42655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42657. * @param name defines the name of the new line system
  42658. * @param options defines the options used to create the line system
  42659. * @param scene defines the hosting scene
  42660. * @returns a new line mesh
  42661. */
  42662. static CreateLines(name: string, options: {
  42663. points: Vector3[];
  42664. updatable?: boolean;
  42665. instance?: Nullable<LinesMesh>;
  42666. colors?: Color4[];
  42667. useVertexAlpha?: boolean;
  42668. }, scene?: Nullable<Scene>): LinesMesh;
  42669. /**
  42670. * Creates a dashed line mesh
  42671. * * 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
  42672. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42673. * * The parameter `points` is an array successive Vector3
  42674. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42675. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42676. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42677. * * 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
  42678. * * When updating an instance, remember that only point positions can change, not the number of points
  42679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42680. * @param name defines the name of the mesh
  42681. * @param options defines the options used to create the mesh
  42682. * @param scene defines the hosting scene
  42683. * @returns the dashed line mesh
  42684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42685. */
  42686. static CreateDashedLines(name: string, options: {
  42687. points: Vector3[];
  42688. dashSize?: number;
  42689. gapSize?: number;
  42690. dashNb?: number;
  42691. updatable?: boolean;
  42692. instance?: LinesMesh;
  42693. }, scene?: Nullable<Scene>): LinesMesh;
  42694. }
  42695. }
  42696. declare module "babylonjs/Debug/rayHelper" {
  42697. import { Nullable } from "babylonjs/types";
  42698. import { Ray } from "babylonjs/Culling/ray";
  42699. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42700. import { Scene } from "babylonjs/scene";
  42701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42702. import "babylonjs/Meshes/Builders/linesBuilder";
  42703. /**
  42704. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42705. * in order to better appreciate the issue one might have.
  42706. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42707. */
  42708. export class RayHelper {
  42709. /**
  42710. * Defines the ray we are currently tryin to visualize.
  42711. */
  42712. ray: Nullable<Ray>;
  42713. private _renderPoints;
  42714. private _renderLine;
  42715. private _renderFunction;
  42716. private _scene;
  42717. private _updateToMeshFunction;
  42718. private _attachedToMesh;
  42719. private _meshSpaceDirection;
  42720. private _meshSpaceOrigin;
  42721. /**
  42722. * Helper function to create a colored helper in a scene in one line.
  42723. * @param ray Defines the ray we are currently tryin to visualize
  42724. * @param scene Defines the scene the ray is used in
  42725. * @param color Defines the color we want to see the ray in
  42726. * @returns The newly created ray helper.
  42727. */
  42728. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42729. /**
  42730. * Instantiate a new ray helper.
  42731. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42732. * in order to better appreciate the issue one might have.
  42733. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42734. * @param ray Defines the ray we are currently tryin to visualize
  42735. */
  42736. constructor(ray: Ray);
  42737. /**
  42738. * Shows the ray we are willing to debug.
  42739. * @param scene Defines the scene the ray needs to be rendered in
  42740. * @param color Defines the color the ray needs to be rendered in
  42741. */
  42742. show(scene: Scene, color?: Color3): void;
  42743. /**
  42744. * Hides the ray we are debugging.
  42745. */
  42746. hide(): void;
  42747. private _render;
  42748. /**
  42749. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42750. * @param mesh Defines the mesh we want the helper attached to
  42751. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42752. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42753. * @param length Defines the length of the ray
  42754. */
  42755. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42756. /**
  42757. * Detach the ray helper from the mesh it has previously been attached to.
  42758. */
  42759. detachFromMesh(): void;
  42760. private _updateToMesh;
  42761. /**
  42762. * Dispose the helper and release its associated resources.
  42763. */
  42764. dispose(): void;
  42765. }
  42766. }
  42767. declare module "babylonjs/Debug/skeletonViewer" {
  42768. import { Color3 } from "babylonjs/Maths/math";
  42769. import { Scene } from "babylonjs/scene";
  42770. import { Nullable } from "babylonjs/types";
  42771. import { Skeleton } from "babylonjs/Bones/skeleton";
  42772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42773. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42774. /**
  42775. * Class used to render a debug view of a given skeleton
  42776. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42777. */
  42778. export class SkeletonViewer {
  42779. /** defines the skeleton to render */
  42780. skeleton: Skeleton;
  42781. /** defines the mesh attached to the skeleton */
  42782. mesh: AbstractMesh;
  42783. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42784. autoUpdateBonesMatrices: boolean;
  42785. /** defines the rendering group id to use with the viewer */
  42786. renderingGroupId: number;
  42787. /** Gets or sets the color used to render the skeleton */
  42788. color: Color3;
  42789. private _scene;
  42790. private _debugLines;
  42791. private _debugMesh;
  42792. private _isEnabled;
  42793. private _renderFunction;
  42794. private _utilityLayer;
  42795. /**
  42796. * Returns the mesh used to render the bones
  42797. */
  42798. readonly debugMesh: Nullable<LinesMesh>;
  42799. /**
  42800. * Creates a new SkeletonViewer
  42801. * @param skeleton defines the skeleton to render
  42802. * @param mesh defines the mesh attached to the skeleton
  42803. * @param scene defines the hosting scene
  42804. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42805. * @param renderingGroupId defines the rendering group id to use with the viewer
  42806. */
  42807. constructor(
  42808. /** defines the skeleton to render */
  42809. skeleton: Skeleton,
  42810. /** defines the mesh attached to the skeleton */
  42811. mesh: AbstractMesh, scene: Scene,
  42812. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42813. autoUpdateBonesMatrices?: boolean,
  42814. /** defines the rendering group id to use with the viewer */
  42815. renderingGroupId?: number);
  42816. /** Gets or sets a boolean indicating if the viewer is enabled */
  42817. isEnabled: boolean;
  42818. private _getBonePosition;
  42819. private _getLinesForBonesWithLength;
  42820. private _getLinesForBonesNoLength;
  42821. /** Update the viewer to sync with current skeleton state */
  42822. update(): void;
  42823. /** Release associated resources */
  42824. dispose(): void;
  42825. }
  42826. }
  42827. declare module "babylonjs/Debug/index" {
  42828. export * from "babylonjs/Debug/axesViewer";
  42829. export * from "babylonjs/Debug/boneAxesViewer";
  42830. export * from "babylonjs/Debug/debugLayer";
  42831. export * from "babylonjs/Debug/physicsViewer";
  42832. export * from "babylonjs/Debug/rayHelper";
  42833. export * from "babylonjs/Debug/skeletonViewer";
  42834. }
  42835. declare module "babylonjs/Engines/nullEngine" {
  42836. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42837. import { Scene } from "babylonjs/scene";
  42838. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42839. import { Engine } from "babylonjs/Engines/engine";
  42840. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42841. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42843. import { Effect } from "babylonjs/Materials/effect";
  42844. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42845. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42846. /**
  42847. * Options to create the null engine
  42848. */
  42849. export class NullEngineOptions {
  42850. /**
  42851. * Render width (Default: 512)
  42852. */
  42853. renderWidth: number;
  42854. /**
  42855. * Render height (Default: 256)
  42856. */
  42857. renderHeight: number;
  42858. /**
  42859. * Texture size (Default: 512)
  42860. */
  42861. textureSize: number;
  42862. /**
  42863. * If delta time between frames should be constant
  42864. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42865. */
  42866. deterministicLockstep: boolean;
  42867. /**
  42868. * Maximum about of steps between frames (Default: 4)
  42869. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42870. */
  42871. lockstepMaxSteps: number;
  42872. }
  42873. /**
  42874. * The null engine class provides support for headless version of babylon.js.
  42875. * This can be used in server side scenario or for testing purposes
  42876. */
  42877. export class NullEngine extends Engine {
  42878. private _options;
  42879. /**
  42880. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42881. */
  42882. isDeterministicLockStep(): boolean;
  42883. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42884. getLockstepMaxSteps(): number;
  42885. /**
  42886. * Sets hardware scaling, used to save performance if needed
  42887. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42888. */
  42889. getHardwareScalingLevel(): number;
  42890. constructor(options?: NullEngineOptions);
  42891. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42892. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42893. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42894. getRenderWidth(useScreen?: boolean): number;
  42895. getRenderHeight(useScreen?: boolean): number;
  42896. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42897. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42898. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42899. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42900. bindSamplers(effect: Effect): void;
  42901. enableEffect(effect: Effect): void;
  42902. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42903. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42904. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42905. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42906. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42907. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42908. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42909. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42910. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42911. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42912. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42913. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42914. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42915. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42916. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42917. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42918. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42919. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42920. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42921. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42922. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42923. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42924. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42925. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42926. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42927. bindBuffers(vertexBuffers: {
  42928. [key: string]: VertexBuffer;
  42929. }, indexBuffer: DataBuffer, effect: Effect): void;
  42930. wipeCaches(bruteForce?: boolean): void;
  42931. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42932. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42933. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42934. /** @hidden */
  42935. _createTexture(): WebGLTexture;
  42936. /** @hidden */
  42937. _releaseTexture(texture: InternalTexture): void;
  42938. 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;
  42939. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42940. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42941. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42942. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42943. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42944. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42945. areAllEffectsReady(): boolean;
  42946. /**
  42947. * @hidden
  42948. * Get the current error code of the webGL context
  42949. * @returns the error code
  42950. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42951. */
  42952. getError(): number;
  42953. /** @hidden */
  42954. _getUnpackAlignement(): number;
  42955. /** @hidden */
  42956. _unpackFlipY(value: boolean): void;
  42957. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42958. /**
  42959. * Updates a dynamic vertex buffer.
  42960. * @param vertexBuffer the vertex buffer to update
  42961. * @param data the data used to update the vertex buffer
  42962. * @param byteOffset the byte offset of the data (optional)
  42963. * @param byteLength the byte length of the data (optional)
  42964. */
  42965. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42966. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42967. /** @hidden */
  42968. _bindTexture(channel: number, texture: InternalTexture): void;
  42969. /** @hidden */
  42970. _releaseBuffer(buffer: DataBuffer): boolean;
  42971. releaseEffects(): void;
  42972. displayLoadingUI(): void;
  42973. hideLoadingUI(): void;
  42974. /** @hidden */
  42975. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42976. /** @hidden */
  42977. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42978. /** @hidden */
  42979. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42980. /** @hidden */
  42981. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42982. }
  42983. }
  42984. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42985. import { Nullable, int } from "babylonjs/types";
  42986. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42987. /** @hidden */
  42988. export class _OcclusionDataStorage {
  42989. /** @hidden */
  42990. occlusionInternalRetryCounter: number;
  42991. /** @hidden */
  42992. isOcclusionQueryInProgress: boolean;
  42993. /** @hidden */
  42994. isOccluded: boolean;
  42995. /** @hidden */
  42996. occlusionRetryCount: number;
  42997. /** @hidden */
  42998. occlusionType: number;
  42999. /** @hidden */
  43000. occlusionQueryAlgorithmType: number;
  43001. }
  43002. module "babylonjs/Engines/engine" {
  43003. interface Engine {
  43004. /**
  43005. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43006. * @return the new query
  43007. */
  43008. createQuery(): WebGLQuery;
  43009. /**
  43010. * Delete and release a webGL query
  43011. * @param query defines the query to delete
  43012. * @return the current engine
  43013. */
  43014. deleteQuery(query: WebGLQuery): Engine;
  43015. /**
  43016. * Check if a given query has resolved and got its value
  43017. * @param query defines the query to check
  43018. * @returns true if the query got its value
  43019. */
  43020. isQueryResultAvailable(query: WebGLQuery): boolean;
  43021. /**
  43022. * Gets the value of a given query
  43023. * @param query defines the query to check
  43024. * @returns the value of the query
  43025. */
  43026. getQueryResult(query: WebGLQuery): number;
  43027. /**
  43028. * Initiates an occlusion query
  43029. * @param algorithmType defines the algorithm to use
  43030. * @param query defines the query to use
  43031. * @returns the current engine
  43032. * @see http://doc.babylonjs.com/features/occlusionquery
  43033. */
  43034. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43035. /**
  43036. * Ends an occlusion query
  43037. * @see http://doc.babylonjs.com/features/occlusionquery
  43038. * @param algorithmType defines the algorithm to use
  43039. * @returns the current engine
  43040. */
  43041. endOcclusionQuery(algorithmType: number): Engine;
  43042. /**
  43043. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43044. * Please note that only one query can be issued at a time
  43045. * @returns a time token used to track the time span
  43046. */
  43047. startTimeQuery(): Nullable<_TimeToken>;
  43048. /**
  43049. * Ends a time query
  43050. * @param token defines the token used to measure the time span
  43051. * @returns the time spent (in ns)
  43052. */
  43053. endTimeQuery(token: _TimeToken): int;
  43054. /** @hidden */
  43055. _currentNonTimestampToken: Nullable<_TimeToken>;
  43056. /** @hidden */
  43057. _createTimeQuery(): WebGLQuery;
  43058. /** @hidden */
  43059. _deleteTimeQuery(query: WebGLQuery): void;
  43060. /** @hidden */
  43061. _getGlAlgorithmType(algorithmType: number): number;
  43062. /** @hidden */
  43063. _getTimeQueryResult(query: WebGLQuery): any;
  43064. /** @hidden */
  43065. _getTimeQueryAvailability(query: WebGLQuery): any;
  43066. }
  43067. }
  43068. module "babylonjs/Meshes/abstractMesh" {
  43069. interface AbstractMesh {
  43070. /**
  43071. * Backing filed
  43072. * @hidden
  43073. */
  43074. __occlusionDataStorage: _OcclusionDataStorage;
  43075. /**
  43076. * Access property
  43077. * @hidden
  43078. */
  43079. _occlusionDataStorage: _OcclusionDataStorage;
  43080. /**
  43081. * 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.
  43082. * The default value is -1 which means don't break the query and wait till the result
  43083. * @see http://doc.babylonjs.com/features/occlusionquery
  43084. */
  43085. occlusionRetryCount: number;
  43086. /**
  43087. * 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:
  43088. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43089. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43090. * * 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.
  43091. * @see http://doc.babylonjs.com/features/occlusionquery
  43092. */
  43093. occlusionType: number;
  43094. /**
  43095. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43096. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43097. * * 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.
  43098. * @see http://doc.babylonjs.com/features/occlusionquery
  43099. */
  43100. occlusionQueryAlgorithmType: number;
  43101. /**
  43102. * 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
  43103. * @see http://doc.babylonjs.com/features/occlusionquery
  43104. */
  43105. isOccluded: boolean;
  43106. /**
  43107. * Flag to check the progress status of the query
  43108. * @see http://doc.babylonjs.com/features/occlusionquery
  43109. */
  43110. isOcclusionQueryInProgress: boolean;
  43111. }
  43112. }
  43113. }
  43114. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43115. import { Nullable } from "babylonjs/types";
  43116. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43117. /** @hidden */
  43118. export var _forceTransformFeedbackToBundle: boolean;
  43119. module "babylonjs/Engines/engine" {
  43120. interface Engine {
  43121. /**
  43122. * Creates a webGL transform feedback object
  43123. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43124. * @returns the webGL transform feedback object
  43125. */
  43126. createTransformFeedback(): WebGLTransformFeedback;
  43127. /**
  43128. * Delete a webGL transform feedback object
  43129. * @param value defines the webGL transform feedback object to delete
  43130. */
  43131. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43132. /**
  43133. * Bind a webGL transform feedback object to the webgl context
  43134. * @param value defines the webGL transform feedback object to bind
  43135. */
  43136. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43137. /**
  43138. * Begins a transform feedback operation
  43139. * @param usePoints defines if points or triangles must be used
  43140. */
  43141. beginTransformFeedback(usePoints: boolean): void;
  43142. /**
  43143. * Ends a transform feedback operation
  43144. */
  43145. endTransformFeedback(): void;
  43146. /**
  43147. * Specify the varyings to use with transform feedback
  43148. * @param program defines the associated webGL program
  43149. * @param value defines the list of strings representing the varying names
  43150. */
  43151. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43152. /**
  43153. * Bind a webGL buffer for a transform feedback operation
  43154. * @param value defines the webGL buffer to bind
  43155. */
  43156. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43157. }
  43158. }
  43159. }
  43160. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43161. import { Scene } from "babylonjs/scene";
  43162. import { Engine } from "babylonjs/Engines/engine";
  43163. import { Texture } from "babylonjs/Materials/Textures/texture";
  43164. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43165. import "babylonjs/Engines/Extensions/engine.multiRender";
  43166. /**
  43167. * Creation options of the multi render target texture.
  43168. */
  43169. export interface IMultiRenderTargetOptions {
  43170. /**
  43171. * Define if the texture needs to create mip maps after render.
  43172. */
  43173. generateMipMaps?: boolean;
  43174. /**
  43175. * Define the types of all the draw buffers we want to create
  43176. */
  43177. types?: number[];
  43178. /**
  43179. * Define the sampling modes of all the draw buffers we want to create
  43180. */
  43181. samplingModes?: number[];
  43182. /**
  43183. * Define if a depth buffer is required
  43184. */
  43185. generateDepthBuffer?: boolean;
  43186. /**
  43187. * Define if a stencil buffer is required
  43188. */
  43189. generateStencilBuffer?: boolean;
  43190. /**
  43191. * Define if a depth texture is required instead of a depth buffer
  43192. */
  43193. generateDepthTexture?: boolean;
  43194. /**
  43195. * Define the number of desired draw buffers
  43196. */
  43197. textureCount?: number;
  43198. /**
  43199. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43200. */
  43201. doNotChangeAspectRatio?: boolean;
  43202. /**
  43203. * Define the default type of the buffers we are creating
  43204. */
  43205. defaultType?: number;
  43206. }
  43207. /**
  43208. * A multi render target, like a render target provides the ability to render to a texture.
  43209. * Unlike the render target, it can render to several draw buffers in one draw.
  43210. * This is specially interesting in deferred rendering or for any effects requiring more than
  43211. * just one color from a single pass.
  43212. */
  43213. export class MultiRenderTarget extends RenderTargetTexture {
  43214. private _internalTextures;
  43215. private _textures;
  43216. private _multiRenderTargetOptions;
  43217. /**
  43218. * Get if draw buffers are currently supported by the used hardware and browser.
  43219. */
  43220. readonly isSupported: boolean;
  43221. /**
  43222. * Get the list of textures generated by the multi render target.
  43223. */
  43224. readonly textures: Texture[];
  43225. /**
  43226. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43227. */
  43228. readonly depthTexture: Texture;
  43229. /**
  43230. * Set the wrapping mode on U of all the textures we are rendering to.
  43231. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43232. */
  43233. wrapU: number;
  43234. /**
  43235. * Set the wrapping mode on V of all the textures we are rendering to.
  43236. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43237. */
  43238. wrapV: number;
  43239. /**
  43240. * Instantiate a new multi render target texture.
  43241. * A multi render target, like a render target provides the ability to render to a texture.
  43242. * Unlike the render target, it can render to several draw buffers in one draw.
  43243. * This is specially interesting in deferred rendering or for any effects requiring more than
  43244. * just one color from a single pass.
  43245. * @param name Define the name of the texture
  43246. * @param size Define the size of the buffers to render to
  43247. * @param count Define the number of target we are rendering into
  43248. * @param scene Define the scene the texture belongs to
  43249. * @param options Define the options used to create the multi render target
  43250. */
  43251. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43252. /** @hidden */
  43253. _rebuild(): void;
  43254. private _createInternalTextures;
  43255. private _createTextures;
  43256. /**
  43257. * Define the number of samples used if MSAA is enabled.
  43258. */
  43259. samples: number;
  43260. /**
  43261. * Resize all the textures in the multi render target.
  43262. * Be carrefull as it will recreate all the data in the new texture.
  43263. * @param size Define the new size
  43264. */
  43265. resize(size: any): void;
  43266. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43267. /**
  43268. * Dispose the render targets and their associated resources
  43269. */
  43270. dispose(): void;
  43271. /**
  43272. * Release all the underlying texture used as draw buffers.
  43273. */
  43274. releaseInternalTextures(): void;
  43275. }
  43276. }
  43277. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43278. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43279. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43280. import { Nullable } from "babylonjs/types";
  43281. module "babylonjs/Engines/engine" {
  43282. interface Engine {
  43283. /**
  43284. * Unbind a list of render target textures from the webGL context
  43285. * This is used only when drawBuffer extension or webGL2 are active
  43286. * @param textures defines the render target textures to unbind
  43287. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43288. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43289. */
  43290. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43291. /**
  43292. * Create a multi render target texture
  43293. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43294. * @param size defines the size of the texture
  43295. * @param options defines the creation options
  43296. * @returns the cube texture as an InternalTexture
  43297. */
  43298. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43299. /**
  43300. * Update the sample count for a given multiple render target texture
  43301. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43302. * @param textures defines the textures to update
  43303. * @param samples defines the sample count to set
  43304. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43305. */
  43306. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43307. }
  43308. }
  43309. }
  43310. declare module "babylonjs/Engines/Extensions/index" {
  43311. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43312. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43313. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43314. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43315. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43316. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43317. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43318. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43319. }
  43320. declare module "babylonjs/Engines/index" {
  43321. export * from "babylonjs/Engines/constants";
  43322. export * from "babylonjs/Engines/engine";
  43323. export * from "babylonjs/Engines/engineStore";
  43324. export * from "babylonjs/Engines/nullEngine";
  43325. export * from "babylonjs/Engines/Extensions/index";
  43326. export * from "babylonjs/Engines/IPipelineContext";
  43327. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43328. }
  43329. declare module "babylonjs/Events/clipboardEvents" {
  43330. /**
  43331. * Gather the list of clipboard event types as constants.
  43332. */
  43333. export class ClipboardEventTypes {
  43334. /**
  43335. * The clipboard event is fired when a copy command is active (pressed).
  43336. */
  43337. static readonly COPY: number;
  43338. /**
  43339. * The clipboard event is fired when a cut command is active (pressed).
  43340. */
  43341. static readonly CUT: number;
  43342. /**
  43343. * The clipboard event is fired when a paste command is active (pressed).
  43344. */
  43345. static readonly PASTE: number;
  43346. }
  43347. /**
  43348. * This class is used to store clipboard related info for the onClipboardObservable event.
  43349. */
  43350. export class ClipboardInfo {
  43351. /**
  43352. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43353. */
  43354. type: number;
  43355. /**
  43356. * Defines the related dom event
  43357. */
  43358. event: ClipboardEvent;
  43359. /**
  43360. *Creates an instance of ClipboardInfo.
  43361. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43362. * @param event Defines the related dom event
  43363. */
  43364. constructor(
  43365. /**
  43366. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43367. */
  43368. type: number,
  43369. /**
  43370. * Defines the related dom event
  43371. */
  43372. event: ClipboardEvent);
  43373. /**
  43374. * Get the clipboard event's type from the keycode.
  43375. * @param keyCode Defines the keyCode for the current keyboard event.
  43376. * @return {number}
  43377. */
  43378. static GetTypeFromCharacter(keyCode: number): number;
  43379. }
  43380. }
  43381. declare module "babylonjs/Events/index" {
  43382. export * from "babylonjs/Events/keyboardEvents";
  43383. export * from "babylonjs/Events/pointerEvents";
  43384. export * from "babylonjs/Events/clipboardEvents";
  43385. }
  43386. declare module "babylonjs/Loading/sceneLoader" {
  43387. import { Observable } from "babylonjs/Misc/observable";
  43388. import { Nullable } from "babylonjs/types";
  43389. import { Scene } from "babylonjs/scene";
  43390. import { Engine } from "babylonjs/Engines/engine";
  43391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43392. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43393. import { AssetContainer } from "babylonjs/assetContainer";
  43394. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43395. import { Skeleton } from "babylonjs/Bones/skeleton";
  43396. /**
  43397. * Class used to represent data loading progression
  43398. */
  43399. export class SceneLoaderProgressEvent {
  43400. /** defines if data length to load can be evaluated */
  43401. readonly lengthComputable: boolean;
  43402. /** defines the loaded data length */
  43403. readonly loaded: number;
  43404. /** defines the data length to load */
  43405. readonly total: number;
  43406. /**
  43407. * Create a new progress event
  43408. * @param lengthComputable defines if data length to load can be evaluated
  43409. * @param loaded defines the loaded data length
  43410. * @param total defines the data length to load
  43411. */
  43412. constructor(
  43413. /** defines if data length to load can be evaluated */
  43414. lengthComputable: boolean,
  43415. /** defines the loaded data length */
  43416. loaded: number,
  43417. /** defines the data length to load */
  43418. total: number);
  43419. /**
  43420. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43421. * @param event defines the source event
  43422. * @returns a new SceneLoaderProgressEvent
  43423. */
  43424. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43425. }
  43426. /**
  43427. * Interface used by SceneLoader plugins to define supported file extensions
  43428. */
  43429. export interface ISceneLoaderPluginExtensions {
  43430. /**
  43431. * Defines the list of supported extensions
  43432. */
  43433. [extension: string]: {
  43434. isBinary: boolean;
  43435. };
  43436. }
  43437. /**
  43438. * Interface used by SceneLoader plugin factory
  43439. */
  43440. export interface ISceneLoaderPluginFactory {
  43441. /**
  43442. * Defines the name of the factory
  43443. */
  43444. name: string;
  43445. /**
  43446. * Function called to create a new plugin
  43447. * @return the new plugin
  43448. */
  43449. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43450. /**
  43451. * Boolean indicating if the plugin can direct load specific data
  43452. */
  43453. canDirectLoad?: (data: string) => boolean;
  43454. }
  43455. /**
  43456. * Interface used to define a SceneLoader plugin
  43457. */
  43458. export interface ISceneLoaderPlugin {
  43459. /**
  43460. * The friendly name of this plugin.
  43461. */
  43462. name: string;
  43463. /**
  43464. * The file extensions supported by this plugin.
  43465. */
  43466. extensions: string | ISceneLoaderPluginExtensions;
  43467. /**
  43468. * Import meshes into a scene.
  43469. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43470. * @param scene The scene to import into
  43471. * @param data The data to import
  43472. * @param rootUrl The root url for scene and resources
  43473. * @param meshes The meshes array to import into
  43474. * @param particleSystems The particle systems array to import into
  43475. * @param skeletons The skeletons array to import into
  43476. * @param onError The callback when import fails
  43477. * @returns True if successful or false otherwise
  43478. */
  43479. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43480. /**
  43481. * Load into a scene.
  43482. * @param scene The scene to load into
  43483. * @param data The data to import
  43484. * @param rootUrl The root url for scene and resources
  43485. * @param onError The callback when import fails
  43486. * @returns true if successful or false otherwise
  43487. */
  43488. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43489. /**
  43490. * The callback that returns true if the data can be directly loaded.
  43491. */
  43492. canDirectLoad?: (data: string) => boolean;
  43493. /**
  43494. * The callback that allows custom handling of the root url based on the response url.
  43495. */
  43496. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43497. /**
  43498. * Load into an asset container.
  43499. * @param scene The scene to load into
  43500. * @param data The data to import
  43501. * @param rootUrl The root url for scene and resources
  43502. * @param onError The callback when import fails
  43503. * @returns The loaded asset container
  43504. */
  43505. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43506. }
  43507. /**
  43508. * Interface used to define an async SceneLoader plugin
  43509. */
  43510. export interface ISceneLoaderPluginAsync {
  43511. /**
  43512. * The friendly name of this plugin.
  43513. */
  43514. name: string;
  43515. /**
  43516. * The file extensions supported by this plugin.
  43517. */
  43518. extensions: string | ISceneLoaderPluginExtensions;
  43519. /**
  43520. * Import meshes into a scene.
  43521. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43522. * @param scene The scene to import into
  43523. * @param data The data to import
  43524. * @param rootUrl The root url for scene and resources
  43525. * @param onProgress The callback when the load progresses
  43526. * @param fileName Defines the name of the file to load
  43527. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43528. */
  43529. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43530. meshes: AbstractMesh[];
  43531. particleSystems: IParticleSystem[];
  43532. skeletons: Skeleton[];
  43533. animationGroups: AnimationGroup[];
  43534. }>;
  43535. /**
  43536. * Load into a scene.
  43537. * @param scene The scene to load into
  43538. * @param data The data to import
  43539. * @param rootUrl The root url for scene and resources
  43540. * @param onProgress The callback when the load progresses
  43541. * @param fileName Defines the name of the file to load
  43542. * @returns Nothing
  43543. */
  43544. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43545. /**
  43546. * The callback that returns true if the data can be directly loaded.
  43547. */
  43548. canDirectLoad?: (data: string) => boolean;
  43549. /**
  43550. * The callback that allows custom handling of the root url based on the response url.
  43551. */
  43552. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43553. /**
  43554. * Load into an asset container.
  43555. * @param scene The scene to load into
  43556. * @param data The data to import
  43557. * @param rootUrl The root url for scene and resources
  43558. * @param onProgress The callback when the load progresses
  43559. * @param fileName Defines the name of the file to load
  43560. * @returns The loaded asset container
  43561. */
  43562. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43563. }
  43564. /**
  43565. * Class used to load scene from various file formats using registered plugins
  43566. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43567. */
  43568. export class SceneLoader {
  43569. /**
  43570. * No logging while loading
  43571. */
  43572. static readonly NO_LOGGING: number;
  43573. /**
  43574. * Minimal logging while loading
  43575. */
  43576. static readonly MINIMAL_LOGGING: number;
  43577. /**
  43578. * Summary logging while loading
  43579. */
  43580. static readonly SUMMARY_LOGGING: number;
  43581. /**
  43582. * Detailled logging while loading
  43583. */
  43584. static readonly DETAILED_LOGGING: number;
  43585. /**
  43586. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43587. */
  43588. static ForceFullSceneLoadingForIncremental: boolean;
  43589. /**
  43590. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43591. */
  43592. static ShowLoadingScreen: boolean;
  43593. /**
  43594. * Defines the current logging level (while loading the scene)
  43595. * @ignorenaming
  43596. */
  43597. static loggingLevel: number;
  43598. /**
  43599. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43600. */
  43601. static CleanBoneMatrixWeights: boolean;
  43602. /**
  43603. * Event raised when a plugin is used to load a scene
  43604. */
  43605. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43606. private static _registeredPlugins;
  43607. private static _getDefaultPlugin;
  43608. private static _getPluginForExtension;
  43609. private static _getPluginForDirectLoad;
  43610. private static _getPluginForFilename;
  43611. private static _getDirectLoad;
  43612. private static _loadData;
  43613. private static _getFileInfo;
  43614. /**
  43615. * Gets a plugin that can load the given extension
  43616. * @param extension defines the extension to load
  43617. * @returns a plugin or null if none works
  43618. */
  43619. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43620. /**
  43621. * Gets a boolean indicating that the given extension can be loaded
  43622. * @param extension defines the extension to load
  43623. * @returns true if the extension is supported
  43624. */
  43625. static IsPluginForExtensionAvailable(extension: string): boolean;
  43626. /**
  43627. * Adds a new plugin to the list of registered plugins
  43628. * @param plugin defines the plugin to add
  43629. */
  43630. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43631. /**
  43632. * Import meshes into a scene
  43633. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43634. * @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)
  43635. * @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)
  43636. * @param scene the instance of BABYLON.Scene to append to
  43637. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43638. * @param onProgress a callback with a progress event for each file being loaded
  43639. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43640. * @param pluginExtension the extension used to determine the plugin
  43641. * @returns The loaded plugin
  43642. */
  43643. 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>;
  43644. /**
  43645. * Import meshes into a scene
  43646. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43647. * @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)
  43648. * @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)
  43649. * @param scene the instance of BABYLON.Scene to append to
  43650. * @param onProgress a callback with a progress event for each file being loaded
  43651. * @param pluginExtension the extension used to determine the plugin
  43652. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43653. */
  43654. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43655. meshes: AbstractMesh[];
  43656. particleSystems: IParticleSystem[];
  43657. skeletons: Skeleton[];
  43658. animationGroups: AnimationGroup[];
  43659. }>;
  43660. /**
  43661. * Load a scene
  43662. * @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)
  43663. * @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)
  43664. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43665. * @param onSuccess a callback with the scene when import succeeds
  43666. * @param onProgress a callback with a progress event for each file being loaded
  43667. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43668. * @param pluginExtension the extension used to determine the plugin
  43669. * @returns The loaded plugin
  43670. */
  43671. 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>;
  43672. /**
  43673. * Load a scene
  43674. * @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)
  43675. * @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)
  43676. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43677. * @param onProgress a callback with a progress event for each file being loaded
  43678. * @param pluginExtension the extension used to determine the plugin
  43679. * @returns The loaded scene
  43680. */
  43681. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43682. /**
  43683. * Append a scene
  43684. * @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)
  43685. * @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)
  43686. * @param scene is the instance of BABYLON.Scene to append to
  43687. * @param onSuccess a callback with the scene when import succeeds
  43688. * @param onProgress a callback with a progress event for each file being loaded
  43689. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43690. * @param pluginExtension the extension used to determine the plugin
  43691. * @returns The loaded plugin
  43692. */
  43693. 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>;
  43694. /**
  43695. * Append a scene
  43696. * @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)
  43697. * @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)
  43698. * @param scene is the instance of BABYLON.Scene to append to
  43699. * @param onProgress a callback with a progress event for each file being loaded
  43700. * @param pluginExtension the extension used to determine the plugin
  43701. * @returns The given scene
  43702. */
  43703. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43704. /**
  43705. * Load a scene into an asset container
  43706. * @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)
  43707. * @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)
  43708. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43709. * @param onSuccess a callback with the scene when import succeeds
  43710. * @param onProgress a callback with a progress event for each file being loaded
  43711. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43712. * @param pluginExtension the extension used to determine the plugin
  43713. * @returns The loaded plugin
  43714. */
  43715. 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>;
  43716. /**
  43717. * Load a scene into an asset container
  43718. * @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)
  43719. * @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)
  43720. * @param scene is the instance of Scene to append to
  43721. * @param onProgress a callback with a progress event for each file being loaded
  43722. * @param pluginExtension the extension used to determine the plugin
  43723. * @returns The loaded asset container
  43724. */
  43725. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43726. }
  43727. }
  43728. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43729. import { Scene } from "babylonjs/scene";
  43730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43731. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43732. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43733. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43734. /**
  43735. * Google Daydream controller
  43736. */
  43737. export class DaydreamController extends WebVRController {
  43738. /**
  43739. * Base Url for the controller model.
  43740. */
  43741. static MODEL_BASE_URL: string;
  43742. /**
  43743. * File name for the controller model.
  43744. */
  43745. static MODEL_FILENAME: string;
  43746. /**
  43747. * Gamepad Id prefix used to identify Daydream Controller.
  43748. */
  43749. static readonly GAMEPAD_ID_PREFIX: string;
  43750. /**
  43751. * Creates a new DaydreamController from a gamepad
  43752. * @param vrGamepad the gamepad that the controller should be created from
  43753. */
  43754. constructor(vrGamepad: any);
  43755. /**
  43756. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43757. * @param scene scene in which to add meshes
  43758. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43759. */
  43760. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43761. /**
  43762. * Called once for each button that changed state since the last frame
  43763. * @param buttonIdx Which button index changed
  43764. * @param state New state of the button
  43765. * @param changes Which properties on the state changed since last frame
  43766. */
  43767. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43768. }
  43769. }
  43770. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43771. import { Scene } from "babylonjs/scene";
  43772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43773. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43774. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43775. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43776. /**
  43777. * Gear VR Controller
  43778. */
  43779. export class GearVRController extends WebVRController {
  43780. /**
  43781. * Base Url for the controller model.
  43782. */
  43783. static MODEL_BASE_URL: string;
  43784. /**
  43785. * File name for the controller model.
  43786. */
  43787. static MODEL_FILENAME: string;
  43788. /**
  43789. * Gamepad Id prefix used to identify this controller.
  43790. */
  43791. static readonly GAMEPAD_ID_PREFIX: string;
  43792. private readonly _buttonIndexToObservableNameMap;
  43793. /**
  43794. * Creates a new GearVRController from a gamepad
  43795. * @param vrGamepad the gamepad that the controller should be created from
  43796. */
  43797. constructor(vrGamepad: any);
  43798. /**
  43799. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43800. * @param scene scene in which to add meshes
  43801. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43802. */
  43803. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43804. /**
  43805. * Called once for each button that changed state since the last frame
  43806. * @param buttonIdx Which button index changed
  43807. * @param state New state of the button
  43808. * @param changes Which properties on the state changed since last frame
  43809. */
  43810. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43811. }
  43812. }
  43813. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43814. import { Scene } from "babylonjs/scene";
  43815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43816. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43817. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43818. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43819. /**
  43820. * Generic Controller
  43821. */
  43822. export class GenericController extends WebVRController {
  43823. /**
  43824. * Base Url for the controller model.
  43825. */
  43826. static readonly MODEL_BASE_URL: string;
  43827. /**
  43828. * File name for the controller model.
  43829. */
  43830. static readonly MODEL_FILENAME: string;
  43831. /**
  43832. * Creates a new GenericController from a gamepad
  43833. * @param vrGamepad the gamepad that the controller should be created from
  43834. */
  43835. constructor(vrGamepad: any);
  43836. /**
  43837. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43838. * @param scene scene in which to add meshes
  43839. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43840. */
  43841. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43842. /**
  43843. * Called once for each button that changed state since the last frame
  43844. * @param buttonIdx Which button index changed
  43845. * @param state New state of the button
  43846. * @param changes Which properties on the state changed since last frame
  43847. */
  43848. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43849. }
  43850. }
  43851. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43852. import { Observable } from "babylonjs/Misc/observable";
  43853. import { Scene } from "babylonjs/scene";
  43854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43855. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43856. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43857. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43858. /**
  43859. * Oculus Touch Controller
  43860. */
  43861. export class OculusTouchController extends WebVRController {
  43862. /**
  43863. * Base Url for the controller model.
  43864. */
  43865. static MODEL_BASE_URL: string;
  43866. /**
  43867. * File name for the left controller model.
  43868. */
  43869. static MODEL_LEFT_FILENAME: string;
  43870. /**
  43871. * File name for the right controller model.
  43872. */
  43873. static MODEL_RIGHT_FILENAME: string;
  43874. /**
  43875. * Fired when the secondary trigger on this controller is modified
  43876. */
  43877. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43878. /**
  43879. * Fired when the thumb rest on this controller is modified
  43880. */
  43881. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43882. /**
  43883. * Creates a new OculusTouchController from a gamepad
  43884. * @param vrGamepad the gamepad that the controller should be created from
  43885. */
  43886. constructor(vrGamepad: any);
  43887. /**
  43888. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43889. * @param scene scene in which to add meshes
  43890. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43891. */
  43892. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43893. /**
  43894. * Fired when the A button on this controller is modified
  43895. */
  43896. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43897. /**
  43898. * Fired when the B button on this controller is modified
  43899. */
  43900. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43901. /**
  43902. * Fired when the X button on this controller is modified
  43903. */
  43904. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43905. /**
  43906. * Fired when the Y button on this controller is modified
  43907. */
  43908. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43909. /**
  43910. * Called once for each button that changed state since the last frame
  43911. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43912. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43913. * 2) secondary trigger (same)
  43914. * 3) A (right) X (left), touch, pressed = value
  43915. * 4) B / Y
  43916. * 5) thumb rest
  43917. * @param buttonIdx Which button index changed
  43918. * @param state New state of the button
  43919. * @param changes Which properties on the state changed since last frame
  43920. */
  43921. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43922. }
  43923. }
  43924. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43925. import { Scene } from "babylonjs/scene";
  43926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43927. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43928. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43929. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43930. import { Observable } from "babylonjs/Misc/observable";
  43931. /**
  43932. * Vive Controller
  43933. */
  43934. export class ViveController extends WebVRController {
  43935. /**
  43936. * Base Url for the controller model.
  43937. */
  43938. static MODEL_BASE_URL: string;
  43939. /**
  43940. * File name for the controller model.
  43941. */
  43942. static MODEL_FILENAME: string;
  43943. /**
  43944. * Creates a new ViveController from a gamepad
  43945. * @param vrGamepad the gamepad that the controller should be created from
  43946. */
  43947. constructor(vrGamepad: any);
  43948. /**
  43949. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43950. * @param scene scene in which to add meshes
  43951. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43952. */
  43953. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43954. /**
  43955. * Fired when the left button on this controller is modified
  43956. */
  43957. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43958. /**
  43959. * Fired when the right button on this controller is modified
  43960. */
  43961. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43962. /**
  43963. * Fired when the menu button on this controller is modified
  43964. */
  43965. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43966. /**
  43967. * Called once for each button that changed state since the last frame
  43968. * Vive mapping:
  43969. * 0: touchpad
  43970. * 1: trigger
  43971. * 2: left AND right buttons
  43972. * 3: menu button
  43973. * @param buttonIdx Which button index changed
  43974. * @param state New state of the button
  43975. * @param changes Which properties on the state changed since last frame
  43976. */
  43977. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43978. }
  43979. }
  43980. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43981. import { Observable } from "babylonjs/Misc/observable";
  43982. import { Scene } from "babylonjs/scene";
  43983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43984. import { Ray } from "babylonjs/Culling/ray";
  43985. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43986. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43987. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43988. /**
  43989. * Defines the WindowsMotionController object that the state of the windows motion controller
  43990. */
  43991. export class WindowsMotionController extends WebVRController {
  43992. /**
  43993. * The base url used to load the left and right controller models
  43994. */
  43995. static MODEL_BASE_URL: string;
  43996. /**
  43997. * The name of the left controller model file
  43998. */
  43999. static MODEL_LEFT_FILENAME: string;
  44000. /**
  44001. * The name of the right controller model file
  44002. */
  44003. static MODEL_RIGHT_FILENAME: string;
  44004. /**
  44005. * The controller name prefix for this controller type
  44006. */
  44007. static readonly GAMEPAD_ID_PREFIX: string;
  44008. /**
  44009. * The controller id pattern for this controller type
  44010. */
  44011. private static readonly GAMEPAD_ID_PATTERN;
  44012. private _loadedMeshInfo;
  44013. private readonly _mapping;
  44014. /**
  44015. * Fired when the trackpad on this controller is clicked
  44016. */
  44017. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44018. /**
  44019. * Fired when the trackpad on this controller is modified
  44020. */
  44021. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44022. /**
  44023. * The current x and y values of this controller's trackpad
  44024. */
  44025. trackpad: StickValues;
  44026. /**
  44027. * Creates a new WindowsMotionController from a gamepad
  44028. * @param vrGamepad the gamepad that the controller should be created from
  44029. */
  44030. constructor(vrGamepad: any);
  44031. /**
  44032. * Fired when the trigger on this controller is modified
  44033. */
  44034. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44035. /**
  44036. * Fired when the menu button on this controller is modified
  44037. */
  44038. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44039. /**
  44040. * Fired when the grip button on this controller is modified
  44041. */
  44042. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44043. /**
  44044. * Fired when the thumbstick button on this controller is modified
  44045. */
  44046. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44047. /**
  44048. * Fired when the touchpad button on this controller is modified
  44049. */
  44050. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44051. /**
  44052. * Fired when the touchpad values on this controller are modified
  44053. */
  44054. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44055. private _updateTrackpad;
  44056. /**
  44057. * Called once per frame by the engine.
  44058. */
  44059. update(): void;
  44060. /**
  44061. * Called once for each button that changed state since the last frame
  44062. * @param buttonIdx Which button index changed
  44063. * @param state New state of the button
  44064. * @param changes Which properties on the state changed since last frame
  44065. */
  44066. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44067. /**
  44068. * Moves the buttons on the controller mesh based on their current state
  44069. * @param buttonName the name of the button to move
  44070. * @param buttonValue the value of the button which determines the buttons new position
  44071. */
  44072. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44073. /**
  44074. * Moves the axis on the controller mesh based on its current state
  44075. * @param axis the index of the axis
  44076. * @param axisValue the value of the axis which determines the meshes new position
  44077. * @hidden
  44078. */
  44079. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44080. /**
  44081. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44082. * @param scene scene in which to add meshes
  44083. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44084. */
  44085. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44086. /**
  44087. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44088. * can be transformed by button presses and axes values, based on this._mapping.
  44089. *
  44090. * @param scene scene in which the meshes exist
  44091. * @param meshes list of meshes that make up the controller model to process
  44092. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44093. */
  44094. private processModel;
  44095. private createMeshInfo;
  44096. /**
  44097. * Gets the ray of the controller in the direction the controller is pointing
  44098. * @param length the length the resulting ray should be
  44099. * @returns a ray in the direction the controller is pointing
  44100. */
  44101. getForwardRay(length?: number): Ray;
  44102. /**
  44103. * Disposes of the controller
  44104. */
  44105. dispose(): void;
  44106. }
  44107. }
  44108. declare module "babylonjs/Gamepads/Controllers/index" {
  44109. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44110. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44111. export * from "babylonjs/Gamepads/Controllers/genericController";
  44112. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44113. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44114. export * from "babylonjs/Gamepads/Controllers/viveController";
  44115. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44116. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44117. }
  44118. declare module "babylonjs/Gamepads/index" {
  44119. export * from "babylonjs/Gamepads/Controllers/index";
  44120. export * from "babylonjs/Gamepads/gamepad";
  44121. export * from "babylonjs/Gamepads/gamepadManager";
  44122. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44123. export * from "babylonjs/Gamepads/xboxGamepad";
  44124. }
  44125. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44126. import { Observable } from "babylonjs/Misc/observable";
  44127. import { Nullable } from "babylonjs/types";
  44128. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44130. import { Mesh } from "babylonjs/Meshes/mesh";
  44131. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44132. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44133. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44134. /**
  44135. * Single axis scale gizmo
  44136. */
  44137. export class AxisScaleGizmo extends Gizmo {
  44138. private _coloredMaterial;
  44139. /**
  44140. * Drag behavior responsible for the gizmos dragging interactions
  44141. */
  44142. dragBehavior: PointerDragBehavior;
  44143. private _pointerObserver;
  44144. /**
  44145. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44146. */
  44147. snapDistance: number;
  44148. /**
  44149. * Event that fires each time the gizmo snaps to a new location.
  44150. * * snapDistance is the the change in distance
  44151. */
  44152. onSnapObservable: Observable<{
  44153. snapDistance: number;
  44154. }>;
  44155. /**
  44156. * If the scaling operation should be done on all axis (default: false)
  44157. */
  44158. uniformScaling: boolean;
  44159. /**
  44160. * Creates an AxisScaleGizmo
  44161. * @param gizmoLayer The utility layer the gizmo will be added to
  44162. * @param dragAxis The axis which the gizmo will be able to scale on
  44163. * @param color The color of the gizmo
  44164. */
  44165. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44166. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44167. /**
  44168. * Disposes of the gizmo
  44169. */
  44170. dispose(): void;
  44171. /**
  44172. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44173. * @param mesh The mesh to replace the default mesh of the gizmo
  44174. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44175. */
  44176. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44177. }
  44178. }
  44179. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44180. import { Observable } from "babylonjs/Misc/observable";
  44181. import { Nullable } from "babylonjs/types";
  44182. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44184. import { Mesh } from "babylonjs/Meshes/mesh";
  44185. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44186. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44187. import "babylonjs/Meshes/Builders/boxBuilder";
  44188. /**
  44189. * Bounding box gizmo
  44190. */
  44191. export class BoundingBoxGizmo extends Gizmo {
  44192. private _lineBoundingBox;
  44193. private _rotateSpheresParent;
  44194. private _scaleBoxesParent;
  44195. private _boundingDimensions;
  44196. private _renderObserver;
  44197. private _pointerObserver;
  44198. private _scaleDragSpeed;
  44199. private _tmpQuaternion;
  44200. private _tmpVector;
  44201. private _tmpRotationMatrix;
  44202. /**
  44203. * 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)
  44204. */
  44205. ignoreChildren: boolean;
  44206. /**
  44207. * 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)
  44208. */
  44209. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44210. /**
  44211. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44212. */
  44213. rotationSphereSize: number;
  44214. /**
  44215. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44216. */
  44217. scaleBoxSize: number;
  44218. /**
  44219. * 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)
  44220. */
  44221. fixedDragMeshScreenSize: boolean;
  44222. /**
  44223. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44224. */
  44225. fixedDragMeshScreenSizeDistanceFactor: number;
  44226. /**
  44227. * Fired when a rotation sphere or scale box is dragged
  44228. */
  44229. onDragStartObservable: Observable<{}>;
  44230. /**
  44231. * Fired when a scale box is dragged
  44232. */
  44233. onScaleBoxDragObservable: Observable<{}>;
  44234. /**
  44235. * Fired when a scale box drag is ended
  44236. */
  44237. onScaleBoxDragEndObservable: Observable<{}>;
  44238. /**
  44239. * Fired when a rotation sphere is dragged
  44240. */
  44241. onRotationSphereDragObservable: Observable<{}>;
  44242. /**
  44243. * Fired when a rotation sphere drag is ended
  44244. */
  44245. onRotationSphereDragEndObservable: Observable<{}>;
  44246. /**
  44247. * 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)
  44248. */
  44249. scalePivot: Nullable<Vector3>;
  44250. /**
  44251. * Mesh used as a pivot to rotate the attached mesh
  44252. */
  44253. private _anchorMesh;
  44254. private _existingMeshScale;
  44255. private _dragMesh;
  44256. private pointerDragBehavior;
  44257. private coloredMaterial;
  44258. private hoverColoredMaterial;
  44259. /**
  44260. * Sets the color of the bounding box gizmo
  44261. * @param color the color to set
  44262. */
  44263. setColor(color: Color3): void;
  44264. /**
  44265. * Creates an BoundingBoxGizmo
  44266. * @param gizmoLayer The utility layer the gizmo will be added to
  44267. * @param color The color of the gizmo
  44268. */
  44269. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44270. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44271. private _selectNode;
  44272. /**
  44273. * Updates the bounding box information for the Gizmo
  44274. */
  44275. updateBoundingBox(): void;
  44276. private _updateRotationSpheres;
  44277. private _updateScaleBoxes;
  44278. /**
  44279. * Enables rotation on the specified axis and disables rotation on the others
  44280. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44281. */
  44282. setEnabledRotationAxis(axis: string): void;
  44283. /**
  44284. * Enables/disables scaling
  44285. * @param enable if scaling should be enabled
  44286. */
  44287. setEnabledScaling(enable: boolean): void;
  44288. private _updateDummy;
  44289. /**
  44290. * Enables a pointer drag behavior on the bounding box of the gizmo
  44291. */
  44292. enableDragBehavior(): void;
  44293. /**
  44294. * Disposes of the gizmo
  44295. */
  44296. dispose(): void;
  44297. /**
  44298. * 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)
  44299. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44300. * @returns the bounding box mesh with the passed in mesh as a child
  44301. */
  44302. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44303. /**
  44304. * CustomMeshes are not supported by this gizmo
  44305. * @param mesh The mesh to replace the default mesh of the gizmo
  44306. */
  44307. setCustomMesh(mesh: Mesh): void;
  44308. }
  44309. }
  44310. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44311. import { Observable } from "babylonjs/Misc/observable";
  44312. import { Nullable } from "babylonjs/types";
  44313. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44315. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44316. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44317. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44318. import "babylonjs/Meshes/Builders/linesBuilder";
  44319. /**
  44320. * Single plane rotation gizmo
  44321. */
  44322. export class PlaneRotationGizmo extends Gizmo {
  44323. /**
  44324. * Drag behavior responsible for the gizmos dragging interactions
  44325. */
  44326. dragBehavior: PointerDragBehavior;
  44327. private _pointerObserver;
  44328. /**
  44329. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44330. */
  44331. snapDistance: number;
  44332. /**
  44333. * Event that fires each time the gizmo snaps to a new location.
  44334. * * snapDistance is the the change in distance
  44335. */
  44336. onSnapObservable: Observable<{
  44337. snapDistance: number;
  44338. }>;
  44339. /**
  44340. * Creates a PlaneRotationGizmo
  44341. * @param gizmoLayer The utility layer the gizmo will be added to
  44342. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44343. * @param color The color of the gizmo
  44344. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44345. */
  44346. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44347. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44348. /**
  44349. * Disposes of the gizmo
  44350. */
  44351. dispose(): void;
  44352. }
  44353. }
  44354. declare module "babylonjs/Gizmos/rotationGizmo" {
  44355. import { Observable } from "babylonjs/Misc/observable";
  44356. import { Nullable } from "babylonjs/types";
  44357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44358. import { Mesh } from "babylonjs/Meshes/mesh";
  44359. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44360. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44361. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44362. /**
  44363. * Gizmo that enables rotating a mesh along 3 axis
  44364. */
  44365. export class RotationGizmo extends Gizmo {
  44366. /**
  44367. * Internal gizmo used for interactions on the x axis
  44368. */
  44369. xGizmo: PlaneRotationGizmo;
  44370. /**
  44371. * Internal gizmo used for interactions on the y axis
  44372. */
  44373. yGizmo: PlaneRotationGizmo;
  44374. /**
  44375. * Internal gizmo used for interactions on the z axis
  44376. */
  44377. zGizmo: PlaneRotationGizmo;
  44378. /** Fires an event when any of it's sub gizmos are dragged */
  44379. onDragStartObservable: Observable<{}>;
  44380. /** Fires an event when any of it's sub gizmos are released from dragging */
  44381. onDragEndObservable: Observable<{}>;
  44382. attachedMesh: Nullable<AbstractMesh>;
  44383. /**
  44384. * Creates a RotationGizmo
  44385. * @param gizmoLayer The utility layer the gizmo will be added to
  44386. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44387. */
  44388. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44389. updateGizmoRotationToMatchAttachedMesh: boolean;
  44390. /**
  44391. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44392. */
  44393. snapDistance: number;
  44394. /**
  44395. * Ratio for the scale of the gizmo (Default: 1)
  44396. */
  44397. scaleRatio: number;
  44398. /**
  44399. * Disposes of the gizmo
  44400. */
  44401. dispose(): void;
  44402. /**
  44403. * CustomMeshes are not supported by this gizmo
  44404. * @param mesh The mesh to replace the default mesh of the gizmo
  44405. */
  44406. setCustomMesh(mesh: Mesh): void;
  44407. }
  44408. }
  44409. declare module "babylonjs/Gizmos/positionGizmo" {
  44410. import { Observable } from "babylonjs/Misc/observable";
  44411. import { Nullable } from "babylonjs/types";
  44412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44413. import { Mesh } from "babylonjs/Meshes/mesh";
  44414. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44415. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44416. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44417. /**
  44418. * Gizmo that enables dragging a mesh along 3 axis
  44419. */
  44420. export class PositionGizmo extends Gizmo {
  44421. /**
  44422. * Internal gizmo used for interactions on the x axis
  44423. */
  44424. xGizmo: AxisDragGizmo;
  44425. /**
  44426. * Internal gizmo used for interactions on the y axis
  44427. */
  44428. yGizmo: AxisDragGizmo;
  44429. /**
  44430. * Internal gizmo used for interactions on the z axis
  44431. */
  44432. zGizmo: AxisDragGizmo;
  44433. /** Fires an event when any of it's sub gizmos are dragged */
  44434. onDragStartObservable: Observable<{}>;
  44435. /** Fires an event when any of it's sub gizmos are released from dragging */
  44436. onDragEndObservable: Observable<{}>;
  44437. attachedMesh: Nullable<AbstractMesh>;
  44438. /**
  44439. * Creates a PositionGizmo
  44440. * @param gizmoLayer The utility layer the gizmo will be added to
  44441. */
  44442. constructor(gizmoLayer?: UtilityLayerRenderer);
  44443. updateGizmoRotationToMatchAttachedMesh: boolean;
  44444. /**
  44445. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44446. */
  44447. snapDistance: number;
  44448. /**
  44449. * Ratio for the scale of the gizmo (Default: 1)
  44450. */
  44451. scaleRatio: number;
  44452. /**
  44453. * Disposes of the gizmo
  44454. */
  44455. dispose(): void;
  44456. /**
  44457. * CustomMeshes are not supported by this gizmo
  44458. * @param mesh The mesh to replace the default mesh of the gizmo
  44459. */
  44460. setCustomMesh(mesh: Mesh): void;
  44461. }
  44462. }
  44463. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44464. import { Scene } from "babylonjs/scene";
  44465. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44466. import { Mesh } from "babylonjs/Meshes/mesh";
  44467. import { Nullable } from "babylonjs/types";
  44468. /**
  44469. * Class containing static functions to help procedurally build meshes
  44470. */
  44471. export class PolyhedronBuilder {
  44472. /**
  44473. * Creates a polyhedron mesh
  44474. * * 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
  44475. * * The parameter `size` (positive float, default 1) sets the polygon size
  44476. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44477. * * 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`
  44478. * * 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
  44479. * * 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)`)
  44480. * * 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
  44481. * * 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
  44482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44485. * @param name defines the name of the mesh
  44486. * @param options defines the options used to create the mesh
  44487. * @param scene defines the hosting scene
  44488. * @returns the polyhedron mesh
  44489. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44490. */
  44491. static CreatePolyhedron(name: string, options: {
  44492. type?: number;
  44493. size?: number;
  44494. sizeX?: number;
  44495. sizeY?: number;
  44496. sizeZ?: number;
  44497. custom?: any;
  44498. faceUV?: Vector4[];
  44499. faceColors?: Color4[];
  44500. flat?: boolean;
  44501. updatable?: boolean;
  44502. sideOrientation?: number;
  44503. frontUVs?: Vector4;
  44504. backUVs?: Vector4;
  44505. }, scene?: Nullable<Scene>): Mesh;
  44506. }
  44507. }
  44508. declare module "babylonjs/Gizmos/scaleGizmo" {
  44509. import { Observable } from "babylonjs/Misc/observable";
  44510. import { Nullable } from "babylonjs/types";
  44511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44512. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44513. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44514. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44515. /**
  44516. * Gizmo that enables scaling a mesh along 3 axis
  44517. */
  44518. export class ScaleGizmo extends Gizmo {
  44519. /**
  44520. * Internal gizmo used for interactions on the x axis
  44521. */
  44522. xGizmo: AxisScaleGizmo;
  44523. /**
  44524. * Internal gizmo used for interactions on the y axis
  44525. */
  44526. yGizmo: AxisScaleGizmo;
  44527. /**
  44528. * Internal gizmo used for interactions on the z axis
  44529. */
  44530. zGizmo: AxisScaleGizmo;
  44531. /**
  44532. * Internal gizmo used to scale all axis equally
  44533. */
  44534. uniformScaleGizmo: AxisScaleGizmo;
  44535. /** Fires an event when any of it's sub gizmos are dragged */
  44536. onDragStartObservable: Observable<{}>;
  44537. /** Fires an event when any of it's sub gizmos are released from dragging */
  44538. onDragEndObservable: Observable<{}>;
  44539. attachedMesh: Nullable<AbstractMesh>;
  44540. /**
  44541. * Creates a ScaleGizmo
  44542. * @param gizmoLayer The utility layer the gizmo will be added to
  44543. */
  44544. constructor(gizmoLayer?: UtilityLayerRenderer);
  44545. updateGizmoRotationToMatchAttachedMesh: boolean;
  44546. /**
  44547. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44548. */
  44549. snapDistance: number;
  44550. /**
  44551. * Ratio for the scale of the gizmo (Default: 1)
  44552. */
  44553. scaleRatio: number;
  44554. /**
  44555. * Disposes of the gizmo
  44556. */
  44557. dispose(): void;
  44558. }
  44559. }
  44560. declare module "babylonjs/Gizmos/gizmoManager" {
  44561. import { Observable } from "babylonjs/Misc/observable";
  44562. import { Nullable } from "babylonjs/types";
  44563. import { Scene, IDisposable } from "babylonjs/scene";
  44564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44565. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44566. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44567. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44568. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44569. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44570. /**
  44571. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44572. */
  44573. export class GizmoManager implements IDisposable {
  44574. private scene;
  44575. /**
  44576. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44577. */
  44578. gizmos: {
  44579. positionGizmo: Nullable<PositionGizmo>;
  44580. rotationGizmo: Nullable<RotationGizmo>;
  44581. scaleGizmo: Nullable<ScaleGizmo>;
  44582. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44583. };
  44584. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44585. clearGizmoOnEmptyPointerEvent: boolean;
  44586. /** Fires an event when the manager is attached to a mesh */
  44587. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44588. private _gizmosEnabled;
  44589. private _pointerObserver;
  44590. private _attachedMesh;
  44591. private _boundingBoxColor;
  44592. private _defaultUtilityLayer;
  44593. private _defaultKeepDepthUtilityLayer;
  44594. /**
  44595. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44596. */
  44597. boundingBoxDragBehavior: SixDofDragBehavior;
  44598. /**
  44599. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44600. */
  44601. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44602. /**
  44603. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44604. */
  44605. usePointerToAttachGizmos: boolean;
  44606. /**
  44607. * Instatiates a gizmo manager
  44608. * @param scene the scene to overlay the gizmos on top of
  44609. */
  44610. constructor(scene: Scene);
  44611. /**
  44612. * Attaches a set of gizmos to the specified mesh
  44613. * @param mesh The mesh the gizmo's should be attached to
  44614. */
  44615. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44616. /**
  44617. * If the position gizmo is enabled
  44618. */
  44619. positionGizmoEnabled: boolean;
  44620. /**
  44621. * If the rotation gizmo is enabled
  44622. */
  44623. rotationGizmoEnabled: boolean;
  44624. /**
  44625. * If the scale gizmo is enabled
  44626. */
  44627. scaleGizmoEnabled: boolean;
  44628. /**
  44629. * If the boundingBox gizmo is enabled
  44630. */
  44631. boundingBoxGizmoEnabled: boolean;
  44632. /**
  44633. * Disposes of the gizmo manager
  44634. */
  44635. dispose(): void;
  44636. }
  44637. }
  44638. declare module "babylonjs/Lights/directionalLight" {
  44639. import { Camera } from "babylonjs/Cameras/camera";
  44640. import { Scene } from "babylonjs/scene";
  44641. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44643. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44644. import { Effect } from "babylonjs/Materials/effect";
  44645. /**
  44646. * A directional light is defined by a direction (what a surprise!).
  44647. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44648. * 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.
  44649. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44650. */
  44651. export class DirectionalLight extends ShadowLight {
  44652. private _shadowFrustumSize;
  44653. /**
  44654. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44655. */
  44656. /**
  44657. * Specifies a fix frustum size for the shadow generation.
  44658. */
  44659. shadowFrustumSize: number;
  44660. private _shadowOrthoScale;
  44661. /**
  44662. * Gets the shadow projection scale against the optimal computed one.
  44663. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44664. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44665. */
  44666. /**
  44667. * Sets the shadow projection scale against the optimal computed one.
  44668. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44669. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44670. */
  44671. shadowOrthoScale: number;
  44672. /**
  44673. * Automatically compute the projection matrix to best fit (including all the casters)
  44674. * on each frame.
  44675. */
  44676. autoUpdateExtends: boolean;
  44677. private _orthoLeft;
  44678. private _orthoRight;
  44679. private _orthoTop;
  44680. private _orthoBottom;
  44681. /**
  44682. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44683. * The directional light is emitted from everywhere in the given direction.
  44684. * It can cast shadows.
  44685. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44686. * @param name The friendly name of the light
  44687. * @param direction The direction of the light
  44688. * @param scene The scene the light belongs to
  44689. */
  44690. constructor(name: string, direction: Vector3, scene: Scene);
  44691. /**
  44692. * Returns the string "DirectionalLight".
  44693. * @return The class name
  44694. */
  44695. getClassName(): string;
  44696. /**
  44697. * Returns the integer 1.
  44698. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44699. */
  44700. getTypeID(): number;
  44701. /**
  44702. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44703. * Returns the DirectionalLight Shadow projection matrix.
  44704. */
  44705. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44706. /**
  44707. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44708. * Returns the DirectionalLight Shadow projection matrix.
  44709. */
  44710. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44711. /**
  44712. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44713. * Returns the DirectionalLight Shadow projection matrix.
  44714. */
  44715. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44716. protected _buildUniformLayout(): void;
  44717. /**
  44718. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44719. * @param effect The effect to update
  44720. * @param lightIndex The index of the light in the effect to update
  44721. * @returns The directional light
  44722. */
  44723. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44724. /**
  44725. * Gets the minZ used for shadow according to both the scene and the light.
  44726. *
  44727. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44728. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44729. * @param activeCamera The camera we are returning the min for
  44730. * @returns the depth min z
  44731. */
  44732. getDepthMinZ(activeCamera: Camera): number;
  44733. /**
  44734. * Gets the maxZ used for shadow according to both the scene and the light.
  44735. *
  44736. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44737. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44738. * @param activeCamera The camera we are returning the max for
  44739. * @returns the depth max z
  44740. */
  44741. getDepthMaxZ(activeCamera: Camera): number;
  44742. /**
  44743. * Prepares the list of defines specific to the light type.
  44744. * @param defines the list of defines
  44745. * @param lightIndex defines the index of the light for the effect
  44746. */
  44747. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44748. }
  44749. }
  44750. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44751. import { Mesh } from "babylonjs/Meshes/mesh";
  44752. /**
  44753. * Class containing static functions to help procedurally build meshes
  44754. */
  44755. export class HemisphereBuilder {
  44756. /**
  44757. * Creates a hemisphere mesh
  44758. * @param name defines the name of the mesh
  44759. * @param options defines the options used to create the mesh
  44760. * @param scene defines the hosting scene
  44761. * @returns the hemisphere mesh
  44762. */
  44763. static CreateHemisphere(name: string, options: {
  44764. segments?: number;
  44765. diameter?: number;
  44766. sideOrientation?: number;
  44767. }, scene: any): Mesh;
  44768. }
  44769. }
  44770. declare module "babylonjs/Lights/spotLight" {
  44771. import { Nullable } from "babylonjs/types";
  44772. import { Scene } from "babylonjs/scene";
  44773. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44775. import { Effect } from "babylonjs/Materials/effect";
  44776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44777. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44778. /**
  44779. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44780. * These values define a cone of light starting from the position, emitting toward the direction.
  44781. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44782. * and the exponent defines the speed of the decay of the light with distance (reach).
  44783. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44784. */
  44785. export class SpotLight extends ShadowLight {
  44786. private _angle;
  44787. private _innerAngle;
  44788. private _cosHalfAngle;
  44789. private _lightAngleScale;
  44790. private _lightAngleOffset;
  44791. /**
  44792. * Gets the cone angle of the spot light in Radians.
  44793. */
  44794. /**
  44795. * Sets the cone angle of the spot light in Radians.
  44796. */
  44797. angle: number;
  44798. /**
  44799. * Only used in gltf falloff mode, this defines the angle where
  44800. * the directional falloff will start before cutting at angle which could be seen
  44801. * as outer angle.
  44802. */
  44803. /**
  44804. * Only used in gltf falloff mode, this defines the angle where
  44805. * the directional falloff will start before cutting at angle which could be seen
  44806. * as outer angle.
  44807. */
  44808. innerAngle: number;
  44809. private _shadowAngleScale;
  44810. /**
  44811. * Allows scaling the angle of the light for shadow generation only.
  44812. */
  44813. /**
  44814. * Allows scaling the angle of the light for shadow generation only.
  44815. */
  44816. shadowAngleScale: number;
  44817. /**
  44818. * The light decay speed with the distance from the emission spot.
  44819. */
  44820. exponent: number;
  44821. private _projectionTextureMatrix;
  44822. /**
  44823. * Allows reading the projecton texture
  44824. */
  44825. readonly projectionTextureMatrix: Matrix;
  44826. protected _projectionTextureLightNear: number;
  44827. /**
  44828. * Gets the near clip of the Spotlight for texture projection.
  44829. */
  44830. /**
  44831. * Sets the near clip of the Spotlight for texture projection.
  44832. */
  44833. projectionTextureLightNear: number;
  44834. protected _projectionTextureLightFar: number;
  44835. /**
  44836. * Gets the far clip of the Spotlight for texture projection.
  44837. */
  44838. /**
  44839. * Sets the far clip of the Spotlight for texture projection.
  44840. */
  44841. projectionTextureLightFar: number;
  44842. protected _projectionTextureUpDirection: Vector3;
  44843. /**
  44844. * Gets the Up vector of the Spotlight for texture projection.
  44845. */
  44846. /**
  44847. * Sets the Up vector of the Spotlight for texture projection.
  44848. */
  44849. projectionTextureUpDirection: Vector3;
  44850. private _projectionTexture;
  44851. /**
  44852. * Gets the projection texture of the light.
  44853. */
  44854. /**
  44855. * Sets the projection texture of the light.
  44856. */
  44857. projectionTexture: Nullable<BaseTexture>;
  44858. private _projectionTextureViewLightDirty;
  44859. private _projectionTextureProjectionLightDirty;
  44860. private _projectionTextureDirty;
  44861. private _projectionTextureViewTargetVector;
  44862. private _projectionTextureViewLightMatrix;
  44863. private _projectionTextureProjectionLightMatrix;
  44864. private _projectionTextureScalingMatrix;
  44865. /**
  44866. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44867. * It can cast shadows.
  44868. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44869. * @param name The light friendly name
  44870. * @param position The position of the spot light in the scene
  44871. * @param direction The direction of the light in the scene
  44872. * @param angle The cone angle of the light in Radians
  44873. * @param exponent The light decay speed with the distance from the emission spot
  44874. * @param scene The scene the lights belongs to
  44875. */
  44876. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44877. /**
  44878. * Returns the string "SpotLight".
  44879. * @returns the class name
  44880. */
  44881. getClassName(): string;
  44882. /**
  44883. * Returns the integer 2.
  44884. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44885. */
  44886. getTypeID(): number;
  44887. /**
  44888. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44889. */
  44890. protected _setDirection(value: Vector3): void;
  44891. /**
  44892. * Overrides the position setter to recompute the projection texture view light Matrix.
  44893. */
  44894. protected _setPosition(value: Vector3): void;
  44895. /**
  44896. * 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.
  44897. * Returns the SpotLight.
  44898. */
  44899. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44900. protected _computeProjectionTextureViewLightMatrix(): void;
  44901. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44902. /**
  44903. * Main function for light texture projection matrix computing.
  44904. */
  44905. protected _computeProjectionTextureMatrix(): void;
  44906. protected _buildUniformLayout(): void;
  44907. private _computeAngleValues;
  44908. /**
  44909. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44910. * @param effect The effect to update
  44911. * @param lightIndex The index of the light in the effect to update
  44912. * @returns The spot light
  44913. */
  44914. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44915. /**
  44916. * Disposes the light and the associated resources.
  44917. */
  44918. dispose(): void;
  44919. /**
  44920. * Prepares the list of defines specific to the light type.
  44921. * @param defines the list of defines
  44922. * @param lightIndex defines the index of the light for the effect
  44923. */
  44924. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44925. }
  44926. }
  44927. declare module "babylonjs/Gizmos/lightGizmo" {
  44928. import { Nullable } from "babylonjs/types";
  44929. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44930. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44931. import { Light } from "babylonjs/Lights/light";
  44932. /**
  44933. * Gizmo that enables viewing a light
  44934. */
  44935. export class LightGizmo extends Gizmo {
  44936. private _lightMesh;
  44937. private _material;
  44938. /**
  44939. * Creates a LightGizmo
  44940. * @param gizmoLayer The utility layer the gizmo will be added to
  44941. */
  44942. constructor(gizmoLayer?: UtilityLayerRenderer);
  44943. private _light;
  44944. /**
  44945. * The light that the gizmo is attached to
  44946. */
  44947. light: Nullable<Light>;
  44948. /**
  44949. * @hidden
  44950. * Updates the gizmo to match the attached mesh's position/rotation
  44951. */
  44952. protected _update(): void;
  44953. private static _Scale;
  44954. /**
  44955. * Creates the lines for a light mesh
  44956. */
  44957. private static _createLightLines;
  44958. private static _CreateHemisphericLightMesh;
  44959. private static _CreatePointLightMesh;
  44960. private static _CreateSpotLightMesh;
  44961. private static _CreateDirectionalLightMesh;
  44962. }
  44963. }
  44964. declare module "babylonjs/Gizmos/index" {
  44965. export * from "babylonjs/Gizmos/axisDragGizmo";
  44966. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44967. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44968. export * from "babylonjs/Gizmos/gizmo";
  44969. export * from "babylonjs/Gizmos/gizmoManager";
  44970. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44971. export * from "babylonjs/Gizmos/positionGizmo";
  44972. export * from "babylonjs/Gizmos/rotationGizmo";
  44973. export * from "babylonjs/Gizmos/scaleGizmo";
  44974. export * from "babylonjs/Gizmos/lightGizmo";
  44975. }
  44976. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44977. /** @hidden */
  44978. export var backgroundFragmentDeclaration: {
  44979. name: string;
  44980. shader: string;
  44981. };
  44982. }
  44983. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44984. /** @hidden */
  44985. export var backgroundUboDeclaration: {
  44986. name: string;
  44987. shader: string;
  44988. };
  44989. }
  44990. declare module "babylonjs/Shaders/background.fragment" {
  44991. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44992. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44993. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44994. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44995. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44996. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44997. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44998. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44999. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45000. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45001. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45002. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45003. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45004. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45005. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45006. /** @hidden */
  45007. export var backgroundPixelShader: {
  45008. name: string;
  45009. shader: string;
  45010. };
  45011. }
  45012. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45013. /** @hidden */
  45014. export var backgroundVertexDeclaration: {
  45015. name: string;
  45016. shader: string;
  45017. };
  45018. }
  45019. declare module "babylonjs/Shaders/background.vertex" {
  45020. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45021. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45022. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45023. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45024. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45025. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45026. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45027. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45028. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45029. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45030. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45031. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45032. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45033. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45034. /** @hidden */
  45035. export var backgroundVertexShader: {
  45036. name: string;
  45037. shader: string;
  45038. };
  45039. }
  45040. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45041. import { Nullable, int, float } from "babylonjs/types";
  45042. import { Scene } from "babylonjs/scene";
  45043. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45044. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45046. import { Mesh } from "babylonjs/Meshes/mesh";
  45047. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45048. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45049. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45050. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45051. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45052. import "babylonjs/Shaders/background.fragment";
  45053. import "babylonjs/Shaders/background.vertex";
  45054. /**
  45055. * Background material used to create an efficient environement around your scene.
  45056. */
  45057. export class BackgroundMaterial extends PushMaterial {
  45058. /**
  45059. * Standard reflectance value at parallel view angle.
  45060. */
  45061. static StandardReflectance0: number;
  45062. /**
  45063. * Standard reflectance value at grazing angle.
  45064. */
  45065. static StandardReflectance90: number;
  45066. protected _primaryColor: Color3;
  45067. /**
  45068. * Key light Color (multiply against the environement texture)
  45069. */
  45070. primaryColor: Color3;
  45071. protected __perceptualColor: Nullable<Color3>;
  45072. /**
  45073. * Experimental Internal Use Only.
  45074. *
  45075. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45076. * This acts as a helper to set the primary color to a more "human friendly" value.
  45077. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45078. * output color as close as possible from the chosen value.
  45079. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45080. * part of lighting setup.)
  45081. */
  45082. _perceptualColor: Nullable<Color3>;
  45083. protected _primaryColorShadowLevel: float;
  45084. /**
  45085. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45086. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45087. */
  45088. primaryColorShadowLevel: float;
  45089. protected _primaryColorHighlightLevel: float;
  45090. /**
  45091. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45092. * The primary color is used at the level chosen to define what the white area would look.
  45093. */
  45094. primaryColorHighlightLevel: float;
  45095. protected _reflectionTexture: Nullable<BaseTexture>;
  45096. /**
  45097. * Reflection Texture used in the material.
  45098. * Should be author in a specific way for the best result (refer to the documentation).
  45099. */
  45100. reflectionTexture: Nullable<BaseTexture>;
  45101. protected _reflectionBlur: float;
  45102. /**
  45103. * Reflection Texture level of blur.
  45104. *
  45105. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45106. * texture twice.
  45107. */
  45108. reflectionBlur: float;
  45109. protected _diffuseTexture: Nullable<BaseTexture>;
  45110. /**
  45111. * Diffuse Texture used in the material.
  45112. * Should be author in a specific way for the best result (refer to the documentation).
  45113. */
  45114. diffuseTexture: Nullable<BaseTexture>;
  45115. protected _shadowLights: Nullable<IShadowLight[]>;
  45116. /**
  45117. * Specify the list of lights casting shadow on the material.
  45118. * All scene shadow lights will be included if null.
  45119. */
  45120. shadowLights: Nullable<IShadowLight[]>;
  45121. protected _shadowLevel: float;
  45122. /**
  45123. * Helps adjusting the shadow to a softer level if required.
  45124. * 0 means black shadows and 1 means no shadows.
  45125. */
  45126. shadowLevel: float;
  45127. protected _sceneCenter: Vector3;
  45128. /**
  45129. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45130. * It is usually zero but might be interesting to modify according to your setup.
  45131. */
  45132. sceneCenter: Vector3;
  45133. protected _opacityFresnel: boolean;
  45134. /**
  45135. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45136. * This helps ensuring a nice transition when the camera goes under the ground.
  45137. */
  45138. opacityFresnel: boolean;
  45139. protected _reflectionFresnel: boolean;
  45140. /**
  45141. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45142. * This helps adding a mirror texture on the ground.
  45143. */
  45144. reflectionFresnel: boolean;
  45145. protected _reflectionFalloffDistance: number;
  45146. /**
  45147. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45148. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45149. */
  45150. reflectionFalloffDistance: number;
  45151. protected _reflectionAmount: number;
  45152. /**
  45153. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45154. */
  45155. reflectionAmount: number;
  45156. protected _reflectionReflectance0: number;
  45157. /**
  45158. * This specifies the weight of the reflection at grazing angle.
  45159. */
  45160. reflectionReflectance0: number;
  45161. protected _reflectionReflectance90: number;
  45162. /**
  45163. * This specifies the weight of the reflection at a perpendicular point of view.
  45164. */
  45165. reflectionReflectance90: number;
  45166. /**
  45167. * Sets the reflection reflectance fresnel values according to the default standard
  45168. * empirically know to work well :-)
  45169. */
  45170. reflectionStandardFresnelWeight: number;
  45171. protected _useRGBColor: boolean;
  45172. /**
  45173. * Helps to directly use the maps channels instead of their level.
  45174. */
  45175. useRGBColor: boolean;
  45176. protected _enableNoise: boolean;
  45177. /**
  45178. * This helps reducing the banding effect that could occur on the background.
  45179. */
  45180. enableNoise: boolean;
  45181. /**
  45182. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45183. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45184. * Recommended to be keep at 1.0 except for special cases.
  45185. */
  45186. fovMultiplier: number;
  45187. private _fovMultiplier;
  45188. /**
  45189. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45190. */
  45191. useEquirectangularFOV: boolean;
  45192. private _maxSimultaneousLights;
  45193. /**
  45194. * Number of Simultaneous lights allowed on the material.
  45195. */
  45196. maxSimultaneousLights: int;
  45197. /**
  45198. * Default configuration related to image processing available in the Background Material.
  45199. */
  45200. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45201. /**
  45202. * Keep track of the image processing observer to allow dispose and replace.
  45203. */
  45204. private _imageProcessingObserver;
  45205. /**
  45206. * Attaches a new image processing configuration to the PBR Material.
  45207. * @param configuration (if null the scene configuration will be use)
  45208. */
  45209. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45210. /**
  45211. * Gets the image processing configuration used either in this material.
  45212. */
  45213. /**
  45214. * Sets the Default image processing configuration used either in the this material.
  45215. *
  45216. * If sets to null, the scene one is in use.
  45217. */
  45218. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45219. /**
  45220. * Gets wether the color curves effect is enabled.
  45221. */
  45222. /**
  45223. * Sets wether the color curves effect is enabled.
  45224. */
  45225. cameraColorCurvesEnabled: boolean;
  45226. /**
  45227. * Gets wether the color grading effect is enabled.
  45228. */
  45229. /**
  45230. * Gets wether the color grading effect is enabled.
  45231. */
  45232. cameraColorGradingEnabled: boolean;
  45233. /**
  45234. * Gets wether tonemapping is enabled or not.
  45235. */
  45236. /**
  45237. * Sets wether tonemapping is enabled or not
  45238. */
  45239. cameraToneMappingEnabled: boolean;
  45240. /**
  45241. * The camera exposure used on this material.
  45242. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45243. * This corresponds to a photographic exposure.
  45244. */
  45245. /**
  45246. * The camera exposure used on this material.
  45247. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45248. * This corresponds to a photographic exposure.
  45249. */
  45250. cameraExposure: float;
  45251. /**
  45252. * Gets The camera contrast used on this material.
  45253. */
  45254. /**
  45255. * Sets The camera contrast used on this material.
  45256. */
  45257. cameraContrast: float;
  45258. /**
  45259. * Gets the Color Grading 2D Lookup Texture.
  45260. */
  45261. /**
  45262. * Sets the Color Grading 2D Lookup Texture.
  45263. */
  45264. cameraColorGradingTexture: Nullable<BaseTexture>;
  45265. /**
  45266. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45267. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45268. * 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;
  45269. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45270. */
  45271. /**
  45272. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45273. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45274. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  45275. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45276. */
  45277. cameraColorCurves: Nullable<ColorCurves>;
  45278. /**
  45279. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45280. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45281. */
  45282. switchToBGR: boolean;
  45283. private _renderTargets;
  45284. private _reflectionControls;
  45285. private _white;
  45286. private _primaryShadowColor;
  45287. private _primaryHighlightColor;
  45288. /**
  45289. * Instantiates a Background Material in the given scene
  45290. * @param name The friendly name of the material
  45291. * @param scene The scene to add the material to
  45292. */
  45293. constructor(name: string, scene: Scene);
  45294. /**
  45295. * Gets a boolean indicating that current material needs to register RTT
  45296. */
  45297. readonly hasRenderTargetTextures: boolean;
  45298. /**
  45299. * The entire material has been created in order to prevent overdraw.
  45300. * @returns false
  45301. */
  45302. needAlphaTesting(): boolean;
  45303. /**
  45304. * The entire material has been created in order to prevent overdraw.
  45305. * @returns true if blending is enable
  45306. */
  45307. needAlphaBlending(): boolean;
  45308. /**
  45309. * Checks wether the material is ready to be rendered for a given mesh.
  45310. * @param mesh The mesh to render
  45311. * @param subMesh The submesh to check against
  45312. * @param useInstances Specify wether or not the material is used with instances
  45313. * @returns true if all the dependencies are ready (Textures, Effects...)
  45314. */
  45315. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45316. /**
  45317. * Compute the primary color according to the chosen perceptual color.
  45318. */
  45319. private _computePrimaryColorFromPerceptualColor;
  45320. /**
  45321. * Compute the highlights and shadow colors according to their chosen levels.
  45322. */
  45323. private _computePrimaryColors;
  45324. /**
  45325. * Build the uniform buffer used in the material.
  45326. */
  45327. buildUniformLayout(): void;
  45328. /**
  45329. * Unbind the material.
  45330. */
  45331. unbind(): void;
  45332. /**
  45333. * Bind only the world matrix to the material.
  45334. * @param world The world matrix to bind.
  45335. */
  45336. bindOnlyWorldMatrix(world: Matrix): void;
  45337. /**
  45338. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45339. * @param world The world matrix to bind.
  45340. * @param subMesh The submesh to bind for.
  45341. */
  45342. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45343. /**
  45344. * Dispose the material.
  45345. * @param forceDisposeEffect Force disposal of the associated effect.
  45346. * @param forceDisposeTextures Force disposal of the associated textures.
  45347. */
  45348. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45349. /**
  45350. * Clones the material.
  45351. * @param name The cloned name.
  45352. * @returns The cloned material.
  45353. */
  45354. clone(name: string): BackgroundMaterial;
  45355. /**
  45356. * Serializes the current material to its JSON representation.
  45357. * @returns The JSON representation.
  45358. */
  45359. serialize(): any;
  45360. /**
  45361. * Gets the class name of the material
  45362. * @returns "BackgroundMaterial"
  45363. */
  45364. getClassName(): string;
  45365. /**
  45366. * Parse a JSON input to create back a background material.
  45367. * @param source The JSON data to parse
  45368. * @param scene The scene to create the parsed material in
  45369. * @param rootUrl The root url of the assets the material depends upon
  45370. * @returns the instantiated BackgroundMaterial.
  45371. */
  45372. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45373. }
  45374. }
  45375. declare module "babylonjs/Helpers/environmentHelper" {
  45376. import { Observable } from "babylonjs/Misc/observable";
  45377. import { Nullable } from "babylonjs/types";
  45378. import { Scene } from "babylonjs/scene";
  45379. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45381. import { Mesh } from "babylonjs/Meshes/mesh";
  45382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45383. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45384. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45385. import "babylonjs/Meshes/Builders/planeBuilder";
  45386. import "babylonjs/Meshes/Builders/boxBuilder";
  45387. /**
  45388. * Represents the different options available during the creation of
  45389. * a Environment helper.
  45390. *
  45391. * This can control the default ground, skybox and image processing setup of your scene.
  45392. */
  45393. export interface IEnvironmentHelperOptions {
  45394. /**
  45395. * Specifies wether or not to create a ground.
  45396. * True by default.
  45397. */
  45398. createGround: boolean;
  45399. /**
  45400. * Specifies the ground size.
  45401. * 15 by default.
  45402. */
  45403. groundSize: number;
  45404. /**
  45405. * The texture used on the ground for the main color.
  45406. * Comes from the BabylonJS CDN by default.
  45407. *
  45408. * Remarks: Can be either a texture or a url.
  45409. */
  45410. groundTexture: string | BaseTexture;
  45411. /**
  45412. * The color mixed in the ground texture by default.
  45413. * BabylonJS clearColor by default.
  45414. */
  45415. groundColor: Color3;
  45416. /**
  45417. * Specifies the ground opacity.
  45418. * 1 by default.
  45419. */
  45420. groundOpacity: number;
  45421. /**
  45422. * Enables the ground to receive shadows.
  45423. * True by default.
  45424. */
  45425. enableGroundShadow: boolean;
  45426. /**
  45427. * Helps preventing the shadow to be fully black on the ground.
  45428. * 0.5 by default.
  45429. */
  45430. groundShadowLevel: number;
  45431. /**
  45432. * Creates a mirror texture attach to the ground.
  45433. * false by default.
  45434. */
  45435. enableGroundMirror: boolean;
  45436. /**
  45437. * Specifies the ground mirror size ratio.
  45438. * 0.3 by default as the default kernel is 64.
  45439. */
  45440. groundMirrorSizeRatio: number;
  45441. /**
  45442. * Specifies the ground mirror blur kernel size.
  45443. * 64 by default.
  45444. */
  45445. groundMirrorBlurKernel: number;
  45446. /**
  45447. * Specifies the ground mirror visibility amount.
  45448. * 1 by default
  45449. */
  45450. groundMirrorAmount: number;
  45451. /**
  45452. * Specifies the ground mirror reflectance weight.
  45453. * This uses the standard weight of the background material to setup the fresnel effect
  45454. * of the mirror.
  45455. * 1 by default.
  45456. */
  45457. groundMirrorFresnelWeight: number;
  45458. /**
  45459. * Specifies the ground mirror Falloff distance.
  45460. * This can helps reducing the size of the reflection.
  45461. * 0 by Default.
  45462. */
  45463. groundMirrorFallOffDistance: number;
  45464. /**
  45465. * Specifies the ground mirror texture type.
  45466. * Unsigned Int by Default.
  45467. */
  45468. groundMirrorTextureType: number;
  45469. /**
  45470. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45471. * the shown objects.
  45472. */
  45473. groundYBias: number;
  45474. /**
  45475. * Specifies wether or not to create a skybox.
  45476. * True by default.
  45477. */
  45478. createSkybox: boolean;
  45479. /**
  45480. * Specifies the skybox size.
  45481. * 20 by default.
  45482. */
  45483. skyboxSize: number;
  45484. /**
  45485. * The texture used on the skybox for the main color.
  45486. * Comes from the BabylonJS CDN by default.
  45487. *
  45488. * Remarks: Can be either a texture or a url.
  45489. */
  45490. skyboxTexture: string | BaseTexture;
  45491. /**
  45492. * The color mixed in the skybox texture by default.
  45493. * BabylonJS clearColor by default.
  45494. */
  45495. skyboxColor: Color3;
  45496. /**
  45497. * The background rotation around the Y axis of the scene.
  45498. * This helps aligning the key lights of your scene with the background.
  45499. * 0 by default.
  45500. */
  45501. backgroundYRotation: number;
  45502. /**
  45503. * Compute automatically the size of the elements to best fit with the scene.
  45504. */
  45505. sizeAuto: boolean;
  45506. /**
  45507. * Default position of the rootMesh if autoSize is not true.
  45508. */
  45509. rootPosition: Vector3;
  45510. /**
  45511. * Sets up the image processing in the scene.
  45512. * true by default.
  45513. */
  45514. setupImageProcessing: boolean;
  45515. /**
  45516. * The texture used as your environment texture in the scene.
  45517. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45518. *
  45519. * Remarks: Can be either a texture or a url.
  45520. */
  45521. environmentTexture: string | BaseTexture;
  45522. /**
  45523. * The value of the exposure to apply to the scene.
  45524. * 0.6 by default if setupImageProcessing is true.
  45525. */
  45526. cameraExposure: number;
  45527. /**
  45528. * The value of the contrast to apply to the scene.
  45529. * 1.6 by default if setupImageProcessing is true.
  45530. */
  45531. cameraContrast: number;
  45532. /**
  45533. * Specifies wether or not tonemapping should be enabled in the scene.
  45534. * true by default if setupImageProcessing is true.
  45535. */
  45536. toneMappingEnabled: boolean;
  45537. }
  45538. /**
  45539. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45540. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45541. * It also helps with the default setup of your imageProcessing configuration.
  45542. */
  45543. export class EnvironmentHelper {
  45544. /**
  45545. * Default ground texture URL.
  45546. */
  45547. private static _groundTextureCDNUrl;
  45548. /**
  45549. * Default skybox texture URL.
  45550. */
  45551. private static _skyboxTextureCDNUrl;
  45552. /**
  45553. * Default environment texture URL.
  45554. */
  45555. private static _environmentTextureCDNUrl;
  45556. /**
  45557. * Creates the default options for the helper.
  45558. */
  45559. private static _getDefaultOptions;
  45560. private _rootMesh;
  45561. /**
  45562. * Gets the root mesh created by the helper.
  45563. */
  45564. readonly rootMesh: Mesh;
  45565. private _skybox;
  45566. /**
  45567. * Gets the skybox created by the helper.
  45568. */
  45569. readonly skybox: Nullable<Mesh>;
  45570. private _skyboxTexture;
  45571. /**
  45572. * Gets the skybox texture created by the helper.
  45573. */
  45574. readonly skyboxTexture: Nullable<BaseTexture>;
  45575. private _skyboxMaterial;
  45576. /**
  45577. * Gets the skybox material created by the helper.
  45578. */
  45579. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45580. private _ground;
  45581. /**
  45582. * Gets the ground mesh created by the helper.
  45583. */
  45584. readonly ground: Nullable<Mesh>;
  45585. private _groundTexture;
  45586. /**
  45587. * Gets the ground texture created by the helper.
  45588. */
  45589. readonly groundTexture: Nullable<BaseTexture>;
  45590. private _groundMirror;
  45591. /**
  45592. * Gets the ground mirror created by the helper.
  45593. */
  45594. readonly groundMirror: Nullable<MirrorTexture>;
  45595. /**
  45596. * Gets the ground mirror render list to helps pushing the meshes
  45597. * you wish in the ground reflection.
  45598. */
  45599. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45600. private _groundMaterial;
  45601. /**
  45602. * Gets the ground material created by the helper.
  45603. */
  45604. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45605. /**
  45606. * Stores the creation options.
  45607. */
  45608. private readonly _scene;
  45609. private _options;
  45610. /**
  45611. * This observable will be notified with any error during the creation of the environment,
  45612. * mainly texture creation errors.
  45613. */
  45614. onErrorObservable: Observable<{
  45615. message?: string;
  45616. exception?: any;
  45617. }>;
  45618. /**
  45619. * constructor
  45620. * @param options Defines the options we want to customize the helper
  45621. * @param scene The scene to add the material to
  45622. */
  45623. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45624. /**
  45625. * Updates the background according to the new options
  45626. * @param options
  45627. */
  45628. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45629. /**
  45630. * Sets the primary color of all the available elements.
  45631. * @param color the main color to affect to the ground and the background
  45632. */
  45633. setMainColor(color: Color3): void;
  45634. /**
  45635. * Setup the image processing according to the specified options.
  45636. */
  45637. private _setupImageProcessing;
  45638. /**
  45639. * Setup the environment texture according to the specified options.
  45640. */
  45641. private _setupEnvironmentTexture;
  45642. /**
  45643. * Setup the background according to the specified options.
  45644. */
  45645. private _setupBackground;
  45646. /**
  45647. * Get the scene sizes according to the setup.
  45648. */
  45649. private _getSceneSize;
  45650. /**
  45651. * Setup the ground according to the specified options.
  45652. */
  45653. private _setupGround;
  45654. /**
  45655. * Setup the ground material according to the specified options.
  45656. */
  45657. private _setupGroundMaterial;
  45658. /**
  45659. * Setup the ground diffuse texture according to the specified options.
  45660. */
  45661. private _setupGroundDiffuseTexture;
  45662. /**
  45663. * Setup the ground mirror texture according to the specified options.
  45664. */
  45665. private _setupGroundMirrorTexture;
  45666. /**
  45667. * Setup the ground to receive the mirror texture.
  45668. */
  45669. private _setupMirrorInGroundMaterial;
  45670. /**
  45671. * Setup the skybox according to the specified options.
  45672. */
  45673. private _setupSkybox;
  45674. /**
  45675. * Setup the skybox material according to the specified options.
  45676. */
  45677. private _setupSkyboxMaterial;
  45678. /**
  45679. * Setup the skybox reflection texture according to the specified options.
  45680. */
  45681. private _setupSkyboxReflectionTexture;
  45682. private _errorHandler;
  45683. /**
  45684. * Dispose all the elements created by the Helper.
  45685. */
  45686. dispose(): void;
  45687. }
  45688. }
  45689. declare module "babylonjs/Helpers/photoDome" {
  45690. import { Observable } from "babylonjs/Misc/observable";
  45691. import { Nullable } from "babylonjs/types";
  45692. import { Scene } from "babylonjs/scene";
  45693. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45694. import { Mesh } from "babylonjs/Meshes/mesh";
  45695. import { Texture } from "babylonjs/Materials/Textures/texture";
  45696. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45697. import "babylonjs/Meshes/Builders/sphereBuilder";
  45698. /**
  45699. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45700. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45701. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45702. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45703. */
  45704. export class PhotoDome extends TransformNode {
  45705. private _useDirectMapping;
  45706. /**
  45707. * The texture being displayed on the sphere
  45708. */
  45709. protected _photoTexture: Texture;
  45710. /**
  45711. * Gets or sets the texture being displayed on the sphere
  45712. */
  45713. photoTexture: Texture;
  45714. /**
  45715. * Observable raised when an error occured while loading the 360 image
  45716. */
  45717. onLoadErrorObservable: Observable<string>;
  45718. /**
  45719. * The skybox material
  45720. */
  45721. protected _material: BackgroundMaterial;
  45722. /**
  45723. * The surface used for the skybox
  45724. */
  45725. protected _mesh: Mesh;
  45726. /**
  45727. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45728. * Also see the options.resolution property.
  45729. */
  45730. fovMultiplier: number;
  45731. /**
  45732. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45733. * @param name Element's name, child elements will append suffixes for their own names.
  45734. * @param urlsOfPhoto defines the url of the photo to display
  45735. * @param options defines an object containing optional or exposed sub element properties
  45736. * @param onError defines a callback called when an error occured while loading the texture
  45737. */
  45738. constructor(name: string, urlOfPhoto: string, options: {
  45739. resolution?: number;
  45740. size?: number;
  45741. useDirectMapping?: boolean;
  45742. faceForward?: boolean;
  45743. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45744. /**
  45745. * Releases resources associated with this node.
  45746. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45747. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45748. */
  45749. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45750. }
  45751. }
  45752. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45753. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45754. /** @hidden */
  45755. export var rgbdDecodePixelShader: {
  45756. name: string;
  45757. shader: string;
  45758. };
  45759. }
  45760. declare module "babylonjs/Misc/brdfTextureTools" {
  45761. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45762. import { Scene } from "babylonjs/scene";
  45763. import "babylonjs/Shaders/rgbdDecode.fragment";
  45764. /**
  45765. * Class used to host texture specific utilities
  45766. */
  45767. export class BRDFTextureTools {
  45768. /**
  45769. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45770. * @param texture the texture to expand.
  45771. */
  45772. private static _ExpandDefaultBRDFTexture;
  45773. /**
  45774. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45775. * @param scene defines the hosting scene
  45776. * @returns the environment BRDF texture
  45777. */
  45778. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45779. private static _environmentBRDFBase64Texture;
  45780. }
  45781. }
  45782. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45783. import { Nullable } from "babylonjs/types";
  45784. import { IAnimatable } from "babylonjs/Misc/tools";
  45785. import { Color3 } from "babylonjs/Maths/math";
  45786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45787. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45788. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45789. import { Engine } from "babylonjs/Engines/engine";
  45790. import { Scene } from "babylonjs/scene";
  45791. /**
  45792. * @hidden
  45793. */
  45794. export interface IMaterialClearCoatDefines {
  45795. CLEARCOAT: boolean;
  45796. CLEARCOAT_DEFAULTIOR: boolean;
  45797. CLEARCOAT_TEXTURE: boolean;
  45798. CLEARCOAT_TEXTUREDIRECTUV: number;
  45799. CLEARCOAT_BUMP: boolean;
  45800. CLEARCOAT_BUMPDIRECTUV: number;
  45801. CLEARCOAT_TINT: boolean;
  45802. CLEARCOAT_TINT_TEXTURE: boolean;
  45803. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45804. /** @hidden */
  45805. _areTexturesDirty: boolean;
  45806. }
  45807. /**
  45808. * Define the code related to the clear coat parameters of the pbr material.
  45809. */
  45810. export class PBRClearCoatConfiguration {
  45811. /**
  45812. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45813. * The default fits with a polyurethane material.
  45814. */
  45815. private static readonly _DefaultIndiceOfRefraction;
  45816. private _isEnabled;
  45817. /**
  45818. * Defines if the clear coat is enabled in the material.
  45819. */
  45820. isEnabled: boolean;
  45821. /**
  45822. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45823. */
  45824. intensity: number;
  45825. /**
  45826. * Defines the clear coat layer roughness.
  45827. */
  45828. roughness: number;
  45829. private _indiceOfRefraction;
  45830. /**
  45831. * Defines the indice of refraction of the clear coat.
  45832. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45833. * The default fits with a polyurethane material.
  45834. * Changing the default value is more performance intensive.
  45835. */
  45836. indiceOfRefraction: number;
  45837. private _texture;
  45838. /**
  45839. * Stores the clear coat values in a texture.
  45840. */
  45841. texture: Nullable<BaseTexture>;
  45842. private _bumpTexture;
  45843. /**
  45844. * Define the clear coat specific bump texture.
  45845. */
  45846. bumpTexture: Nullable<BaseTexture>;
  45847. private _isTintEnabled;
  45848. /**
  45849. * Defines if the clear coat tint is enabled in the material.
  45850. */
  45851. isTintEnabled: boolean;
  45852. /**
  45853. * Defines the clear coat tint of the material.
  45854. * This is only use if tint is enabled
  45855. */
  45856. tintColor: Color3;
  45857. /**
  45858. * Defines the distance at which the tint color should be found in the
  45859. * clear coat media.
  45860. * This is only use if tint is enabled
  45861. */
  45862. tintColorAtDistance: number;
  45863. /**
  45864. * Defines the clear coat layer thickness.
  45865. * This is only use if tint is enabled
  45866. */
  45867. tintThickness: number;
  45868. private _tintTexture;
  45869. /**
  45870. * Stores the clear tint values in a texture.
  45871. * rgb is tint
  45872. * a is a thickness factor
  45873. */
  45874. tintTexture: Nullable<BaseTexture>;
  45875. /** @hidden */
  45876. private _internalMarkAllSubMeshesAsTexturesDirty;
  45877. /** @hidden */
  45878. _markAllSubMeshesAsTexturesDirty(): void;
  45879. /**
  45880. * Instantiate a new istance of clear coat configuration.
  45881. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45882. */
  45883. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45884. /**
  45885. * Gets wehter the submesh is ready to be used or not.
  45886. * @param defines the list of "defines" to update.
  45887. * @param scene defines the scene the material belongs to.
  45888. * @param engine defines the engine the material belongs to.
  45889. * @param disableBumpMap defines wether the material disables bump or not.
  45890. * @returns - boolean indicating that the submesh is ready or not.
  45891. */
  45892. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45893. /**
  45894. * Checks to see if a texture is used in the material.
  45895. * @param defines the list of "defines" to update.
  45896. * @param scene defines the scene to the material belongs to.
  45897. */
  45898. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45899. /**
  45900. * Binds the material data.
  45901. * @param uniformBuffer defines the Uniform buffer to fill in.
  45902. * @param scene defines the scene the material belongs to.
  45903. * @param engine defines the engine the material belongs to.
  45904. * @param disableBumpMap defines wether the material disables bump or not.
  45905. * @param isFrozen defines wether the material is frozen or not.
  45906. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45907. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45908. */
  45909. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45910. /**
  45911. * Checks to see if a texture is used in the material.
  45912. * @param texture - Base texture to use.
  45913. * @returns - Boolean specifying if a texture is used in the material.
  45914. */
  45915. hasTexture(texture: BaseTexture): boolean;
  45916. /**
  45917. * Returns an array of the actively used textures.
  45918. * @param activeTextures Array of BaseTextures
  45919. */
  45920. getActiveTextures(activeTextures: BaseTexture[]): void;
  45921. /**
  45922. * Returns the animatable textures.
  45923. * @param animatables Array of animatable textures.
  45924. */
  45925. getAnimatables(animatables: IAnimatable[]): void;
  45926. /**
  45927. * Disposes the resources of the material.
  45928. * @param forceDisposeTextures - Forces the disposal of all textures.
  45929. */
  45930. dispose(forceDisposeTextures?: boolean): void;
  45931. /**
  45932. * Get the current class name of the texture useful for serialization or dynamic coding.
  45933. * @returns "PBRClearCoatConfiguration"
  45934. */
  45935. getClassName(): string;
  45936. /**
  45937. * Add fallbacks to the effect fallbacks list.
  45938. * @param defines defines the Base texture to use.
  45939. * @param fallbacks defines the current fallback list.
  45940. * @param currentRank defines the current fallback rank.
  45941. * @returns the new fallback rank.
  45942. */
  45943. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45944. /**
  45945. * Add the required uniforms to the current list.
  45946. * @param uniforms defines the current uniform list.
  45947. */
  45948. static AddUniforms(uniforms: string[]): void;
  45949. /**
  45950. * Add the required samplers to the current list.
  45951. * @param samplers defines the current sampler list.
  45952. */
  45953. static AddSamplers(samplers: string[]): void;
  45954. /**
  45955. * Add the required uniforms to the current buffer.
  45956. * @param uniformBuffer defines the current uniform buffer.
  45957. */
  45958. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45959. /**
  45960. * Makes a duplicate of the current configuration into another one.
  45961. * @param clearCoatConfiguration define the config where to copy the info
  45962. */
  45963. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45964. /**
  45965. * Serializes this clear coat configuration.
  45966. * @returns - An object with the serialized config.
  45967. */
  45968. serialize(): any;
  45969. /**
  45970. * Parses a Clear Coat Configuration from a serialized object.
  45971. * @param source - Serialized object.
  45972. */
  45973. parse(source: any): void;
  45974. }
  45975. }
  45976. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45977. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45978. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45980. import { Vector2 } from "babylonjs/Maths/math";
  45981. import { Scene } from "babylonjs/scene";
  45982. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45983. import { IAnimatable } from "babylonjs/Misc/tools";
  45984. import { Nullable } from "babylonjs/types";
  45985. /**
  45986. * @hidden
  45987. */
  45988. export interface IMaterialAnisotropicDefines {
  45989. ANISOTROPIC: boolean;
  45990. ANISOTROPIC_TEXTURE: boolean;
  45991. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45992. MAINUV1: boolean;
  45993. _areTexturesDirty: boolean;
  45994. _needUVs: boolean;
  45995. }
  45996. /**
  45997. * Define the code related to the anisotropic parameters of the pbr material.
  45998. */
  45999. export class PBRAnisotropicConfiguration {
  46000. private _isEnabled;
  46001. /**
  46002. * Defines if the anisotropy is enabled in the material.
  46003. */
  46004. isEnabled: boolean;
  46005. /**
  46006. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46007. */
  46008. intensity: number;
  46009. /**
  46010. * Defines if the effect is along the tangents, bitangents or in between.
  46011. * By default, the effect is "strectching" the highlights along the tangents.
  46012. */
  46013. direction: Vector2;
  46014. private _texture;
  46015. /**
  46016. * Stores the anisotropy values in a texture.
  46017. * rg is direction (like normal from -1 to 1)
  46018. * b is a intensity
  46019. */
  46020. texture: Nullable<BaseTexture>;
  46021. /** @hidden */
  46022. private _internalMarkAllSubMeshesAsTexturesDirty;
  46023. /** @hidden */
  46024. _markAllSubMeshesAsTexturesDirty(): void;
  46025. /**
  46026. * Instantiate a new istance of anisotropy configuration.
  46027. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46028. */
  46029. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46030. /**
  46031. * Specifies that the submesh is ready to be used.
  46032. * @param defines the list of "defines" to update.
  46033. * @param scene defines the scene the material belongs to.
  46034. * @returns - boolean indicating that the submesh is ready or not.
  46035. */
  46036. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46037. /**
  46038. * Checks to see if a texture is used in the material.
  46039. * @param defines the list of "defines" to update.
  46040. * @param mesh the mesh we are preparing the defines for.
  46041. * @param scene defines the scene the material belongs to.
  46042. */
  46043. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46044. /**
  46045. * Binds the material data.
  46046. * @param uniformBuffer defines the Uniform buffer to fill in.
  46047. * @param scene defines the scene the material belongs to.
  46048. * @param isFrozen defines wether the material is frozen or not.
  46049. */
  46050. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46051. /**
  46052. * Checks to see if a texture is used in the material.
  46053. * @param texture - Base texture to use.
  46054. * @returns - Boolean specifying if a texture is used in the material.
  46055. */
  46056. hasTexture(texture: BaseTexture): boolean;
  46057. /**
  46058. * Returns an array of the actively used textures.
  46059. * @param activeTextures Array of BaseTextures
  46060. */
  46061. getActiveTextures(activeTextures: BaseTexture[]): void;
  46062. /**
  46063. * Returns the animatable textures.
  46064. * @param animatables Array of animatable textures.
  46065. */
  46066. getAnimatables(animatables: IAnimatable[]): void;
  46067. /**
  46068. * Disposes the resources of the material.
  46069. * @param forceDisposeTextures - Forces the disposal of all textures.
  46070. */
  46071. dispose(forceDisposeTextures?: boolean): void;
  46072. /**
  46073. * Get the current class name of the texture useful for serialization or dynamic coding.
  46074. * @returns "PBRAnisotropicConfiguration"
  46075. */
  46076. getClassName(): string;
  46077. /**
  46078. * Add fallbacks to the effect fallbacks list.
  46079. * @param defines defines the Base texture to use.
  46080. * @param fallbacks defines the current fallback list.
  46081. * @param currentRank defines the current fallback rank.
  46082. * @returns the new fallback rank.
  46083. */
  46084. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46085. /**
  46086. * Add the required uniforms to the current list.
  46087. * @param uniforms defines the current uniform list.
  46088. */
  46089. static AddUniforms(uniforms: string[]): void;
  46090. /**
  46091. * Add the required uniforms to the current buffer.
  46092. * @param uniformBuffer defines the current uniform buffer.
  46093. */
  46094. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46095. /**
  46096. * Add the required samplers to the current list.
  46097. * @param samplers defines the current sampler list.
  46098. */
  46099. static AddSamplers(samplers: string[]): void;
  46100. /**
  46101. * Makes a duplicate of the current configuration into another one.
  46102. * @param anisotropicConfiguration define the config where to copy the info
  46103. */
  46104. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46105. /**
  46106. * Serializes this anisotropy configuration.
  46107. * @returns - An object with the serialized config.
  46108. */
  46109. serialize(): any;
  46110. /**
  46111. * Parses a anisotropy Configuration from a serialized object.
  46112. * @param source - Serialized object.
  46113. */
  46114. parse(source: any): void;
  46115. }
  46116. }
  46117. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46118. /**
  46119. * @hidden
  46120. */
  46121. export interface IMaterialBRDFDefines {
  46122. BRDF_V_HEIGHT_CORRELATED: boolean;
  46123. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46124. SPHERICAL_HARMONICS: boolean;
  46125. /** @hidden */
  46126. _areMiscDirty: boolean;
  46127. }
  46128. /**
  46129. * Define the code related to the BRDF parameters of the pbr material.
  46130. */
  46131. export class PBRBRDFConfiguration {
  46132. /**
  46133. * Default value used for the energy conservation.
  46134. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46135. */
  46136. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46137. /**
  46138. * Default value used for the Smith Visibility Height Correlated mode.
  46139. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46140. */
  46141. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46142. /**
  46143. * Default value used for the IBL diffuse part.
  46144. * This can help switching back to the polynomials mode globally which is a tiny bit
  46145. * less GPU intensive at the drawback of a lower quality.
  46146. */
  46147. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46148. private _useEnergyConservation;
  46149. /**
  46150. * Defines if the material uses energy conservation.
  46151. */
  46152. useEnergyConservation: boolean;
  46153. private _useSmithVisibilityHeightCorrelated;
  46154. /**
  46155. * LEGACY Mode set to false
  46156. * Defines if the material uses height smith correlated visibility term.
  46157. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46158. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46159. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46160. * Not relying on height correlated will also disable energy conservation.
  46161. */
  46162. useSmithVisibilityHeightCorrelated: boolean;
  46163. private _useSphericalHarmonics;
  46164. /**
  46165. * LEGACY Mode set to false
  46166. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46167. * diffuse part of the IBL.
  46168. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46169. * to the ground truth.
  46170. */
  46171. useSphericalHarmonics: boolean;
  46172. /** @hidden */
  46173. private _internalMarkAllSubMeshesAsMiscDirty;
  46174. /** @hidden */
  46175. _markAllSubMeshesAsMiscDirty(): void;
  46176. /**
  46177. * Instantiate a new istance of clear coat configuration.
  46178. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46179. */
  46180. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46181. /**
  46182. * Checks to see if a texture is used in the material.
  46183. * @param defines the list of "defines" to update.
  46184. */
  46185. prepareDefines(defines: IMaterialBRDFDefines): void;
  46186. /**
  46187. * Get the current class name of the texture useful for serialization or dynamic coding.
  46188. * @returns "PBRClearCoatConfiguration"
  46189. */
  46190. getClassName(): string;
  46191. /**
  46192. * Makes a duplicate of the current configuration into another one.
  46193. * @param brdfConfiguration define the config where to copy the info
  46194. */
  46195. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46196. /**
  46197. * Serializes this BRDF configuration.
  46198. * @returns - An object with the serialized config.
  46199. */
  46200. serialize(): any;
  46201. /**
  46202. * Parses a BRDF Configuration from a serialized object.
  46203. * @param source - Serialized object.
  46204. */
  46205. parse(source: any): void;
  46206. }
  46207. }
  46208. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46209. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46210. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46211. import { Color3 } from "babylonjs/Maths/math";
  46212. import { Scene } from "babylonjs/scene";
  46213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46214. import { IAnimatable } from "babylonjs/Misc/tools";
  46215. import { Nullable } from "babylonjs/types";
  46216. /**
  46217. * @hidden
  46218. */
  46219. export interface IMaterialSheenDefines {
  46220. SHEEN: boolean;
  46221. SHEEN_TEXTURE: boolean;
  46222. SHEEN_TEXTUREDIRECTUV: number;
  46223. SHEEN_LINKWITHALBEDO: boolean;
  46224. /** @hidden */
  46225. _areTexturesDirty: boolean;
  46226. }
  46227. /**
  46228. * Define the code related to the Sheen parameters of the pbr material.
  46229. */
  46230. export class PBRSheenConfiguration {
  46231. private _isEnabled;
  46232. /**
  46233. * Defines if the material uses sheen.
  46234. */
  46235. isEnabled: boolean;
  46236. private _linkSheenWithAlbedo;
  46237. /**
  46238. * Defines if the sheen is linked to the sheen color.
  46239. */
  46240. linkSheenWithAlbedo: boolean;
  46241. /**
  46242. * Defines the sheen intensity.
  46243. */
  46244. intensity: number;
  46245. /**
  46246. * Defines the sheen color.
  46247. */
  46248. color: Color3;
  46249. private _texture;
  46250. /**
  46251. * Stores the sheen tint values in a texture.
  46252. * rgb is tint
  46253. * a is a intensity
  46254. */
  46255. texture: Nullable<BaseTexture>;
  46256. /** @hidden */
  46257. private _internalMarkAllSubMeshesAsTexturesDirty;
  46258. /** @hidden */
  46259. _markAllSubMeshesAsTexturesDirty(): void;
  46260. /**
  46261. * Instantiate a new istance of clear coat configuration.
  46262. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46263. */
  46264. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46265. /**
  46266. * Specifies that the submesh is ready to be used.
  46267. * @param defines the list of "defines" to update.
  46268. * @param scene defines the scene the material belongs to.
  46269. * @returns - boolean indicating that the submesh is ready or not.
  46270. */
  46271. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46272. /**
  46273. * Checks to see if a texture is used in the material.
  46274. * @param defines the list of "defines" to update.
  46275. * @param scene defines the scene the material belongs to.
  46276. */
  46277. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46278. /**
  46279. * Binds the material data.
  46280. * @param uniformBuffer defines the Uniform buffer to fill in.
  46281. * @param scene defines the scene the material belongs to.
  46282. * @param isFrozen defines wether the material is frozen or not.
  46283. */
  46284. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46285. /**
  46286. * Checks to see if a texture is used in the material.
  46287. * @param texture - Base texture to use.
  46288. * @returns - Boolean specifying if a texture is used in the material.
  46289. */
  46290. hasTexture(texture: BaseTexture): boolean;
  46291. /**
  46292. * Returns an array of the actively used textures.
  46293. * @param activeTextures Array of BaseTextures
  46294. */
  46295. getActiveTextures(activeTextures: BaseTexture[]): void;
  46296. /**
  46297. * Returns the animatable textures.
  46298. * @param animatables Array of animatable textures.
  46299. */
  46300. getAnimatables(animatables: IAnimatable[]): void;
  46301. /**
  46302. * Disposes the resources of the material.
  46303. * @param forceDisposeTextures - Forces the disposal of all textures.
  46304. */
  46305. dispose(forceDisposeTextures?: boolean): void;
  46306. /**
  46307. * Get the current class name of the texture useful for serialization or dynamic coding.
  46308. * @returns "PBRSheenConfiguration"
  46309. */
  46310. getClassName(): string;
  46311. /**
  46312. * Add fallbacks to the effect fallbacks list.
  46313. * @param defines defines the Base texture to use.
  46314. * @param fallbacks defines the current fallback list.
  46315. * @param currentRank defines the current fallback rank.
  46316. * @returns the new fallback rank.
  46317. */
  46318. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46319. /**
  46320. * Add the required uniforms to the current list.
  46321. * @param uniforms defines the current uniform list.
  46322. */
  46323. static AddUniforms(uniforms: string[]): void;
  46324. /**
  46325. * Add the required uniforms to the current buffer.
  46326. * @param uniformBuffer defines the current uniform buffer.
  46327. */
  46328. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46329. /**
  46330. * Add the required samplers to the current list.
  46331. * @param samplers defines the current sampler list.
  46332. */
  46333. static AddSamplers(samplers: string[]): void;
  46334. /**
  46335. * Makes a duplicate of the current configuration into another one.
  46336. * @param sheenConfiguration define the config where to copy the info
  46337. */
  46338. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46339. /**
  46340. * Serializes this BRDF configuration.
  46341. * @returns - An object with the serialized config.
  46342. */
  46343. serialize(): any;
  46344. /**
  46345. * Parses a Sheen Configuration from a serialized object.
  46346. * @param source - Serialized object.
  46347. */
  46348. parse(source: any): void;
  46349. }
  46350. }
  46351. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46352. import { Nullable } from "babylonjs/types";
  46353. import { IAnimatable } from "babylonjs/Misc/tools";
  46354. import { Color3 } from "babylonjs/Maths/math";
  46355. import { SmartArray } from "babylonjs/Misc/smartArray";
  46356. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46357. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46358. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46359. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46360. import { Engine } from "babylonjs/Engines/engine";
  46361. import { Scene } from "babylonjs/scene";
  46362. /**
  46363. * @hidden
  46364. */
  46365. export interface IMaterialSubSurfaceDefines {
  46366. SUBSURFACE: boolean;
  46367. SS_REFRACTION: boolean;
  46368. SS_TRANSLUCENCY: boolean;
  46369. SS_SCATERRING: boolean;
  46370. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46371. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46372. SS_REFRACTIONMAP_3D: boolean;
  46373. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46374. SS_LODINREFRACTIONALPHA: boolean;
  46375. SS_GAMMAREFRACTION: boolean;
  46376. SS_RGBDREFRACTION: boolean;
  46377. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46378. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46379. /** @hidden */
  46380. _areTexturesDirty: boolean;
  46381. }
  46382. /**
  46383. * Define the code related to the sub surface parameters of the pbr material.
  46384. */
  46385. export class PBRSubSurfaceConfiguration {
  46386. private _isRefractionEnabled;
  46387. /**
  46388. * Defines if the refraction is enabled in the material.
  46389. */
  46390. isRefractionEnabled: boolean;
  46391. private _isTranslucencyEnabled;
  46392. /**
  46393. * Defines if the translucency is enabled in the material.
  46394. */
  46395. isTranslucencyEnabled: boolean;
  46396. private _isScatteringEnabled;
  46397. /**
  46398. * Defines the refraction intensity of the material.
  46399. * The refraction when enabled replaces the Diffuse part of the material.
  46400. * The intensity helps transitionning between diffuse and refraction.
  46401. */
  46402. refractionIntensity: number;
  46403. /**
  46404. * Defines the translucency intensity of the material.
  46405. * When translucency has been enabled, this defines how much of the "translucency"
  46406. * is addded to the diffuse part of the material.
  46407. */
  46408. translucencyIntensity: number;
  46409. /**
  46410. * Defines the scattering intensity of the material.
  46411. * When scattering has been enabled, this defines how much of the "scattered light"
  46412. * is addded to the diffuse part of the material.
  46413. */
  46414. scatteringIntensity: number;
  46415. private _thicknessTexture;
  46416. /**
  46417. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46418. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46419. * 0 would mean minimumThickness
  46420. * 1 would mean maximumThickness
  46421. * The other channels might be use as a mask to vary the different effects intensity.
  46422. */
  46423. thicknessTexture: Nullable<BaseTexture>;
  46424. private _refractionTexture;
  46425. /**
  46426. * Defines the texture to use for refraction.
  46427. */
  46428. refractionTexture: Nullable<BaseTexture>;
  46429. private _indexOfRefraction;
  46430. /**
  46431. * Defines the indice of refraction used in the material.
  46432. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46433. */
  46434. indexOfRefraction: number;
  46435. private _invertRefractionY;
  46436. /**
  46437. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46438. */
  46439. invertRefractionY: boolean;
  46440. private _linkRefractionWithTransparency;
  46441. /**
  46442. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46443. * Materials half opaque for instance using refraction could benefit from this control.
  46444. */
  46445. linkRefractionWithTransparency: boolean;
  46446. /**
  46447. * Defines the minimum thickness stored in the thickness map.
  46448. * If no thickness map is defined, this value will be used to simulate thickness.
  46449. */
  46450. minimumThickness: number;
  46451. /**
  46452. * Defines the maximum thickness stored in the thickness map.
  46453. */
  46454. maximumThickness: number;
  46455. /**
  46456. * Defines the volume tint of the material.
  46457. * This is used for both translucency and scattering.
  46458. */
  46459. tintColor: Color3;
  46460. /**
  46461. * Defines the distance at which the tint color should be found in the media.
  46462. * This is used for refraction only.
  46463. */
  46464. tintColorAtDistance: number;
  46465. /**
  46466. * Defines how far each channel transmit through the media.
  46467. * It is defined as a color to simplify it selection.
  46468. */
  46469. diffusionDistance: Color3;
  46470. private _useMaskFromThicknessTexture;
  46471. /**
  46472. * Stores the intensity of the different subsurface effects in the thickness texture.
  46473. * * the green channel is the translucency intensity.
  46474. * * the blue channel is the scattering intensity.
  46475. * * the alpha channel is the refraction intensity.
  46476. */
  46477. useMaskFromThicknessTexture: boolean;
  46478. /** @hidden */
  46479. private _internalMarkAllSubMeshesAsTexturesDirty;
  46480. /** @hidden */
  46481. _markAllSubMeshesAsTexturesDirty(): void;
  46482. /**
  46483. * Instantiate a new istance of sub surface configuration.
  46484. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46485. */
  46486. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46487. /**
  46488. * Gets wehter the submesh is ready to be used or not.
  46489. * @param defines the list of "defines" to update.
  46490. * @param scene defines the scene the material belongs to.
  46491. * @returns - boolean indicating that the submesh is ready or not.
  46492. */
  46493. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46494. /**
  46495. * Checks to see if a texture is used in the material.
  46496. * @param defines the list of "defines" to update.
  46497. * @param scene defines the scene to the material belongs to.
  46498. */
  46499. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46500. /**
  46501. * Binds the material data.
  46502. * @param uniformBuffer defines the Uniform buffer to fill in.
  46503. * @param scene defines the scene the material belongs to.
  46504. * @param engine defines the engine the material belongs to.
  46505. * @param isFrozen defines wether the material is frozen or not.
  46506. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46507. */
  46508. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46509. /**
  46510. * Unbinds the material from the mesh.
  46511. * @param activeEffect defines the effect that should be unbound from.
  46512. * @returns true if unbound, otherwise false
  46513. */
  46514. unbind(activeEffect: Effect): boolean;
  46515. /**
  46516. * Returns the texture used for refraction or null if none is used.
  46517. * @param scene defines the scene the material belongs to.
  46518. * @returns - Refraction texture if present. If no refraction texture and refraction
  46519. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46520. */
  46521. private _getRefractionTexture;
  46522. /**
  46523. * Returns true if alpha blending should be disabled.
  46524. */
  46525. readonly disableAlphaBlending: boolean;
  46526. /**
  46527. * Fills the list of render target textures.
  46528. * @param renderTargets the list of render targets to update
  46529. */
  46530. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46531. /**
  46532. * Checks to see if a texture is used in the material.
  46533. * @param texture - Base texture to use.
  46534. * @returns - Boolean specifying if a texture is used in the material.
  46535. */
  46536. hasTexture(texture: BaseTexture): boolean;
  46537. /**
  46538. * Gets a boolean indicating that current material needs to register RTT
  46539. * @returns true if this uses a render target otherwise false.
  46540. */
  46541. hasRenderTargetTextures(): boolean;
  46542. /**
  46543. * Returns an array of the actively used textures.
  46544. * @param activeTextures Array of BaseTextures
  46545. */
  46546. getActiveTextures(activeTextures: BaseTexture[]): void;
  46547. /**
  46548. * Returns the animatable textures.
  46549. * @param animatables Array of animatable textures.
  46550. */
  46551. getAnimatables(animatables: IAnimatable[]): void;
  46552. /**
  46553. * Disposes the resources of the material.
  46554. * @param forceDisposeTextures - Forces the disposal of all textures.
  46555. */
  46556. dispose(forceDisposeTextures?: boolean): void;
  46557. /**
  46558. * Get the current class name of the texture useful for serialization or dynamic coding.
  46559. * @returns "PBRSubSurfaceConfiguration"
  46560. */
  46561. getClassName(): string;
  46562. /**
  46563. * Add fallbacks to the effect fallbacks list.
  46564. * @param defines defines the Base texture to use.
  46565. * @param fallbacks defines the current fallback list.
  46566. * @param currentRank defines the current fallback rank.
  46567. * @returns the new fallback rank.
  46568. */
  46569. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46570. /**
  46571. * Add the required uniforms to the current list.
  46572. * @param uniforms defines the current uniform list.
  46573. */
  46574. static AddUniforms(uniforms: string[]): void;
  46575. /**
  46576. * Add the required samplers to the current list.
  46577. * @param samplers defines the current sampler list.
  46578. */
  46579. static AddSamplers(samplers: string[]): void;
  46580. /**
  46581. * Add the required uniforms to the current buffer.
  46582. * @param uniformBuffer defines the current uniform buffer.
  46583. */
  46584. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46585. /**
  46586. * Makes a duplicate of the current configuration into another one.
  46587. * @param configuration define the config where to copy the info
  46588. */
  46589. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46590. /**
  46591. * Serializes this Sub Surface configuration.
  46592. * @returns - An object with the serialized config.
  46593. */
  46594. serialize(): any;
  46595. /**
  46596. * Parses a Sub Surface Configuration from a serialized object.
  46597. * @param source - Serialized object.
  46598. */
  46599. parse(source: any): void;
  46600. }
  46601. }
  46602. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46603. /** @hidden */
  46604. export var pbrFragmentDeclaration: {
  46605. name: string;
  46606. shader: string;
  46607. };
  46608. }
  46609. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46610. /** @hidden */
  46611. export var pbrUboDeclaration: {
  46612. name: string;
  46613. shader: string;
  46614. };
  46615. }
  46616. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46617. /** @hidden */
  46618. export var pbrFragmentExtraDeclaration: {
  46619. name: string;
  46620. shader: string;
  46621. };
  46622. }
  46623. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46624. /** @hidden */
  46625. export var pbrFragmentSamplersDeclaration: {
  46626. name: string;
  46627. shader: string;
  46628. };
  46629. }
  46630. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46631. /** @hidden */
  46632. export var pbrHelperFunctions: {
  46633. name: string;
  46634. shader: string;
  46635. };
  46636. }
  46637. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46638. /** @hidden */
  46639. export var harmonicsFunctions: {
  46640. name: string;
  46641. shader: string;
  46642. };
  46643. }
  46644. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46645. /** @hidden */
  46646. export var pbrDirectLightingSetupFunctions: {
  46647. name: string;
  46648. shader: string;
  46649. };
  46650. }
  46651. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46652. /** @hidden */
  46653. export var pbrDirectLightingFalloffFunctions: {
  46654. name: string;
  46655. shader: string;
  46656. };
  46657. }
  46658. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46659. /** @hidden */
  46660. export var pbrBRDFFunctions: {
  46661. name: string;
  46662. shader: string;
  46663. };
  46664. }
  46665. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46666. /** @hidden */
  46667. export var pbrDirectLightingFunctions: {
  46668. name: string;
  46669. shader: string;
  46670. };
  46671. }
  46672. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46673. /** @hidden */
  46674. export var pbrIBLFunctions: {
  46675. name: string;
  46676. shader: string;
  46677. };
  46678. }
  46679. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46680. /** @hidden */
  46681. export var pbrDebug: {
  46682. name: string;
  46683. shader: string;
  46684. };
  46685. }
  46686. declare module "babylonjs/Shaders/pbr.fragment" {
  46687. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46688. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46689. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46690. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46691. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46692. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46693. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46694. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46695. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46696. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46697. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46698. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46699. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46700. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46701. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46702. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46703. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46704. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46705. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46706. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46707. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46708. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46709. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46710. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46711. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46712. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46713. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46714. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46715. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46716. /** @hidden */
  46717. export var pbrPixelShader: {
  46718. name: string;
  46719. shader: string;
  46720. };
  46721. }
  46722. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46723. /** @hidden */
  46724. export var pbrVertexDeclaration: {
  46725. name: string;
  46726. shader: string;
  46727. };
  46728. }
  46729. declare module "babylonjs/Shaders/pbr.vertex" {
  46730. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46731. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46732. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46733. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46734. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46735. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46736. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46737. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46738. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46739. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46740. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46741. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46742. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46743. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46744. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46745. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46746. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46747. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46748. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46749. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46750. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46751. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46752. /** @hidden */
  46753. export var pbrVertexShader: {
  46754. name: string;
  46755. shader: string;
  46756. };
  46757. }
  46758. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46759. import { IAnimatable } from "babylonjs/Misc/tools";
  46760. import { Nullable } from "babylonjs/types";
  46761. import { Scene } from "babylonjs/scene";
  46762. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46763. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46765. import { Mesh } from "babylonjs/Meshes/mesh";
  46766. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46767. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46768. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46769. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46770. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46771. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46772. import { Material } from "babylonjs/Materials/material";
  46773. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46774. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46775. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46776. import "babylonjs/Shaders/pbr.fragment";
  46777. import "babylonjs/Shaders/pbr.vertex";
  46778. /**
  46779. * Manages the defines for the PBR Material.
  46780. * @hidden
  46781. */
  46782. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46783. PBR: boolean;
  46784. MAINUV1: boolean;
  46785. MAINUV2: boolean;
  46786. UV1: boolean;
  46787. UV2: boolean;
  46788. ALBEDO: boolean;
  46789. ALBEDODIRECTUV: number;
  46790. VERTEXCOLOR: boolean;
  46791. AMBIENT: boolean;
  46792. AMBIENTDIRECTUV: number;
  46793. AMBIENTINGRAYSCALE: boolean;
  46794. OPACITY: boolean;
  46795. VERTEXALPHA: boolean;
  46796. OPACITYDIRECTUV: number;
  46797. OPACITYRGB: boolean;
  46798. ALPHATEST: boolean;
  46799. DEPTHPREPASS: boolean;
  46800. ALPHABLEND: boolean;
  46801. ALPHAFROMALBEDO: boolean;
  46802. ALPHATESTVALUE: string;
  46803. SPECULAROVERALPHA: boolean;
  46804. RADIANCEOVERALPHA: boolean;
  46805. ALPHAFRESNEL: boolean;
  46806. LINEARALPHAFRESNEL: boolean;
  46807. PREMULTIPLYALPHA: boolean;
  46808. EMISSIVE: boolean;
  46809. EMISSIVEDIRECTUV: number;
  46810. REFLECTIVITY: boolean;
  46811. REFLECTIVITYDIRECTUV: number;
  46812. SPECULARTERM: boolean;
  46813. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46814. MICROSURFACEAUTOMATIC: boolean;
  46815. LODBASEDMICROSFURACE: boolean;
  46816. MICROSURFACEMAP: boolean;
  46817. MICROSURFACEMAPDIRECTUV: number;
  46818. METALLICWORKFLOW: boolean;
  46819. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46820. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46821. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46822. AOSTOREINMETALMAPRED: boolean;
  46823. ENVIRONMENTBRDF: boolean;
  46824. ENVIRONMENTBRDF_RGBD: boolean;
  46825. NORMAL: boolean;
  46826. TANGENT: boolean;
  46827. BUMP: boolean;
  46828. BUMPDIRECTUV: number;
  46829. OBJECTSPACE_NORMALMAP: boolean;
  46830. PARALLAX: boolean;
  46831. PARALLAXOCCLUSION: boolean;
  46832. NORMALXYSCALE: boolean;
  46833. LIGHTMAP: boolean;
  46834. LIGHTMAPDIRECTUV: number;
  46835. USELIGHTMAPASSHADOWMAP: boolean;
  46836. GAMMALIGHTMAP: boolean;
  46837. REFLECTION: boolean;
  46838. REFLECTIONMAP_3D: boolean;
  46839. REFLECTIONMAP_SPHERICAL: boolean;
  46840. REFLECTIONMAP_PLANAR: boolean;
  46841. REFLECTIONMAP_CUBIC: boolean;
  46842. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46843. REFLECTIONMAP_PROJECTION: boolean;
  46844. REFLECTIONMAP_SKYBOX: boolean;
  46845. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46846. REFLECTIONMAP_EXPLICIT: boolean;
  46847. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46848. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46849. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46850. INVERTCUBICMAP: boolean;
  46851. USESPHERICALFROMREFLECTIONMAP: boolean;
  46852. SPHERICAL_HARMONICS: boolean;
  46853. USESPHERICALINVERTEX: boolean;
  46854. REFLECTIONMAP_OPPOSITEZ: boolean;
  46855. LODINREFLECTIONALPHA: boolean;
  46856. GAMMAREFLECTION: boolean;
  46857. RGBDREFLECTION: boolean;
  46858. RADIANCEOCCLUSION: boolean;
  46859. HORIZONOCCLUSION: boolean;
  46860. INSTANCES: boolean;
  46861. NUM_BONE_INFLUENCERS: number;
  46862. BonesPerMesh: number;
  46863. BONETEXTURE: boolean;
  46864. NONUNIFORMSCALING: boolean;
  46865. MORPHTARGETS: boolean;
  46866. MORPHTARGETS_NORMAL: boolean;
  46867. MORPHTARGETS_TANGENT: boolean;
  46868. NUM_MORPH_INFLUENCERS: number;
  46869. IMAGEPROCESSING: boolean;
  46870. VIGNETTE: boolean;
  46871. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46872. VIGNETTEBLENDMODEOPAQUE: boolean;
  46873. TONEMAPPING: boolean;
  46874. TONEMAPPING_ACES: boolean;
  46875. CONTRAST: boolean;
  46876. COLORCURVES: boolean;
  46877. COLORGRADING: boolean;
  46878. COLORGRADING3D: boolean;
  46879. SAMPLER3DGREENDEPTH: boolean;
  46880. SAMPLER3DBGRMAP: boolean;
  46881. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46882. EXPOSURE: boolean;
  46883. MULTIVIEW: boolean;
  46884. USEPHYSICALLIGHTFALLOFF: boolean;
  46885. USEGLTFLIGHTFALLOFF: boolean;
  46886. TWOSIDEDLIGHTING: boolean;
  46887. SHADOWFLOAT: boolean;
  46888. CLIPPLANE: boolean;
  46889. CLIPPLANE2: boolean;
  46890. CLIPPLANE3: boolean;
  46891. CLIPPLANE4: boolean;
  46892. POINTSIZE: boolean;
  46893. FOG: boolean;
  46894. LOGARITHMICDEPTH: boolean;
  46895. FORCENORMALFORWARD: boolean;
  46896. SPECULARAA: boolean;
  46897. CLEARCOAT: boolean;
  46898. CLEARCOAT_DEFAULTIOR: boolean;
  46899. CLEARCOAT_TEXTURE: boolean;
  46900. CLEARCOAT_TEXTUREDIRECTUV: number;
  46901. CLEARCOAT_BUMP: boolean;
  46902. CLEARCOAT_BUMPDIRECTUV: number;
  46903. CLEARCOAT_TINT: boolean;
  46904. CLEARCOAT_TINT_TEXTURE: boolean;
  46905. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46906. ANISOTROPIC: boolean;
  46907. ANISOTROPIC_TEXTURE: boolean;
  46908. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46909. BRDF_V_HEIGHT_CORRELATED: boolean;
  46910. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46911. SHEEN: boolean;
  46912. SHEEN_TEXTURE: boolean;
  46913. SHEEN_TEXTUREDIRECTUV: number;
  46914. SHEEN_LINKWITHALBEDO: boolean;
  46915. SUBSURFACE: boolean;
  46916. SS_REFRACTION: boolean;
  46917. SS_TRANSLUCENCY: boolean;
  46918. SS_SCATERRING: boolean;
  46919. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46920. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46921. SS_REFRACTIONMAP_3D: boolean;
  46922. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46923. SS_LODINREFRACTIONALPHA: boolean;
  46924. SS_GAMMAREFRACTION: boolean;
  46925. SS_RGBDREFRACTION: boolean;
  46926. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46927. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46928. UNLIT: boolean;
  46929. DEBUGMODE: number;
  46930. /**
  46931. * Initializes the PBR Material defines.
  46932. */
  46933. constructor();
  46934. /**
  46935. * Resets the PBR Material defines.
  46936. */
  46937. reset(): void;
  46938. }
  46939. /**
  46940. * The Physically based material base class of BJS.
  46941. *
  46942. * This offers the main features of a standard PBR material.
  46943. * For more information, please refer to the documentation :
  46944. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46945. */
  46946. export abstract class PBRBaseMaterial extends PushMaterial {
  46947. /**
  46948. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46949. */
  46950. static readonly PBRMATERIAL_OPAQUE: number;
  46951. /**
  46952. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46953. */
  46954. static readonly PBRMATERIAL_ALPHATEST: number;
  46955. /**
  46956. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46957. */
  46958. static readonly PBRMATERIAL_ALPHABLEND: number;
  46959. /**
  46960. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46961. * They are also discarded below the alpha cutoff threshold to improve performances.
  46962. */
  46963. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46964. /**
  46965. * Defines the default value of how much AO map is occluding the analytical lights
  46966. * (point spot...).
  46967. */
  46968. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46969. /**
  46970. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46971. */
  46972. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46973. /**
  46974. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46975. * to enhance interoperability with other engines.
  46976. */
  46977. static readonly LIGHTFALLOFF_GLTF: number;
  46978. /**
  46979. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46980. * to enhance interoperability with other materials.
  46981. */
  46982. static readonly LIGHTFALLOFF_STANDARD: number;
  46983. /**
  46984. * Intensity of the direct lights e.g. the four lights available in your scene.
  46985. * This impacts both the direct diffuse and specular highlights.
  46986. */
  46987. protected _directIntensity: number;
  46988. /**
  46989. * Intensity of the emissive part of the material.
  46990. * This helps controlling the emissive effect without modifying the emissive color.
  46991. */
  46992. protected _emissiveIntensity: number;
  46993. /**
  46994. * Intensity of the environment e.g. how much the environment will light the object
  46995. * either through harmonics for rough material or through the refelction for shiny ones.
  46996. */
  46997. protected _environmentIntensity: number;
  46998. /**
  46999. * This is a special control allowing the reduction of the specular highlights coming from the
  47000. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47001. */
  47002. protected _specularIntensity: number;
  47003. /**
  47004. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47005. */
  47006. private _lightingInfos;
  47007. /**
  47008. * Debug Control allowing disabling the bump map on this material.
  47009. */
  47010. protected _disableBumpMap: boolean;
  47011. /**
  47012. * AKA Diffuse Texture in standard nomenclature.
  47013. */
  47014. protected _albedoTexture: Nullable<BaseTexture>;
  47015. /**
  47016. * AKA Occlusion Texture in other nomenclature.
  47017. */
  47018. protected _ambientTexture: Nullable<BaseTexture>;
  47019. /**
  47020. * AKA Occlusion Texture Intensity in other nomenclature.
  47021. */
  47022. protected _ambientTextureStrength: number;
  47023. /**
  47024. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47025. * 1 means it completely occludes it
  47026. * 0 mean it has no impact
  47027. */
  47028. protected _ambientTextureImpactOnAnalyticalLights: number;
  47029. /**
  47030. * Stores the alpha values in a texture.
  47031. */
  47032. protected _opacityTexture: Nullable<BaseTexture>;
  47033. /**
  47034. * Stores the reflection values in a texture.
  47035. */
  47036. protected _reflectionTexture: Nullable<BaseTexture>;
  47037. /**
  47038. * Stores the emissive values in a texture.
  47039. */
  47040. protected _emissiveTexture: Nullable<BaseTexture>;
  47041. /**
  47042. * AKA Specular texture in other nomenclature.
  47043. */
  47044. protected _reflectivityTexture: Nullable<BaseTexture>;
  47045. /**
  47046. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47047. */
  47048. protected _metallicTexture: Nullable<BaseTexture>;
  47049. /**
  47050. * Specifies the metallic scalar of the metallic/roughness workflow.
  47051. * Can also be used to scale the metalness values of the metallic texture.
  47052. */
  47053. protected _metallic: Nullable<number>;
  47054. /**
  47055. * Specifies the roughness scalar of the metallic/roughness workflow.
  47056. * Can also be used to scale the roughness values of the metallic texture.
  47057. */
  47058. protected _roughness: Nullable<number>;
  47059. /**
  47060. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47061. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47062. */
  47063. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47064. /**
  47065. * Stores surface normal data used to displace a mesh in a texture.
  47066. */
  47067. protected _bumpTexture: Nullable<BaseTexture>;
  47068. /**
  47069. * Stores the pre-calculated light information of a mesh in a texture.
  47070. */
  47071. protected _lightmapTexture: Nullable<BaseTexture>;
  47072. /**
  47073. * The color of a material in ambient lighting.
  47074. */
  47075. protected _ambientColor: Color3;
  47076. /**
  47077. * AKA Diffuse Color in other nomenclature.
  47078. */
  47079. protected _albedoColor: Color3;
  47080. /**
  47081. * AKA Specular Color in other nomenclature.
  47082. */
  47083. protected _reflectivityColor: Color3;
  47084. /**
  47085. * The color applied when light is reflected from a material.
  47086. */
  47087. protected _reflectionColor: Color3;
  47088. /**
  47089. * The color applied when light is emitted from a material.
  47090. */
  47091. protected _emissiveColor: Color3;
  47092. /**
  47093. * AKA Glossiness in other nomenclature.
  47094. */
  47095. protected _microSurface: number;
  47096. /**
  47097. * Specifies that the material will use the light map as a show map.
  47098. */
  47099. protected _useLightmapAsShadowmap: boolean;
  47100. /**
  47101. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47102. * makes the reflect vector face the model (under horizon).
  47103. */
  47104. protected _useHorizonOcclusion: boolean;
  47105. /**
  47106. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47107. * too much the area relying on ambient texture to define their ambient occlusion.
  47108. */
  47109. protected _useRadianceOcclusion: boolean;
  47110. /**
  47111. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47112. */
  47113. protected _useAlphaFromAlbedoTexture: boolean;
  47114. /**
  47115. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47116. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47117. */
  47118. protected _useSpecularOverAlpha: boolean;
  47119. /**
  47120. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47121. */
  47122. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47123. /**
  47124. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47125. */
  47126. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47127. /**
  47128. * Specifies if the metallic texture contains the roughness information in its green channel.
  47129. */
  47130. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47131. /**
  47132. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47133. */
  47134. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47135. /**
  47136. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47137. */
  47138. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47139. /**
  47140. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47141. */
  47142. protected _useAmbientInGrayScale: boolean;
  47143. /**
  47144. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47145. * The material will try to infer what glossiness each pixel should be.
  47146. */
  47147. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47148. /**
  47149. * Defines the falloff type used in this material.
  47150. * It by default is Physical.
  47151. */
  47152. protected _lightFalloff: number;
  47153. /**
  47154. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47155. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47156. */
  47157. protected _useRadianceOverAlpha: boolean;
  47158. /**
  47159. * Allows using an object space normal map (instead of tangent space).
  47160. */
  47161. protected _useObjectSpaceNormalMap: boolean;
  47162. /**
  47163. * Allows using the bump map in parallax mode.
  47164. */
  47165. protected _useParallax: boolean;
  47166. /**
  47167. * Allows using the bump map in parallax occlusion mode.
  47168. */
  47169. protected _useParallaxOcclusion: boolean;
  47170. /**
  47171. * Controls the scale bias of the parallax mode.
  47172. */
  47173. protected _parallaxScaleBias: number;
  47174. /**
  47175. * If sets to true, disables all the lights affecting the material.
  47176. */
  47177. protected _disableLighting: boolean;
  47178. /**
  47179. * Number of Simultaneous lights allowed on the material.
  47180. */
  47181. protected _maxSimultaneousLights: number;
  47182. /**
  47183. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47184. */
  47185. protected _invertNormalMapX: boolean;
  47186. /**
  47187. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47188. */
  47189. protected _invertNormalMapY: boolean;
  47190. /**
  47191. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47192. */
  47193. protected _twoSidedLighting: boolean;
  47194. /**
  47195. * Defines the alpha limits in alpha test mode.
  47196. */
  47197. protected _alphaCutOff: number;
  47198. /**
  47199. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47200. */
  47201. protected _forceAlphaTest: boolean;
  47202. /**
  47203. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47204. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47205. */
  47206. protected _useAlphaFresnel: boolean;
  47207. /**
  47208. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47209. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47210. */
  47211. protected _useLinearAlphaFresnel: boolean;
  47212. /**
  47213. * The transparency mode of the material.
  47214. */
  47215. protected _transparencyMode: Nullable<number>;
  47216. /**
  47217. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47218. * from cos thetav and roughness:
  47219. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47220. */
  47221. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47222. /**
  47223. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47224. */
  47225. protected _forceIrradianceInFragment: boolean;
  47226. /**
  47227. * Force normal to face away from face.
  47228. */
  47229. protected _forceNormalForward: boolean;
  47230. /**
  47231. * Enables specular anti aliasing in the PBR shader.
  47232. * It will both interacts on the Geometry for analytical and IBL lighting.
  47233. * It also prefilter the roughness map based on the bump values.
  47234. */
  47235. protected _enableSpecularAntiAliasing: boolean;
  47236. /**
  47237. * Default configuration related to image processing available in the PBR Material.
  47238. */
  47239. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47240. /**
  47241. * Keep track of the image processing observer to allow dispose and replace.
  47242. */
  47243. private _imageProcessingObserver;
  47244. /**
  47245. * Attaches a new image processing configuration to the PBR Material.
  47246. * @param configuration
  47247. */
  47248. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47249. /**
  47250. * Stores the available render targets.
  47251. */
  47252. private _renderTargets;
  47253. /**
  47254. * Sets the global ambient color for the material used in lighting calculations.
  47255. */
  47256. private _globalAmbientColor;
  47257. /**
  47258. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47259. */
  47260. private _useLogarithmicDepth;
  47261. /**
  47262. * If set to true, no lighting calculations will be applied.
  47263. */
  47264. private _unlit;
  47265. private _debugMode;
  47266. /**
  47267. * @hidden
  47268. * This is reserved for the inspector.
  47269. * Defines the material debug mode.
  47270. * It helps seeing only some components of the material while troubleshooting.
  47271. */
  47272. debugMode: number;
  47273. /**
  47274. * @hidden
  47275. * This is reserved for the inspector.
  47276. * Specify from where on screen the debug mode should start.
  47277. * The value goes from -1 (full screen) to 1 (not visible)
  47278. * It helps with side by side comparison against the final render
  47279. * This defaults to -1
  47280. */
  47281. private debugLimit;
  47282. /**
  47283. * @hidden
  47284. * This is reserved for the inspector.
  47285. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47286. * You can use the factor to better multiply the final value.
  47287. */
  47288. private debugFactor;
  47289. /**
  47290. * Defines the clear coat layer parameters for the material.
  47291. */
  47292. readonly clearCoat: PBRClearCoatConfiguration;
  47293. /**
  47294. * Defines the anisotropic parameters for the material.
  47295. */
  47296. readonly anisotropy: PBRAnisotropicConfiguration;
  47297. /**
  47298. * Defines the BRDF parameters for the material.
  47299. */
  47300. readonly brdf: PBRBRDFConfiguration;
  47301. /**
  47302. * Defines the Sheen parameters for the material.
  47303. */
  47304. readonly sheen: PBRSheenConfiguration;
  47305. /**
  47306. * Defines the SubSurface parameters for the material.
  47307. */
  47308. readonly subSurface: PBRSubSurfaceConfiguration;
  47309. /**
  47310. * Custom callback helping to override the default shader used in the material.
  47311. */
  47312. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47313. /**
  47314. * Instantiates a new PBRMaterial instance.
  47315. *
  47316. * @param name The material name
  47317. * @param scene The scene the material will be use in.
  47318. */
  47319. constructor(name: string, scene: Scene);
  47320. /**
  47321. * Gets a boolean indicating that current material needs to register RTT
  47322. */
  47323. readonly hasRenderTargetTextures: boolean;
  47324. /**
  47325. * Gets the name of the material class.
  47326. */
  47327. getClassName(): string;
  47328. /**
  47329. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47330. */
  47331. /**
  47332. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47333. */
  47334. useLogarithmicDepth: boolean;
  47335. /**
  47336. * Gets the current transparency mode.
  47337. */
  47338. /**
  47339. * Sets the transparency mode of the material.
  47340. *
  47341. * | Value | Type | Description |
  47342. * | ----- | ----------------------------------- | ----------- |
  47343. * | 0 | OPAQUE | |
  47344. * | 1 | ALPHATEST | |
  47345. * | 2 | ALPHABLEND | |
  47346. * | 3 | ALPHATESTANDBLEND | |
  47347. *
  47348. */
  47349. transparencyMode: Nullable<number>;
  47350. /**
  47351. * Returns true if alpha blending should be disabled.
  47352. */
  47353. private readonly _disableAlphaBlending;
  47354. /**
  47355. * Specifies whether or not this material should be rendered in alpha blend mode.
  47356. */
  47357. needAlphaBlending(): boolean;
  47358. /**
  47359. * Specifies if the mesh will require alpha blending.
  47360. * @param mesh - BJS mesh.
  47361. */
  47362. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47363. /**
  47364. * Specifies whether or not this material should be rendered in alpha test mode.
  47365. */
  47366. needAlphaTesting(): boolean;
  47367. /**
  47368. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47369. */
  47370. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47371. /**
  47372. * Gets the texture used for the alpha test.
  47373. */
  47374. getAlphaTestTexture(): Nullable<BaseTexture>;
  47375. /**
  47376. * Specifies that the submesh is ready to be used.
  47377. * @param mesh - BJS mesh.
  47378. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47379. * @param useInstances - Specifies that instances should be used.
  47380. * @returns - boolean indicating that the submesh is ready or not.
  47381. */
  47382. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47383. /**
  47384. * Specifies if the material uses metallic roughness workflow.
  47385. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47386. */
  47387. isMetallicWorkflow(): boolean;
  47388. private _prepareEffect;
  47389. private _prepareDefines;
  47390. /**
  47391. * Force shader compilation
  47392. */
  47393. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47394. clipPlane: boolean;
  47395. }>): void;
  47396. /**
  47397. * Initializes the uniform buffer layout for the shader.
  47398. */
  47399. buildUniformLayout(): void;
  47400. /**
  47401. * Unbinds the material from the mesh
  47402. */
  47403. unbind(): void;
  47404. /**
  47405. * Binds the submesh data.
  47406. * @param world - The world matrix.
  47407. * @param mesh - The BJS mesh.
  47408. * @param subMesh - A submesh of the BJS mesh.
  47409. */
  47410. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47411. /**
  47412. * Returns the animatable textures.
  47413. * @returns - Array of animatable textures.
  47414. */
  47415. getAnimatables(): IAnimatable[];
  47416. /**
  47417. * Returns the texture used for reflections.
  47418. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47419. */
  47420. private _getReflectionTexture;
  47421. /**
  47422. * Returns an array of the actively used textures.
  47423. * @returns - Array of BaseTextures
  47424. */
  47425. getActiveTextures(): BaseTexture[];
  47426. /**
  47427. * Checks to see if a texture is used in the material.
  47428. * @param texture - Base texture to use.
  47429. * @returns - Boolean specifying if a texture is used in the material.
  47430. */
  47431. hasTexture(texture: BaseTexture): boolean;
  47432. /**
  47433. * Disposes the resources of the material.
  47434. * @param forceDisposeEffect - Forces the disposal of effects.
  47435. * @param forceDisposeTextures - Forces the disposal of all textures.
  47436. */
  47437. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47438. }
  47439. }
  47440. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47441. import { Nullable } from "babylonjs/types";
  47442. import { Scene } from "babylonjs/scene";
  47443. import { Color3 } from "babylonjs/Maths/math";
  47444. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47445. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47446. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47447. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47448. /**
  47449. * The Physically based material of BJS.
  47450. *
  47451. * This offers the main features of a standard PBR material.
  47452. * For more information, please refer to the documentation :
  47453. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47454. */
  47455. export class PBRMaterial extends PBRBaseMaterial {
  47456. /**
  47457. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47458. */
  47459. static readonly PBRMATERIAL_OPAQUE: number;
  47460. /**
  47461. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47462. */
  47463. static readonly PBRMATERIAL_ALPHATEST: number;
  47464. /**
  47465. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47466. */
  47467. static readonly PBRMATERIAL_ALPHABLEND: number;
  47468. /**
  47469. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47470. * They are also discarded below the alpha cutoff threshold to improve performances.
  47471. */
  47472. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47473. /**
  47474. * Defines the default value of how much AO map is occluding the analytical lights
  47475. * (point spot...).
  47476. */
  47477. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47478. /**
  47479. * Intensity of the direct lights e.g. the four lights available in your scene.
  47480. * This impacts both the direct diffuse and specular highlights.
  47481. */
  47482. directIntensity: number;
  47483. /**
  47484. * Intensity of the emissive part of the material.
  47485. * This helps controlling the emissive effect without modifying the emissive color.
  47486. */
  47487. emissiveIntensity: number;
  47488. /**
  47489. * Intensity of the environment e.g. how much the environment will light the object
  47490. * either through harmonics for rough material or through the refelction for shiny ones.
  47491. */
  47492. environmentIntensity: number;
  47493. /**
  47494. * This is a special control allowing the reduction of the specular highlights coming from the
  47495. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47496. */
  47497. specularIntensity: number;
  47498. /**
  47499. * Debug Control allowing disabling the bump map on this material.
  47500. */
  47501. disableBumpMap: boolean;
  47502. /**
  47503. * AKA Diffuse Texture in standard nomenclature.
  47504. */
  47505. albedoTexture: BaseTexture;
  47506. /**
  47507. * AKA Occlusion Texture in other nomenclature.
  47508. */
  47509. ambientTexture: BaseTexture;
  47510. /**
  47511. * AKA Occlusion Texture Intensity in other nomenclature.
  47512. */
  47513. ambientTextureStrength: number;
  47514. /**
  47515. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47516. * 1 means it completely occludes it
  47517. * 0 mean it has no impact
  47518. */
  47519. ambientTextureImpactOnAnalyticalLights: number;
  47520. /**
  47521. * Stores the alpha values in a texture.
  47522. */
  47523. opacityTexture: BaseTexture;
  47524. /**
  47525. * Stores the reflection values in a texture.
  47526. */
  47527. reflectionTexture: Nullable<BaseTexture>;
  47528. /**
  47529. * Stores the emissive values in a texture.
  47530. */
  47531. emissiveTexture: BaseTexture;
  47532. /**
  47533. * AKA Specular texture in other nomenclature.
  47534. */
  47535. reflectivityTexture: BaseTexture;
  47536. /**
  47537. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47538. */
  47539. metallicTexture: BaseTexture;
  47540. /**
  47541. * Specifies the metallic scalar of the metallic/roughness workflow.
  47542. * Can also be used to scale the metalness values of the metallic texture.
  47543. */
  47544. metallic: Nullable<number>;
  47545. /**
  47546. * Specifies the roughness scalar of the metallic/roughness workflow.
  47547. * Can also be used to scale the roughness values of the metallic texture.
  47548. */
  47549. roughness: Nullable<number>;
  47550. /**
  47551. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47552. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47553. */
  47554. microSurfaceTexture: BaseTexture;
  47555. /**
  47556. * Stores surface normal data used to displace a mesh in a texture.
  47557. */
  47558. bumpTexture: BaseTexture;
  47559. /**
  47560. * Stores the pre-calculated light information of a mesh in a texture.
  47561. */
  47562. lightmapTexture: BaseTexture;
  47563. /**
  47564. * Stores the refracted light information in a texture.
  47565. */
  47566. refractionTexture: Nullable<BaseTexture>;
  47567. /**
  47568. * The color of a material in ambient lighting.
  47569. */
  47570. ambientColor: Color3;
  47571. /**
  47572. * AKA Diffuse Color in other nomenclature.
  47573. */
  47574. albedoColor: Color3;
  47575. /**
  47576. * AKA Specular Color in other nomenclature.
  47577. */
  47578. reflectivityColor: Color3;
  47579. /**
  47580. * The color reflected from the material.
  47581. */
  47582. reflectionColor: Color3;
  47583. /**
  47584. * The color emitted from the material.
  47585. */
  47586. emissiveColor: Color3;
  47587. /**
  47588. * AKA Glossiness in other nomenclature.
  47589. */
  47590. microSurface: number;
  47591. /**
  47592. * source material index of refraction (IOR)' / 'destination material IOR.
  47593. */
  47594. indexOfRefraction: number;
  47595. /**
  47596. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47597. */
  47598. invertRefractionY: boolean;
  47599. /**
  47600. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47601. * Materials half opaque for instance using refraction could benefit from this control.
  47602. */
  47603. linkRefractionWithTransparency: boolean;
  47604. /**
  47605. * If true, the light map contains occlusion information instead of lighting info.
  47606. */
  47607. useLightmapAsShadowmap: boolean;
  47608. /**
  47609. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47610. */
  47611. useAlphaFromAlbedoTexture: boolean;
  47612. /**
  47613. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47614. */
  47615. forceAlphaTest: boolean;
  47616. /**
  47617. * Defines the alpha limits in alpha test mode.
  47618. */
  47619. alphaCutOff: number;
  47620. /**
  47621. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47622. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47623. */
  47624. useSpecularOverAlpha: boolean;
  47625. /**
  47626. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47627. */
  47628. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47629. /**
  47630. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47631. */
  47632. useRoughnessFromMetallicTextureAlpha: boolean;
  47633. /**
  47634. * Specifies if the metallic texture contains the roughness information in its green channel.
  47635. */
  47636. useRoughnessFromMetallicTextureGreen: boolean;
  47637. /**
  47638. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47639. */
  47640. useMetallnessFromMetallicTextureBlue: boolean;
  47641. /**
  47642. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47643. */
  47644. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47645. /**
  47646. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47647. */
  47648. useAmbientInGrayScale: boolean;
  47649. /**
  47650. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47651. * The material will try to infer what glossiness each pixel should be.
  47652. */
  47653. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47654. /**
  47655. * BJS is using an harcoded light falloff based on a manually sets up range.
  47656. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47657. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47658. */
  47659. /**
  47660. * BJS is using an harcoded light falloff based on a manually sets up range.
  47661. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47662. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47663. */
  47664. usePhysicalLightFalloff: boolean;
  47665. /**
  47666. * In order to support the falloff compatibility with gltf, a special mode has been added
  47667. * to reproduce the gltf light falloff.
  47668. */
  47669. /**
  47670. * In order to support the falloff compatibility with gltf, a special mode has been added
  47671. * to reproduce the gltf light falloff.
  47672. */
  47673. useGLTFLightFalloff: boolean;
  47674. /**
  47675. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47676. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47677. */
  47678. useRadianceOverAlpha: boolean;
  47679. /**
  47680. * Allows using an object space normal map (instead of tangent space).
  47681. */
  47682. useObjectSpaceNormalMap: boolean;
  47683. /**
  47684. * Allows using the bump map in parallax mode.
  47685. */
  47686. useParallax: boolean;
  47687. /**
  47688. * Allows using the bump map in parallax occlusion mode.
  47689. */
  47690. useParallaxOcclusion: boolean;
  47691. /**
  47692. * Controls the scale bias of the parallax mode.
  47693. */
  47694. parallaxScaleBias: number;
  47695. /**
  47696. * If sets to true, disables all the lights affecting the material.
  47697. */
  47698. disableLighting: boolean;
  47699. /**
  47700. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47701. */
  47702. forceIrradianceInFragment: boolean;
  47703. /**
  47704. * Number of Simultaneous lights allowed on the material.
  47705. */
  47706. maxSimultaneousLights: number;
  47707. /**
  47708. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47709. */
  47710. invertNormalMapX: boolean;
  47711. /**
  47712. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47713. */
  47714. invertNormalMapY: boolean;
  47715. /**
  47716. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47717. */
  47718. twoSidedLighting: boolean;
  47719. /**
  47720. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47721. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47722. */
  47723. useAlphaFresnel: boolean;
  47724. /**
  47725. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47726. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47727. */
  47728. useLinearAlphaFresnel: boolean;
  47729. /**
  47730. * Let user defines the brdf lookup texture used for IBL.
  47731. * A default 8bit version is embedded but you could point at :
  47732. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47733. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47734. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47735. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47736. */
  47737. environmentBRDFTexture: Nullable<BaseTexture>;
  47738. /**
  47739. * Force normal to face away from face.
  47740. */
  47741. forceNormalForward: boolean;
  47742. /**
  47743. * Enables specular anti aliasing in the PBR shader.
  47744. * It will both interacts on the Geometry for analytical and IBL lighting.
  47745. * It also prefilter the roughness map based on the bump values.
  47746. */
  47747. enableSpecularAntiAliasing: boolean;
  47748. /**
  47749. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47750. * makes the reflect vector face the model (under horizon).
  47751. */
  47752. useHorizonOcclusion: boolean;
  47753. /**
  47754. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47755. * too much the area relying on ambient texture to define their ambient occlusion.
  47756. */
  47757. useRadianceOcclusion: boolean;
  47758. /**
  47759. * If set to true, no lighting calculations will be applied.
  47760. */
  47761. unlit: boolean;
  47762. /**
  47763. * Gets the image processing configuration used either in this material.
  47764. */
  47765. /**
  47766. * Sets the Default image processing configuration used either in the this material.
  47767. *
  47768. * If sets to null, the scene one is in use.
  47769. */
  47770. imageProcessingConfiguration: ImageProcessingConfiguration;
  47771. /**
  47772. * Gets wether the color curves effect is enabled.
  47773. */
  47774. /**
  47775. * Sets wether the color curves effect is enabled.
  47776. */
  47777. cameraColorCurvesEnabled: boolean;
  47778. /**
  47779. * Gets wether the color grading effect is enabled.
  47780. */
  47781. /**
  47782. * Gets wether the color grading effect is enabled.
  47783. */
  47784. cameraColorGradingEnabled: boolean;
  47785. /**
  47786. * Gets wether tonemapping is enabled or not.
  47787. */
  47788. /**
  47789. * Sets wether tonemapping is enabled or not
  47790. */
  47791. cameraToneMappingEnabled: boolean;
  47792. /**
  47793. * The camera exposure used on this material.
  47794. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47795. * This corresponds to a photographic exposure.
  47796. */
  47797. /**
  47798. * The camera exposure used on this material.
  47799. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47800. * This corresponds to a photographic exposure.
  47801. */
  47802. cameraExposure: number;
  47803. /**
  47804. * Gets The camera contrast used on this material.
  47805. */
  47806. /**
  47807. * Sets The camera contrast used on this material.
  47808. */
  47809. cameraContrast: number;
  47810. /**
  47811. * Gets the Color Grading 2D Lookup Texture.
  47812. */
  47813. /**
  47814. * Sets the Color Grading 2D Lookup Texture.
  47815. */
  47816. cameraColorGradingTexture: Nullable<BaseTexture>;
  47817. /**
  47818. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47819. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47820. * 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;
  47821. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47822. */
  47823. /**
  47824. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47825. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47826. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  47827. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47828. */
  47829. cameraColorCurves: Nullable<ColorCurves>;
  47830. /**
  47831. * Instantiates a new PBRMaterial instance.
  47832. *
  47833. * @param name The material name
  47834. * @param scene The scene the material will be use in.
  47835. */
  47836. constructor(name: string, scene: Scene);
  47837. /**
  47838. * Returns the name of this material class.
  47839. */
  47840. getClassName(): string;
  47841. /**
  47842. * Makes a duplicate of the current material.
  47843. * @param name - name to use for the new material.
  47844. */
  47845. clone(name: string): PBRMaterial;
  47846. /**
  47847. * Serializes this PBR Material.
  47848. * @returns - An object with the serialized material.
  47849. */
  47850. serialize(): any;
  47851. /**
  47852. * Parses a PBR Material from a serialized object.
  47853. * @param source - Serialized object.
  47854. * @param scene - BJS scene instance.
  47855. * @param rootUrl - url for the scene object
  47856. * @returns - PBRMaterial
  47857. */
  47858. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47859. }
  47860. }
  47861. declare module "babylonjs/Misc/dds" {
  47862. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47863. import { Engine } from "babylonjs/Engines/engine";
  47864. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47865. import { Nullable } from "babylonjs/types";
  47866. import { Scene } from "babylonjs/scene";
  47867. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47868. /**
  47869. * Direct draw surface info
  47870. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47871. */
  47872. export interface DDSInfo {
  47873. /**
  47874. * Width of the texture
  47875. */
  47876. width: number;
  47877. /**
  47878. * Width of the texture
  47879. */
  47880. height: number;
  47881. /**
  47882. * Number of Mipmaps for the texture
  47883. * @see https://en.wikipedia.org/wiki/Mipmap
  47884. */
  47885. mipmapCount: number;
  47886. /**
  47887. * If the textures format is a known fourCC format
  47888. * @see https://www.fourcc.org/
  47889. */
  47890. isFourCC: boolean;
  47891. /**
  47892. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47893. */
  47894. isRGB: boolean;
  47895. /**
  47896. * If the texture is a lumincance format
  47897. */
  47898. isLuminance: boolean;
  47899. /**
  47900. * If this is a cube texture
  47901. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47902. */
  47903. isCube: boolean;
  47904. /**
  47905. * If the texture is a compressed format eg. FOURCC_DXT1
  47906. */
  47907. isCompressed: boolean;
  47908. /**
  47909. * The dxgiFormat of the texture
  47910. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47911. */
  47912. dxgiFormat: number;
  47913. /**
  47914. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47915. */
  47916. textureType: number;
  47917. /**
  47918. * Sphericle polynomial created for the dds texture
  47919. */
  47920. sphericalPolynomial?: SphericalPolynomial;
  47921. }
  47922. /**
  47923. * Class used to provide DDS decompression tools
  47924. */
  47925. export class DDSTools {
  47926. /**
  47927. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47928. */
  47929. static StoreLODInAlphaChannel: boolean;
  47930. /**
  47931. * Gets DDS information from an array buffer
  47932. * @param arrayBuffer defines the array buffer to read data from
  47933. * @returns the DDS information
  47934. */
  47935. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47936. private static _FloatView;
  47937. private static _Int32View;
  47938. private static _ToHalfFloat;
  47939. private static _FromHalfFloat;
  47940. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47941. private static _GetHalfFloatRGBAArrayBuffer;
  47942. private static _GetFloatRGBAArrayBuffer;
  47943. private static _GetFloatAsUIntRGBAArrayBuffer;
  47944. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47945. private static _GetRGBAArrayBuffer;
  47946. private static _ExtractLongWordOrder;
  47947. private static _GetRGBArrayBuffer;
  47948. private static _GetLuminanceArrayBuffer;
  47949. /**
  47950. * Uploads DDS Levels to a Babylon Texture
  47951. * @hidden
  47952. */
  47953. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47954. }
  47955. module "babylonjs/Engines/engine" {
  47956. interface Engine {
  47957. /**
  47958. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47959. * @param rootUrl defines the url where the file to load is located
  47960. * @param scene defines the current scene
  47961. * @param lodScale defines scale to apply to the mip map selection
  47962. * @param lodOffset defines offset to apply to the mip map selection
  47963. * @param onLoad defines an optional callback raised when the texture is loaded
  47964. * @param onError defines an optional callback raised if there is an issue to load the texture
  47965. * @param format defines the format of the data
  47966. * @param forcedExtension defines the extension to use to pick the right loader
  47967. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47968. * @returns the cube texture as an InternalTexture
  47969. */
  47970. 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;
  47971. }
  47972. }
  47973. }
  47974. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47975. import { Nullable } from "babylonjs/types";
  47976. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47977. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47978. /**
  47979. * Implementation of the DDS Texture Loader.
  47980. * @hidden
  47981. */
  47982. export class _DDSTextureLoader implements IInternalTextureLoader {
  47983. /**
  47984. * Defines wether the loader supports cascade loading the different faces.
  47985. */
  47986. readonly supportCascades: boolean;
  47987. /**
  47988. * This returns if the loader support the current file information.
  47989. * @param extension defines the file extension of the file being loaded
  47990. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47991. * @param fallback defines the fallback internal texture if any
  47992. * @param isBase64 defines whether the texture is encoded as a base64
  47993. * @param isBuffer defines whether the texture data are stored as a buffer
  47994. * @returns true if the loader can load the specified file
  47995. */
  47996. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47997. /**
  47998. * Transform the url before loading if required.
  47999. * @param rootUrl the url of the texture
  48000. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48001. * @returns the transformed texture
  48002. */
  48003. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48004. /**
  48005. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48006. * @param rootUrl the url of the texture
  48007. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48008. * @returns the fallback texture
  48009. */
  48010. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48011. /**
  48012. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48013. * @param data contains the texture data
  48014. * @param texture defines the BabylonJS internal texture
  48015. * @param createPolynomials will be true if polynomials have been requested
  48016. * @param onLoad defines the callback to trigger once the texture is ready
  48017. * @param onError defines the callback to trigger in case of error
  48018. */
  48019. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48020. /**
  48021. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48022. * @param data contains the texture data
  48023. * @param texture defines the BabylonJS internal texture
  48024. * @param callback defines the method to call once ready to upload
  48025. */
  48026. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48027. }
  48028. }
  48029. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48030. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48031. /** @hidden */
  48032. export var rgbdEncodePixelShader: {
  48033. name: string;
  48034. shader: string;
  48035. };
  48036. }
  48037. declare module "babylonjs/Misc/environmentTextureTools" {
  48038. import { Nullable } from "babylonjs/types";
  48039. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48040. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48041. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48042. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48043. import "babylonjs/Shaders/rgbdEncode.fragment";
  48044. import "babylonjs/Shaders/rgbdDecode.fragment";
  48045. /**
  48046. * Raw texture data and descriptor sufficient for WebGL texture upload
  48047. */
  48048. export interface EnvironmentTextureInfo {
  48049. /**
  48050. * Version of the environment map
  48051. */
  48052. version: number;
  48053. /**
  48054. * Width of image
  48055. */
  48056. width: number;
  48057. /**
  48058. * Irradiance information stored in the file.
  48059. */
  48060. irradiance: any;
  48061. /**
  48062. * Specular information stored in the file.
  48063. */
  48064. specular: any;
  48065. }
  48066. /**
  48067. * Sets of helpers addressing the serialization and deserialization of environment texture
  48068. * stored in a BabylonJS env file.
  48069. * Those files are usually stored as .env files.
  48070. */
  48071. export class EnvironmentTextureTools {
  48072. /**
  48073. * Magic number identifying the env file.
  48074. */
  48075. private static _MagicBytes;
  48076. /**
  48077. * Gets the environment info from an env file.
  48078. * @param data The array buffer containing the .env bytes.
  48079. * @returns the environment file info (the json header) if successfully parsed.
  48080. */
  48081. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48082. /**
  48083. * Creates an environment texture from a loaded cube texture.
  48084. * @param texture defines the cube texture to convert in env file
  48085. * @return a promise containing the environment data if succesfull.
  48086. */
  48087. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48088. /**
  48089. * Creates a JSON representation of the spherical data.
  48090. * @param texture defines the texture containing the polynomials
  48091. * @return the JSON representation of the spherical info
  48092. */
  48093. private static _CreateEnvTextureIrradiance;
  48094. /**
  48095. * Uploads the texture info contained in the env file to the GPU.
  48096. * @param texture defines the internal texture to upload to
  48097. * @param arrayBuffer defines the buffer cotaining the data to load
  48098. * @param info defines the texture info retrieved through the GetEnvInfo method
  48099. * @returns a promise
  48100. */
  48101. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48102. /**
  48103. * Uploads the levels of image data to the GPU.
  48104. * @param texture defines the internal texture to upload to
  48105. * @param imageData defines the array buffer views of image data [mipmap][face]
  48106. * @returns a promise
  48107. */
  48108. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48109. /**
  48110. * Uploads spherical polynomials information to the texture.
  48111. * @param texture defines the texture we are trying to upload the information to
  48112. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48113. */
  48114. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48115. /** @hidden */
  48116. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48117. }
  48118. }
  48119. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48120. import { Nullable } from "babylonjs/types";
  48121. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48122. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48123. /**
  48124. * Implementation of the ENV Texture Loader.
  48125. * @hidden
  48126. */
  48127. export class _ENVTextureLoader implements IInternalTextureLoader {
  48128. /**
  48129. * Defines wether the loader supports cascade loading the different faces.
  48130. */
  48131. readonly supportCascades: boolean;
  48132. /**
  48133. * This returns if the loader support the current file information.
  48134. * @param extension defines the file extension of the file being loaded
  48135. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48136. * @param fallback defines the fallback internal texture if any
  48137. * @param isBase64 defines whether the texture is encoded as a base64
  48138. * @param isBuffer defines whether the texture data are stored as a buffer
  48139. * @returns true if the loader can load the specified file
  48140. */
  48141. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48142. /**
  48143. * Transform the url before loading if required.
  48144. * @param rootUrl the url of the texture
  48145. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48146. * @returns the transformed texture
  48147. */
  48148. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48149. /**
  48150. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48151. * @param rootUrl the url of the texture
  48152. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48153. * @returns the fallback texture
  48154. */
  48155. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48156. /**
  48157. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48158. * @param data contains the texture data
  48159. * @param texture defines the BabylonJS internal texture
  48160. * @param createPolynomials will be true if polynomials have been requested
  48161. * @param onLoad defines the callback to trigger once the texture is ready
  48162. * @param onError defines the callback to trigger in case of error
  48163. */
  48164. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48165. /**
  48166. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48167. * @param data contains the texture data
  48168. * @param texture defines the BabylonJS internal texture
  48169. * @param callback defines the method to call once ready to upload
  48170. */
  48171. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48172. }
  48173. }
  48174. declare module "babylonjs/Misc/khronosTextureContainer" {
  48175. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48176. /**
  48177. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48178. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48179. */
  48180. export class KhronosTextureContainer {
  48181. /** contents of the KTX container file */
  48182. arrayBuffer: any;
  48183. private static HEADER_LEN;
  48184. private static COMPRESSED_2D;
  48185. private static COMPRESSED_3D;
  48186. private static TEX_2D;
  48187. private static TEX_3D;
  48188. /**
  48189. * Gets the openGL type
  48190. */
  48191. glType: number;
  48192. /**
  48193. * Gets the openGL type size
  48194. */
  48195. glTypeSize: number;
  48196. /**
  48197. * Gets the openGL format
  48198. */
  48199. glFormat: number;
  48200. /**
  48201. * Gets the openGL internal format
  48202. */
  48203. glInternalFormat: number;
  48204. /**
  48205. * Gets the base internal format
  48206. */
  48207. glBaseInternalFormat: number;
  48208. /**
  48209. * Gets image width in pixel
  48210. */
  48211. pixelWidth: number;
  48212. /**
  48213. * Gets image height in pixel
  48214. */
  48215. pixelHeight: number;
  48216. /**
  48217. * Gets image depth in pixels
  48218. */
  48219. pixelDepth: number;
  48220. /**
  48221. * Gets the number of array elements
  48222. */
  48223. numberOfArrayElements: number;
  48224. /**
  48225. * Gets the number of faces
  48226. */
  48227. numberOfFaces: number;
  48228. /**
  48229. * Gets the number of mipmap levels
  48230. */
  48231. numberOfMipmapLevels: number;
  48232. /**
  48233. * Gets the bytes of key value data
  48234. */
  48235. bytesOfKeyValueData: number;
  48236. /**
  48237. * Gets the load type
  48238. */
  48239. loadType: number;
  48240. /**
  48241. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48242. */
  48243. isInvalid: boolean;
  48244. /**
  48245. * Creates a new KhronosTextureContainer
  48246. * @param arrayBuffer contents of the KTX container file
  48247. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48248. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48249. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48250. */
  48251. constructor(
  48252. /** contents of the KTX container file */
  48253. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48254. /**
  48255. * Uploads KTX content to a Babylon Texture.
  48256. * It is assumed that the texture has already been created & is currently bound
  48257. * @hidden
  48258. */
  48259. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48260. private _upload2DCompressedLevels;
  48261. }
  48262. }
  48263. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48264. import { Nullable } from "babylonjs/types";
  48265. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48266. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48267. /**
  48268. * Implementation of the KTX Texture Loader.
  48269. * @hidden
  48270. */
  48271. export class _KTXTextureLoader implements IInternalTextureLoader {
  48272. /**
  48273. * Defines wether the loader supports cascade loading the different faces.
  48274. */
  48275. readonly supportCascades: boolean;
  48276. /**
  48277. * This returns if the loader support the current file information.
  48278. * @param extension defines the file extension of the file being loaded
  48279. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48280. * @param fallback defines the fallback internal texture if any
  48281. * @param isBase64 defines whether the texture is encoded as a base64
  48282. * @param isBuffer defines whether the texture data are stored as a buffer
  48283. * @returns true if the loader can load the specified file
  48284. */
  48285. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48286. /**
  48287. * Transform the url before loading if required.
  48288. * @param rootUrl the url of the texture
  48289. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48290. * @returns the transformed texture
  48291. */
  48292. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48293. /**
  48294. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48295. * @param rootUrl the url of the texture
  48296. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48297. * @returns the fallback texture
  48298. */
  48299. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48300. /**
  48301. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48302. * @param data contains the texture data
  48303. * @param texture defines the BabylonJS internal texture
  48304. * @param createPolynomials will be true if polynomials have been requested
  48305. * @param onLoad defines the callback to trigger once the texture is ready
  48306. * @param onError defines the callback to trigger in case of error
  48307. */
  48308. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48309. /**
  48310. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48311. * @param data contains the texture data
  48312. * @param texture defines the BabylonJS internal texture
  48313. * @param callback defines the method to call once ready to upload
  48314. */
  48315. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48316. }
  48317. }
  48318. declare module "babylonjs/Helpers/sceneHelpers" {
  48319. import { Nullable } from "babylonjs/types";
  48320. import { Mesh } from "babylonjs/Meshes/mesh";
  48321. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48322. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48323. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48324. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48325. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48326. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48327. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48328. import "babylonjs/Meshes/Builders/boxBuilder";
  48329. /** @hidden */
  48330. export var _forceSceneHelpersToBundle: boolean;
  48331. module "babylonjs/scene" {
  48332. interface Scene {
  48333. /**
  48334. * Creates a default light for the scene.
  48335. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48336. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48337. */
  48338. createDefaultLight(replace?: boolean): void;
  48339. /**
  48340. * Creates a default camera for the scene.
  48341. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48342. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48343. * @param replace has default false, when true replaces the active camera in the scene
  48344. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48345. */
  48346. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48347. /**
  48348. * Creates a default camera and a default light.
  48349. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48350. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48351. * @param replace has the default false, when true replaces the active camera/light in the scene
  48352. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48353. */
  48354. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48355. /**
  48356. * Creates a new sky box
  48357. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48358. * @param environmentTexture defines the texture to use as environment texture
  48359. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48360. * @param scale defines the overall scale of the skybox
  48361. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48362. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48363. * @returns a new mesh holding the sky box
  48364. */
  48365. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48366. /**
  48367. * Creates a new environment
  48368. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48369. * @param options defines the options you can use to configure the environment
  48370. * @returns the new EnvironmentHelper
  48371. */
  48372. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48373. /**
  48374. * Creates a new VREXperienceHelper
  48375. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48376. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48377. * @returns a new VREXperienceHelper
  48378. */
  48379. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48380. /**
  48381. * Creates a new XREXperienceHelper
  48382. * @see http://doc.babylonjs.com/how_to/webxr
  48383. * @returns a promise for a new XREXperienceHelper
  48384. */
  48385. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48386. }
  48387. }
  48388. }
  48389. declare module "babylonjs/Helpers/videoDome" {
  48390. import { Scene } from "babylonjs/scene";
  48391. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48392. import { Mesh } from "babylonjs/Meshes/mesh";
  48393. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48394. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48395. import "babylonjs/Meshes/Builders/sphereBuilder";
  48396. /**
  48397. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48398. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48399. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48400. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48401. */
  48402. export class VideoDome extends TransformNode {
  48403. /**
  48404. * Define the video source as a Monoscopic panoramic 360 video.
  48405. */
  48406. static readonly MODE_MONOSCOPIC: number;
  48407. /**
  48408. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48409. */
  48410. static readonly MODE_TOPBOTTOM: number;
  48411. /**
  48412. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48413. */
  48414. static readonly MODE_SIDEBYSIDE: number;
  48415. private _useDirectMapping;
  48416. /**
  48417. * The video texture being displayed on the sphere
  48418. */
  48419. protected _videoTexture: VideoTexture;
  48420. /**
  48421. * Gets the video texture being displayed on the sphere
  48422. */
  48423. readonly videoTexture: VideoTexture;
  48424. /**
  48425. * The skybox material
  48426. */
  48427. protected _material: BackgroundMaterial;
  48428. /**
  48429. * The surface used for the skybox
  48430. */
  48431. protected _mesh: Mesh;
  48432. /**
  48433. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48434. * Also see the options.resolution property.
  48435. */
  48436. fovMultiplier: number;
  48437. private _videoMode;
  48438. /**
  48439. * Gets or set the current video mode for the video. It can be:
  48440. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48441. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48442. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48443. */
  48444. videoMode: number;
  48445. /**
  48446. * Oberserver used in Stereoscopic VR Mode.
  48447. */
  48448. private _onBeforeCameraRenderObserver;
  48449. /**
  48450. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48451. * @param name Element's name, child elements will append suffixes for their own names.
  48452. * @param urlsOrVideo defines the url(s) or the video element to use
  48453. * @param options An object containing optional or exposed sub element properties
  48454. */
  48455. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48456. resolution?: number;
  48457. clickToPlay?: boolean;
  48458. autoPlay?: boolean;
  48459. loop?: boolean;
  48460. size?: number;
  48461. poster?: string;
  48462. faceForward?: boolean;
  48463. useDirectMapping?: boolean;
  48464. }, scene: Scene);
  48465. private _changeVideoMode;
  48466. /**
  48467. * Releases resources associated with this node.
  48468. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48469. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48470. */
  48471. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48472. }
  48473. }
  48474. declare module "babylonjs/Helpers/index" {
  48475. export * from "babylonjs/Helpers/environmentHelper";
  48476. export * from "babylonjs/Helpers/photoDome";
  48477. export * from "babylonjs/Helpers/sceneHelpers";
  48478. export * from "babylonjs/Helpers/videoDome";
  48479. }
  48480. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48481. import { PerfCounter } from "babylonjs/Misc/tools";
  48482. import { IDisposable } from "babylonjs/scene";
  48483. import { Engine } from "babylonjs/Engines/engine";
  48484. /**
  48485. * This class can be used to get instrumentation data from a Babylon engine
  48486. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48487. */
  48488. export class EngineInstrumentation implements IDisposable {
  48489. /**
  48490. * Define the instrumented engine.
  48491. */
  48492. engine: Engine;
  48493. private _captureGPUFrameTime;
  48494. private _gpuFrameTimeToken;
  48495. private _gpuFrameTime;
  48496. private _captureShaderCompilationTime;
  48497. private _shaderCompilationTime;
  48498. private _onBeginFrameObserver;
  48499. private _onEndFrameObserver;
  48500. private _onBeforeShaderCompilationObserver;
  48501. private _onAfterShaderCompilationObserver;
  48502. /**
  48503. * Gets the perf counter used for GPU frame time
  48504. */
  48505. readonly gpuFrameTimeCounter: PerfCounter;
  48506. /**
  48507. * Gets the GPU frame time capture status
  48508. */
  48509. /**
  48510. * Enable or disable the GPU frame time capture
  48511. */
  48512. captureGPUFrameTime: boolean;
  48513. /**
  48514. * Gets the perf counter used for shader compilation time
  48515. */
  48516. readonly shaderCompilationTimeCounter: PerfCounter;
  48517. /**
  48518. * Gets the shader compilation time capture status
  48519. */
  48520. /**
  48521. * Enable or disable the shader compilation time capture
  48522. */
  48523. captureShaderCompilationTime: boolean;
  48524. /**
  48525. * Instantiates a new engine instrumentation.
  48526. * This class can be used to get instrumentation data from a Babylon engine
  48527. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48528. * @param engine Defines the engine to instrument
  48529. */
  48530. constructor(
  48531. /**
  48532. * Define the instrumented engine.
  48533. */
  48534. engine: Engine);
  48535. /**
  48536. * Dispose and release associated resources.
  48537. */
  48538. dispose(): void;
  48539. }
  48540. }
  48541. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48542. import { PerfCounter } from "babylonjs/Misc/tools";
  48543. import { Scene, IDisposable } from "babylonjs/scene";
  48544. /**
  48545. * This class can be used to get instrumentation data from a Babylon engine
  48546. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48547. */
  48548. export class SceneInstrumentation implements IDisposable {
  48549. /**
  48550. * Defines the scene to instrument
  48551. */
  48552. scene: Scene;
  48553. private _captureActiveMeshesEvaluationTime;
  48554. private _activeMeshesEvaluationTime;
  48555. private _captureRenderTargetsRenderTime;
  48556. private _renderTargetsRenderTime;
  48557. private _captureFrameTime;
  48558. private _frameTime;
  48559. private _captureRenderTime;
  48560. private _renderTime;
  48561. private _captureInterFrameTime;
  48562. private _interFrameTime;
  48563. private _captureParticlesRenderTime;
  48564. private _particlesRenderTime;
  48565. private _captureSpritesRenderTime;
  48566. private _spritesRenderTime;
  48567. private _capturePhysicsTime;
  48568. private _physicsTime;
  48569. private _captureAnimationsTime;
  48570. private _animationsTime;
  48571. private _captureCameraRenderTime;
  48572. private _cameraRenderTime;
  48573. private _onBeforeActiveMeshesEvaluationObserver;
  48574. private _onAfterActiveMeshesEvaluationObserver;
  48575. private _onBeforeRenderTargetsRenderObserver;
  48576. private _onAfterRenderTargetsRenderObserver;
  48577. private _onAfterRenderObserver;
  48578. private _onBeforeDrawPhaseObserver;
  48579. private _onAfterDrawPhaseObserver;
  48580. private _onBeforeAnimationsObserver;
  48581. private _onBeforeParticlesRenderingObserver;
  48582. private _onAfterParticlesRenderingObserver;
  48583. private _onBeforeSpritesRenderingObserver;
  48584. private _onAfterSpritesRenderingObserver;
  48585. private _onBeforePhysicsObserver;
  48586. private _onAfterPhysicsObserver;
  48587. private _onAfterAnimationsObserver;
  48588. private _onBeforeCameraRenderObserver;
  48589. private _onAfterCameraRenderObserver;
  48590. /**
  48591. * Gets the perf counter used for active meshes evaluation time
  48592. */
  48593. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48594. /**
  48595. * Gets the active meshes evaluation time capture status
  48596. */
  48597. /**
  48598. * Enable or disable the active meshes evaluation time capture
  48599. */
  48600. captureActiveMeshesEvaluationTime: boolean;
  48601. /**
  48602. * Gets the perf counter used for render targets render time
  48603. */
  48604. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48605. /**
  48606. * Gets the render targets render time capture status
  48607. */
  48608. /**
  48609. * Enable or disable the render targets render time capture
  48610. */
  48611. captureRenderTargetsRenderTime: boolean;
  48612. /**
  48613. * Gets the perf counter used for particles render time
  48614. */
  48615. readonly particlesRenderTimeCounter: PerfCounter;
  48616. /**
  48617. * Gets the particles render time capture status
  48618. */
  48619. /**
  48620. * Enable or disable the particles render time capture
  48621. */
  48622. captureParticlesRenderTime: boolean;
  48623. /**
  48624. * Gets the perf counter used for sprites render time
  48625. */
  48626. readonly spritesRenderTimeCounter: PerfCounter;
  48627. /**
  48628. * Gets the sprites render time capture status
  48629. */
  48630. /**
  48631. * Enable or disable the sprites render time capture
  48632. */
  48633. captureSpritesRenderTime: boolean;
  48634. /**
  48635. * Gets the perf counter used for physics time
  48636. */
  48637. readonly physicsTimeCounter: PerfCounter;
  48638. /**
  48639. * Gets the physics time capture status
  48640. */
  48641. /**
  48642. * Enable or disable the physics time capture
  48643. */
  48644. capturePhysicsTime: boolean;
  48645. /**
  48646. * Gets the perf counter used for animations time
  48647. */
  48648. readonly animationsTimeCounter: PerfCounter;
  48649. /**
  48650. * Gets the animations time capture status
  48651. */
  48652. /**
  48653. * Enable or disable the animations time capture
  48654. */
  48655. captureAnimationsTime: boolean;
  48656. /**
  48657. * Gets the perf counter used for frame time capture
  48658. */
  48659. readonly frameTimeCounter: PerfCounter;
  48660. /**
  48661. * Gets the frame time capture status
  48662. */
  48663. /**
  48664. * Enable or disable the frame time capture
  48665. */
  48666. captureFrameTime: boolean;
  48667. /**
  48668. * Gets the perf counter used for inter-frames time capture
  48669. */
  48670. readonly interFrameTimeCounter: PerfCounter;
  48671. /**
  48672. * Gets the inter-frames time capture status
  48673. */
  48674. /**
  48675. * Enable or disable the inter-frames time capture
  48676. */
  48677. captureInterFrameTime: boolean;
  48678. /**
  48679. * Gets the perf counter used for render time capture
  48680. */
  48681. readonly renderTimeCounter: PerfCounter;
  48682. /**
  48683. * Gets the render time capture status
  48684. */
  48685. /**
  48686. * Enable or disable the render time capture
  48687. */
  48688. captureRenderTime: boolean;
  48689. /**
  48690. * Gets the perf counter used for camera render time capture
  48691. */
  48692. readonly cameraRenderTimeCounter: PerfCounter;
  48693. /**
  48694. * Gets the camera render time capture status
  48695. */
  48696. /**
  48697. * Enable or disable the camera render time capture
  48698. */
  48699. captureCameraRenderTime: boolean;
  48700. /**
  48701. * Gets the perf counter used for draw calls
  48702. */
  48703. readonly drawCallsCounter: PerfCounter;
  48704. /**
  48705. * Instantiates a new scene instrumentation.
  48706. * This class can be used to get instrumentation data from a Babylon engine
  48707. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48708. * @param scene Defines the scene to instrument
  48709. */
  48710. constructor(
  48711. /**
  48712. * Defines the scene to instrument
  48713. */
  48714. scene: Scene);
  48715. /**
  48716. * Dispose and release associated resources.
  48717. */
  48718. dispose(): void;
  48719. }
  48720. }
  48721. declare module "babylonjs/Instrumentation/index" {
  48722. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48723. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48724. export * from "babylonjs/Instrumentation/timeToken";
  48725. }
  48726. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48727. /** @hidden */
  48728. export var glowMapGenerationPixelShader: {
  48729. name: string;
  48730. shader: string;
  48731. };
  48732. }
  48733. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48734. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48735. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48736. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48737. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48738. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48739. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48740. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48741. /** @hidden */
  48742. export var glowMapGenerationVertexShader: {
  48743. name: string;
  48744. shader: string;
  48745. };
  48746. }
  48747. declare module "babylonjs/Layers/effectLayer" {
  48748. import { Observable } from "babylonjs/Misc/observable";
  48749. import { Nullable } from "babylonjs/types";
  48750. import { Camera } from "babylonjs/Cameras/camera";
  48751. import { Scene } from "babylonjs/scene";
  48752. import { Color4, ISize } from "babylonjs/Maths/math";
  48753. import { Engine } from "babylonjs/Engines/engine";
  48754. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48756. import { Mesh } from "babylonjs/Meshes/mesh";
  48757. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48758. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48759. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48760. import { Effect } from "babylonjs/Materials/effect";
  48761. import { Material } from "babylonjs/Materials/material";
  48762. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48763. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48764. /**
  48765. * Effect layer options. This helps customizing the behaviour
  48766. * of the effect layer.
  48767. */
  48768. export interface IEffectLayerOptions {
  48769. /**
  48770. * Multiplication factor apply to the canvas size to compute the render target size
  48771. * used to generated the objects (the smaller the faster).
  48772. */
  48773. mainTextureRatio: number;
  48774. /**
  48775. * Enforces a fixed size texture to ensure effect stability across devices.
  48776. */
  48777. mainTextureFixedSize?: number;
  48778. /**
  48779. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48780. */
  48781. alphaBlendingMode: number;
  48782. /**
  48783. * The camera attached to the layer.
  48784. */
  48785. camera: Nullable<Camera>;
  48786. /**
  48787. * The rendering group to draw the layer in.
  48788. */
  48789. renderingGroupId: number;
  48790. }
  48791. /**
  48792. * The effect layer Helps adding post process effect blended with the main pass.
  48793. *
  48794. * This can be for instance use to generate glow or higlight effects on the scene.
  48795. *
  48796. * The effect layer class can not be used directly and is intented to inherited from to be
  48797. * customized per effects.
  48798. */
  48799. export abstract class EffectLayer {
  48800. private _vertexBuffers;
  48801. private _indexBuffer;
  48802. private _cachedDefines;
  48803. private _effectLayerMapGenerationEffect;
  48804. private _effectLayerOptions;
  48805. private _mergeEffect;
  48806. protected _scene: Scene;
  48807. protected _engine: Engine;
  48808. protected _maxSize: number;
  48809. protected _mainTextureDesiredSize: ISize;
  48810. protected _mainTexture: RenderTargetTexture;
  48811. protected _shouldRender: boolean;
  48812. protected _postProcesses: PostProcess[];
  48813. protected _textures: BaseTexture[];
  48814. protected _emissiveTextureAndColor: {
  48815. texture: Nullable<BaseTexture>;
  48816. color: Color4;
  48817. };
  48818. /**
  48819. * The name of the layer
  48820. */
  48821. name: string;
  48822. /**
  48823. * The clear color of the texture used to generate the glow map.
  48824. */
  48825. neutralColor: Color4;
  48826. /**
  48827. * Specifies wether the highlight layer is enabled or not.
  48828. */
  48829. isEnabled: boolean;
  48830. /**
  48831. * Gets the camera attached to the layer.
  48832. */
  48833. readonly camera: Nullable<Camera>;
  48834. /**
  48835. * Gets the rendering group id the layer should render in.
  48836. */
  48837. readonly renderingGroupId: number;
  48838. /**
  48839. * An event triggered when the effect layer has been disposed.
  48840. */
  48841. onDisposeObservable: Observable<EffectLayer>;
  48842. /**
  48843. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48844. */
  48845. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48846. /**
  48847. * An event triggered when the generated texture is being merged in the scene.
  48848. */
  48849. onBeforeComposeObservable: Observable<EffectLayer>;
  48850. /**
  48851. * An event triggered when the generated texture has been merged in the scene.
  48852. */
  48853. onAfterComposeObservable: Observable<EffectLayer>;
  48854. /**
  48855. * An event triggered when the efffect layer changes its size.
  48856. */
  48857. onSizeChangedObservable: Observable<EffectLayer>;
  48858. /** @hidden */
  48859. static _SceneComponentInitialization: (scene: Scene) => void;
  48860. /**
  48861. * Instantiates a new effect Layer and references it in the scene.
  48862. * @param name The name of the layer
  48863. * @param scene The scene to use the layer in
  48864. */
  48865. constructor(
  48866. /** The Friendly of the effect in the scene */
  48867. name: string, scene: Scene);
  48868. /**
  48869. * Get the effect name of the layer.
  48870. * @return The effect name
  48871. */
  48872. abstract getEffectName(): string;
  48873. /**
  48874. * Checks for the readiness of the element composing the layer.
  48875. * @param subMesh the mesh to check for
  48876. * @param useInstances specify wether or not to use instances to render the mesh
  48877. * @return true if ready otherwise, false
  48878. */
  48879. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48880. /**
  48881. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48882. * @returns true if the effect requires stencil during the main canvas render pass.
  48883. */
  48884. abstract needStencil(): boolean;
  48885. /**
  48886. * Create the merge effect. This is the shader use to blit the information back
  48887. * to the main canvas at the end of the scene rendering.
  48888. * @returns The effect containing the shader used to merge the effect on the main canvas
  48889. */
  48890. protected abstract _createMergeEffect(): Effect;
  48891. /**
  48892. * Creates the render target textures and post processes used in the effect layer.
  48893. */
  48894. protected abstract _createTextureAndPostProcesses(): void;
  48895. /**
  48896. * Implementation specific of rendering the generating effect on the main canvas.
  48897. * @param effect The effect used to render through
  48898. */
  48899. protected abstract _internalRender(effect: Effect): void;
  48900. /**
  48901. * Sets the required values for both the emissive texture and and the main color.
  48902. */
  48903. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48904. /**
  48905. * Free any resources and references associated to a mesh.
  48906. * Internal use
  48907. * @param mesh The mesh to free.
  48908. */
  48909. abstract _disposeMesh(mesh: Mesh): void;
  48910. /**
  48911. * Serializes this layer (Glow or Highlight for example)
  48912. * @returns a serialized layer object
  48913. */
  48914. abstract serialize?(): any;
  48915. /**
  48916. * Initializes the effect layer with the required options.
  48917. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48918. */
  48919. protected _init(options: Partial<IEffectLayerOptions>): void;
  48920. /**
  48921. * Generates the index buffer of the full screen quad blending to the main canvas.
  48922. */
  48923. private _generateIndexBuffer;
  48924. /**
  48925. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48926. */
  48927. private _generateVertexBuffer;
  48928. /**
  48929. * Sets the main texture desired size which is the closest power of two
  48930. * of the engine canvas size.
  48931. */
  48932. private _setMainTextureSize;
  48933. /**
  48934. * Creates the main texture for the effect layer.
  48935. */
  48936. protected _createMainTexture(): void;
  48937. /**
  48938. * Adds specific effects defines.
  48939. * @param defines The defines to add specifics to.
  48940. */
  48941. protected _addCustomEffectDefines(defines: string[]): void;
  48942. /**
  48943. * Checks for the readiness of the element composing the layer.
  48944. * @param subMesh the mesh to check for
  48945. * @param useInstances specify wether or not to use instances to render the mesh
  48946. * @param emissiveTexture the associated emissive texture used to generate the glow
  48947. * @return true if ready otherwise, false
  48948. */
  48949. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48950. /**
  48951. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48952. */
  48953. render(): void;
  48954. /**
  48955. * Determine if a given mesh will be used in the current effect.
  48956. * @param mesh mesh to test
  48957. * @returns true if the mesh will be used
  48958. */
  48959. hasMesh(mesh: AbstractMesh): boolean;
  48960. /**
  48961. * Returns true if the layer contains information to display, otherwise false.
  48962. * @returns true if the glow layer should be rendered
  48963. */
  48964. shouldRender(): boolean;
  48965. /**
  48966. * Returns true if the mesh should render, otherwise false.
  48967. * @param mesh The mesh to render
  48968. * @returns true if it should render otherwise false
  48969. */
  48970. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48971. /**
  48972. * Returns true if the mesh can be rendered, otherwise false.
  48973. * @param mesh The mesh to render
  48974. * @param material The material used on the mesh
  48975. * @returns true if it can be rendered otherwise false
  48976. */
  48977. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48978. /**
  48979. * Returns true if the mesh should render, otherwise false.
  48980. * @param mesh The mesh to render
  48981. * @returns true if it should render otherwise false
  48982. */
  48983. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48984. /**
  48985. * Renders the submesh passed in parameter to the generation map.
  48986. */
  48987. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48988. /**
  48989. * Rebuild the required buffers.
  48990. * @hidden Internal use only.
  48991. */
  48992. _rebuild(): void;
  48993. /**
  48994. * Dispose only the render target textures and post process.
  48995. */
  48996. private _disposeTextureAndPostProcesses;
  48997. /**
  48998. * Dispose the highlight layer and free resources.
  48999. */
  49000. dispose(): void;
  49001. /**
  49002. * Gets the class name of the effect layer
  49003. * @returns the string with the class name of the effect layer
  49004. */
  49005. getClassName(): string;
  49006. /**
  49007. * Creates an effect layer from parsed effect layer data
  49008. * @param parsedEffectLayer defines effect layer data
  49009. * @param scene defines the current scene
  49010. * @param rootUrl defines the root URL containing the effect layer information
  49011. * @returns a parsed effect Layer
  49012. */
  49013. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49014. }
  49015. }
  49016. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49017. import { Scene } from "babylonjs/scene";
  49018. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49019. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49020. import { AbstractScene } from "babylonjs/abstractScene";
  49021. module "babylonjs/abstractScene" {
  49022. interface AbstractScene {
  49023. /**
  49024. * The list of effect layers (highlights/glow) added to the scene
  49025. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49026. * @see http://doc.babylonjs.com/how_to/glow_layer
  49027. */
  49028. effectLayers: Array<EffectLayer>;
  49029. /**
  49030. * Removes the given effect layer from this scene.
  49031. * @param toRemove defines the effect layer to remove
  49032. * @returns the index of the removed effect layer
  49033. */
  49034. removeEffectLayer(toRemove: EffectLayer): number;
  49035. /**
  49036. * Adds the given effect layer to this scene
  49037. * @param newEffectLayer defines the effect layer to add
  49038. */
  49039. addEffectLayer(newEffectLayer: EffectLayer): void;
  49040. }
  49041. }
  49042. /**
  49043. * Defines the layer scene component responsible to manage any effect layers
  49044. * in a given scene.
  49045. */
  49046. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49047. /**
  49048. * The component name helpfull to identify the component in the list of scene components.
  49049. */
  49050. readonly name: string;
  49051. /**
  49052. * The scene the component belongs to.
  49053. */
  49054. scene: Scene;
  49055. private _engine;
  49056. private _renderEffects;
  49057. private _needStencil;
  49058. private _previousStencilState;
  49059. /**
  49060. * Creates a new instance of the component for the given scene
  49061. * @param scene Defines the scene to register the component in
  49062. */
  49063. constructor(scene: Scene);
  49064. /**
  49065. * Registers the component in a given scene
  49066. */
  49067. register(): void;
  49068. /**
  49069. * Rebuilds the elements related to this component in case of
  49070. * context lost for instance.
  49071. */
  49072. rebuild(): void;
  49073. /**
  49074. * Serializes the component data to the specified json object
  49075. * @param serializationObject The object to serialize to
  49076. */
  49077. serialize(serializationObject: any): void;
  49078. /**
  49079. * Adds all the element from the container to the scene
  49080. * @param container the container holding the elements
  49081. */
  49082. addFromContainer(container: AbstractScene): void;
  49083. /**
  49084. * Removes all the elements in the container from the scene
  49085. * @param container contains the elements to remove
  49086. * @param dispose if the removed element should be disposed (default: false)
  49087. */
  49088. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49089. /**
  49090. * Disposes the component and the associated ressources.
  49091. */
  49092. dispose(): void;
  49093. private _isReadyForMesh;
  49094. private _renderMainTexture;
  49095. private _setStencil;
  49096. private _setStencilBack;
  49097. private _draw;
  49098. private _drawCamera;
  49099. private _drawRenderingGroup;
  49100. }
  49101. }
  49102. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49103. /** @hidden */
  49104. export var glowMapMergePixelShader: {
  49105. name: string;
  49106. shader: string;
  49107. };
  49108. }
  49109. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49110. /** @hidden */
  49111. export var glowMapMergeVertexShader: {
  49112. name: string;
  49113. shader: string;
  49114. };
  49115. }
  49116. declare module "babylonjs/Layers/glowLayer" {
  49117. import { Nullable } from "babylonjs/types";
  49118. import { Camera } from "babylonjs/Cameras/camera";
  49119. import { Scene } from "babylonjs/scene";
  49120. import { Color4 } from "babylonjs/Maths/math";
  49121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49123. import { Mesh } from "babylonjs/Meshes/mesh";
  49124. import { Texture } from "babylonjs/Materials/Textures/texture";
  49125. import { Effect } from "babylonjs/Materials/effect";
  49126. import { Material } from "babylonjs/Materials/material";
  49127. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49128. import "babylonjs/Shaders/glowMapMerge.fragment";
  49129. import "babylonjs/Shaders/glowMapMerge.vertex";
  49130. import "babylonjs/Layers/effectLayerSceneComponent";
  49131. module "babylonjs/abstractScene" {
  49132. interface AbstractScene {
  49133. /**
  49134. * Return a the first highlight layer of the scene with a given name.
  49135. * @param name The name of the highlight layer to look for.
  49136. * @return The highlight layer if found otherwise null.
  49137. */
  49138. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49139. }
  49140. }
  49141. /**
  49142. * Glow layer options. This helps customizing the behaviour
  49143. * of the glow layer.
  49144. */
  49145. export interface IGlowLayerOptions {
  49146. /**
  49147. * Multiplication factor apply to the canvas size to compute the render target size
  49148. * used to generated the glowing objects (the smaller the faster).
  49149. */
  49150. mainTextureRatio: number;
  49151. /**
  49152. * Enforces a fixed size texture to ensure resize independant blur.
  49153. */
  49154. mainTextureFixedSize?: number;
  49155. /**
  49156. * How big is the kernel of the blur texture.
  49157. */
  49158. blurKernelSize: number;
  49159. /**
  49160. * The camera attached to the layer.
  49161. */
  49162. camera: Nullable<Camera>;
  49163. /**
  49164. * Enable MSAA by chosing the number of samples.
  49165. */
  49166. mainTextureSamples?: number;
  49167. /**
  49168. * The rendering group to draw the layer in.
  49169. */
  49170. renderingGroupId: number;
  49171. }
  49172. /**
  49173. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49174. *
  49175. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49176. * glowy meshes to your scene.
  49177. *
  49178. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49179. */
  49180. export class GlowLayer extends EffectLayer {
  49181. /**
  49182. * Effect Name of the layer.
  49183. */
  49184. static readonly EffectName: string;
  49185. /**
  49186. * The default blur kernel size used for the glow.
  49187. */
  49188. static DefaultBlurKernelSize: number;
  49189. /**
  49190. * The default texture size ratio used for the glow.
  49191. */
  49192. static DefaultTextureRatio: number;
  49193. /**
  49194. * Sets the kernel size of the blur.
  49195. */
  49196. /**
  49197. * Gets the kernel size of the blur.
  49198. */
  49199. blurKernelSize: number;
  49200. /**
  49201. * Sets the glow intensity.
  49202. */
  49203. /**
  49204. * Gets the glow intensity.
  49205. */
  49206. intensity: number;
  49207. private _options;
  49208. private _intensity;
  49209. private _horizontalBlurPostprocess1;
  49210. private _verticalBlurPostprocess1;
  49211. private _horizontalBlurPostprocess2;
  49212. private _verticalBlurPostprocess2;
  49213. private _blurTexture1;
  49214. private _blurTexture2;
  49215. private _postProcesses1;
  49216. private _postProcesses2;
  49217. private _includedOnlyMeshes;
  49218. private _excludedMeshes;
  49219. /**
  49220. * Callback used to let the user override the color selection on a per mesh basis
  49221. */
  49222. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49223. /**
  49224. * Callback used to let the user override the texture selection on a per mesh basis
  49225. */
  49226. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49227. /**
  49228. * Instantiates a new glow Layer and references it to the scene.
  49229. * @param name The name of the layer
  49230. * @param scene The scene to use the layer in
  49231. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49232. */
  49233. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49234. /**
  49235. * Get the effect name of the layer.
  49236. * @return The effect name
  49237. */
  49238. getEffectName(): string;
  49239. /**
  49240. * Create the merge effect. This is the shader use to blit the information back
  49241. * to the main canvas at the end of the scene rendering.
  49242. */
  49243. protected _createMergeEffect(): Effect;
  49244. /**
  49245. * Creates the render target textures and post processes used in the glow layer.
  49246. */
  49247. protected _createTextureAndPostProcesses(): void;
  49248. /**
  49249. * Checks for the readiness of the element composing the layer.
  49250. * @param subMesh the mesh to check for
  49251. * @param useInstances specify wether or not to use instances to render the mesh
  49252. * @param emissiveTexture the associated emissive texture used to generate the glow
  49253. * @return true if ready otherwise, false
  49254. */
  49255. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49256. /**
  49257. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49258. */
  49259. needStencil(): boolean;
  49260. /**
  49261. * Returns true if the mesh can be rendered, otherwise false.
  49262. * @param mesh The mesh to render
  49263. * @param material The material used on the mesh
  49264. * @returns true if it can be rendered otherwise false
  49265. */
  49266. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49267. /**
  49268. * Implementation specific of rendering the generating effect on the main canvas.
  49269. * @param effect The effect used to render through
  49270. */
  49271. protected _internalRender(effect: Effect): void;
  49272. /**
  49273. * Sets the required values for both the emissive texture and and the main color.
  49274. */
  49275. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49276. /**
  49277. * Returns true if the mesh should render, otherwise false.
  49278. * @param mesh The mesh to render
  49279. * @returns true if it should render otherwise false
  49280. */
  49281. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49282. /**
  49283. * Adds specific effects defines.
  49284. * @param defines The defines to add specifics to.
  49285. */
  49286. protected _addCustomEffectDefines(defines: string[]): void;
  49287. /**
  49288. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49289. * @param mesh The mesh to exclude from the glow layer
  49290. */
  49291. addExcludedMesh(mesh: Mesh): void;
  49292. /**
  49293. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49294. * @param mesh The mesh to remove
  49295. */
  49296. removeExcludedMesh(mesh: Mesh): void;
  49297. /**
  49298. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49299. * @param mesh The mesh to include in the glow layer
  49300. */
  49301. addIncludedOnlyMesh(mesh: Mesh): void;
  49302. /**
  49303. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49304. * @param mesh The mesh to remove
  49305. */
  49306. removeIncludedOnlyMesh(mesh: Mesh): void;
  49307. /**
  49308. * Determine if a given mesh will be used in the glow layer
  49309. * @param mesh The mesh to test
  49310. * @returns true if the mesh will be highlighted by the current glow layer
  49311. */
  49312. hasMesh(mesh: AbstractMesh): boolean;
  49313. /**
  49314. * Free any resources and references associated to a mesh.
  49315. * Internal use
  49316. * @param mesh The mesh to free.
  49317. * @hidden
  49318. */
  49319. _disposeMesh(mesh: Mesh): void;
  49320. /**
  49321. * Gets the class name of the effect layer
  49322. * @returns the string with the class name of the effect layer
  49323. */
  49324. getClassName(): string;
  49325. /**
  49326. * Serializes this glow layer
  49327. * @returns a serialized glow layer object
  49328. */
  49329. serialize(): any;
  49330. /**
  49331. * Creates a Glow Layer from parsed glow layer data
  49332. * @param parsedGlowLayer defines glow layer data
  49333. * @param scene defines the current scene
  49334. * @param rootUrl defines the root URL containing the glow layer information
  49335. * @returns a parsed Glow Layer
  49336. */
  49337. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49338. }
  49339. }
  49340. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49341. /** @hidden */
  49342. export var glowBlurPostProcessPixelShader: {
  49343. name: string;
  49344. shader: string;
  49345. };
  49346. }
  49347. declare module "babylonjs/Layers/highlightLayer" {
  49348. import { Observable } from "babylonjs/Misc/observable";
  49349. import { Nullable } from "babylonjs/types";
  49350. import { Camera } from "babylonjs/Cameras/camera";
  49351. import { Scene } from "babylonjs/scene";
  49352. import { Color3, Color4 } from "babylonjs/Maths/math";
  49353. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49355. import { Mesh } from "babylonjs/Meshes/mesh";
  49356. import { Effect } from "babylonjs/Materials/effect";
  49357. import { Material } from "babylonjs/Materials/material";
  49358. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49359. import "babylonjs/Shaders/glowMapMerge.fragment";
  49360. import "babylonjs/Shaders/glowMapMerge.vertex";
  49361. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49362. module "babylonjs/abstractScene" {
  49363. interface AbstractScene {
  49364. /**
  49365. * Return a the first highlight layer of the scene with a given name.
  49366. * @param name The name of the highlight layer to look for.
  49367. * @return The highlight layer if found otherwise null.
  49368. */
  49369. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49370. }
  49371. }
  49372. /**
  49373. * Highlight layer options. This helps customizing the behaviour
  49374. * of the highlight layer.
  49375. */
  49376. export interface IHighlightLayerOptions {
  49377. /**
  49378. * Multiplication factor apply to the canvas size to compute the render target size
  49379. * used to generated the glowing objects (the smaller the faster).
  49380. */
  49381. mainTextureRatio: number;
  49382. /**
  49383. * Enforces a fixed size texture to ensure resize independant blur.
  49384. */
  49385. mainTextureFixedSize?: number;
  49386. /**
  49387. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49388. * of the picture to blur (the smaller the faster).
  49389. */
  49390. blurTextureSizeRatio: number;
  49391. /**
  49392. * How big in texel of the blur texture is the vertical blur.
  49393. */
  49394. blurVerticalSize: number;
  49395. /**
  49396. * How big in texel of the blur texture is the horizontal blur.
  49397. */
  49398. blurHorizontalSize: number;
  49399. /**
  49400. * Alpha blending mode used to apply the blur. Default is combine.
  49401. */
  49402. alphaBlendingMode: number;
  49403. /**
  49404. * The camera attached to the layer.
  49405. */
  49406. camera: Nullable<Camera>;
  49407. /**
  49408. * Should we display highlight as a solid stroke?
  49409. */
  49410. isStroke?: boolean;
  49411. /**
  49412. * The rendering group to draw the layer in.
  49413. */
  49414. renderingGroupId: number;
  49415. }
  49416. /**
  49417. * The highlight layer Helps adding a glow effect around a mesh.
  49418. *
  49419. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49420. * glowy meshes to your scene.
  49421. *
  49422. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49423. */
  49424. export class HighlightLayer extends EffectLayer {
  49425. name: string;
  49426. /**
  49427. * Effect Name of the highlight layer.
  49428. */
  49429. static readonly EffectName: string;
  49430. /**
  49431. * The neutral color used during the preparation of the glow effect.
  49432. * This is black by default as the blend operation is a blend operation.
  49433. */
  49434. static NeutralColor: Color4;
  49435. /**
  49436. * Stencil value used for glowing meshes.
  49437. */
  49438. static GlowingMeshStencilReference: number;
  49439. /**
  49440. * Stencil value used for the other meshes in the scene.
  49441. */
  49442. static NormalMeshStencilReference: number;
  49443. /**
  49444. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49445. */
  49446. innerGlow: boolean;
  49447. /**
  49448. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49449. */
  49450. outerGlow: boolean;
  49451. /**
  49452. * Specifies the horizontal size of the blur.
  49453. */
  49454. /**
  49455. * Gets the horizontal size of the blur.
  49456. */
  49457. blurHorizontalSize: number;
  49458. /**
  49459. * Specifies the vertical size of the blur.
  49460. */
  49461. /**
  49462. * Gets the vertical size of the blur.
  49463. */
  49464. blurVerticalSize: number;
  49465. /**
  49466. * An event triggered when the highlight layer is being blurred.
  49467. */
  49468. onBeforeBlurObservable: Observable<HighlightLayer>;
  49469. /**
  49470. * An event triggered when the highlight layer has been blurred.
  49471. */
  49472. onAfterBlurObservable: Observable<HighlightLayer>;
  49473. private _instanceGlowingMeshStencilReference;
  49474. private _options;
  49475. private _downSamplePostprocess;
  49476. private _horizontalBlurPostprocess;
  49477. private _verticalBlurPostprocess;
  49478. private _blurTexture;
  49479. private _meshes;
  49480. private _excludedMeshes;
  49481. /**
  49482. * Instantiates a new highlight Layer and references it to the scene..
  49483. * @param name The name of the layer
  49484. * @param scene The scene to use the layer in
  49485. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49486. */
  49487. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49488. /**
  49489. * Get the effect name of the layer.
  49490. * @return The effect name
  49491. */
  49492. getEffectName(): string;
  49493. /**
  49494. * Create the merge effect. This is the shader use to blit the information back
  49495. * to the main canvas at the end of the scene rendering.
  49496. */
  49497. protected _createMergeEffect(): Effect;
  49498. /**
  49499. * Creates the render target textures and post processes used in the highlight layer.
  49500. */
  49501. protected _createTextureAndPostProcesses(): void;
  49502. /**
  49503. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49504. */
  49505. needStencil(): boolean;
  49506. /**
  49507. * Checks for the readiness of the element composing the layer.
  49508. * @param subMesh the mesh to check for
  49509. * @param useInstances specify wether or not to use instances to render the mesh
  49510. * @param emissiveTexture the associated emissive texture used to generate the glow
  49511. * @return true if ready otherwise, false
  49512. */
  49513. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49514. /**
  49515. * Implementation specific of rendering the generating effect on the main canvas.
  49516. * @param effect The effect used to render through
  49517. */
  49518. protected _internalRender(effect: Effect): void;
  49519. /**
  49520. * Returns true if the layer contains information to display, otherwise false.
  49521. */
  49522. shouldRender(): boolean;
  49523. /**
  49524. * Returns true if the mesh should render, otherwise false.
  49525. * @param mesh The mesh to render
  49526. * @returns true if it should render otherwise false
  49527. */
  49528. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49529. /**
  49530. * Sets the required values for both the emissive texture and and the main color.
  49531. */
  49532. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49533. /**
  49534. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49535. * @param mesh The mesh to exclude from the highlight layer
  49536. */
  49537. addExcludedMesh(mesh: Mesh): void;
  49538. /**
  49539. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49540. * @param mesh The mesh to highlight
  49541. */
  49542. removeExcludedMesh(mesh: Mesh): void;
  49543. /**
  49544. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49545. * @param mesh mesh to test
  49546. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49547. */
  49548. hasMesh(mesh: AbstractMesh): boolean;
  49549. /**
  49550. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49551. * @param mesh The mesh to highlight
  49552. * @param color The color of the highlight
  49553. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49554. */
  49555. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49556. /**
  49557. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49558. * @param mesh The mesh to highlight
  49559. */
  49560. removeMesh(mesh: Mesh): void;
  49561. /**
  49562. * Force the stencil to the normal expected value for none glowing parts
  49563. */
  49564. private _defaultStencilReference;
  49565. /**
  49566. * Free any resources and references associated to a mesh.
  49567. * Internal use
  49568. * @param mesh The mesh to free.
  49569. * @hidden
  49570. */
  49571. _disposeMesh(mesh: Mesh): void;
  49572. /**
  49573. * Dispose the highlight layer and free resources.
  49574. */
  49575. dispose(): void;
  49576. /**
  49577. * Gets the class name of the effect layer
  49578. * @returns the string with the class name of the effect layer
  49579. */
  49580. getClassName(): string;
  49581. /**
  49582. * Serializes this Highlight layer
  49583. * @returns a serialized Highlight layer object
  49584. */
  49585. serialize(): any;
  49586. /**
  49587. * Creates a Highlight layer from parsed Highlight layer data
  49588. * @param parsedHightlightLayer defines the Highlight layer data
  49589. * @param scene defines the current scene
  49590. * @param rootUrl defines the root URL containing the Highlight layer information
  49591. * @returns a parsed Highlight layer
  49592. */
  49593. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49594. }
  49595. }
  49596. declare module "babylonjs/Layers/index" {
  49597. export * from "babylonjs/Layers/effectLayer";
  49598. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49599. export * from "babylonjs/Layers/glowLayer";
  49600. export * from "babylonjs/Layers/highlightLayer";
  49601. export * from "babylonjs/Layers/layer";
  49602. export * from "babylonjs/Layers/layerSceneComponent";
  49603. }
  49604. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49605. /** @hidden */
  49606. export var lensFlarePixelShader: {
  49607. name: string;
  49608. shader: string;
  49609. };
  49610. }
  49611. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49612. /** @hidden */
  49613. export var lensFlareVertexShader: {
  49614. name: string;
  49615. shader: string;
  49616. };
  49617. }
  49618. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49619. import { Scene } from "babylonjs/scene";
  49620. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49622. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49623. import "babylonjs/Shaders/lensFlare.fragment";
  49624. import "babylonjs/Shaders/lensFlare.vertex";
  49625. /**
  49626. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49627. * It is usually composed of several `lensFlare`.
  49628. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49629. */
  49630. export class LensFlareSystem {
  49631. /**
  49632. * Define the name of the lens flare system
  49633. */
  49634. name: string;
  49635. /**
  49636. * List of lens flares used in this system.
  49637. */
  49638. lensFlares: LensFlare[];
  49639. /**
  49640. * Define a limit from the border the lens flare can be visible.
  49641. */
  49642. borderLimit: number;
  49643. /**
  49644. * Define a viewport border we do not want to see the lens flare in.
  49645. */
  49646. viewportBorder: number;
  49647. /**
  49648. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49649. */
  49650. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49651. /**
  49652. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49653. */
  49654. layerMask: number;
  49655. /**
  49656. * Define the id of the lens flare system in the scene.
  49657. * (equal to name by default)
  49658. */
  49659. id: string;
  49660. private _scene;
  49661. private _emitter;
  49662. private _vertexBuffers;
  49663. private _indexBuffer;
  49664. private _effect;
  49665. private _positionX;
  49666. private _positionY;
  49667. private _isEnabled;
  49668. /** @hidden */
  49669. static _SceneComponentInitialization: (scene: Scene) => void;
  49670. /**
  49671. * Instantiates a lens flare system.
  49672. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49673. * It is usually composed of several `lensFlare`.
  49674. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49675. * @param name Define the name of the lens flare system in the scene
  49676. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49677. * @param scene Define the scene the lens flare system belongs to
  49678. */
  49679. constructor(
  49680. /**
  49681. * Define the name of the lens flare system
  49682. */
  49683. name: string, emitter: any, scene: Scene);
  49684. /**
  49685. * Define if the lens flare system is enabled.
  49686. */
  49687. isEnabled: boolean;
  49688. /**
  49689. * Get the scene the effects belongs to.
  49690. * @returns the scene holding the lens flare system
  49691. */
  49692. getScene(): Scene;
  49693. /**
  49694. * Get the emitter of the lens flare system.
  49695. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49696. * @returns the emitter of the lens flare system
  49697. */
  49698. getEmitter(): any;
  49699. /**
  49700. * Set the emitter of the lens flare system.
  49701. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49702. * @param newEmitter Define the new emitter of the system
  49703. */
  49704. setEmitter(newEmitter: any): void;
  49705. /**
  49706. * Get the lens flare system emitter position.
  49707. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49708. * @returns the position
  49709. */
  49710. getEmitterPosition(): Vector3;
  49711. /**
  49712. * @hidden
  49713. */
  49714. computeEffectivePosition(globalViewport: Viewport): boolean;
  49715. /** @hidden */
  49716. _isVisible(): boolean;
  49717. /**
  49718. * @hidden
  49719. */
  49720. render(): boolean;
  49721. /**
  49722. * Dispose and release the lens flare with its associated resources.
  49723. */
  49724. dispose(): void;
  49725. /**
  49726. * Parse a lens flare system from a JSON repressentation
  49727. * @param parsedLensFlareSystem Define the JSON to parse
  49728. * @param scene Define the scene the parsed system should be instantiated in
  49729. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49730. * @returns the parsed system
  49731. */
  49732. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49733. /**
  49734. * Serialize the current Lens Flare System into a JSON representation.
  49735. * @returns the serialized JSON
  49736. */
  49737. serialize(): any;
  49738. }
  49739. }
  49740. declare module "babylonjs/LensFlares/lensFlare" {
  49741. import { Nullable } from "babylonjs/types";
  49742. import { Color3 } from "babylonjs/Maths/math";
  49743. import { Texture } from "babylonjs/Materials/Textures/texture";
  49744. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49745. /**
  49746. * This represents one of the lens effect in a `lensFlareSystem`.
  49747. * It controls one of the indiviual texture used in the effect.
  49748. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49749. */
  49750. export class LensFlare {
  49751. /**
  49752. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49753. */
  49754. size: number;
  49755. /**
  49756. * 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.
  49757. */
  49758. position: number;
  49759. /**
  49760. * Define the lens color.
  49761. */
  49762. color: Color3;
  49763. /**
  49764. * Define the lens texture.
  49765. */
  49766. texture: Nullable<Texture>;
  49767. /**
  49768. * Define the alpha mode to render this particular lens.
  49769. */
  49770. alphaMode: number;
  49771. private _system;
  49772. /**
  49773. * Creates a new Lens Flare.
  49774. * This represents one of the lens effect in a `lensFlareSystem`.
  49775. * It controls one of the indiviual texture used in the effect.
  49776. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49777. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49778. * @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.
  49779. * @param color Define the lens color
  49780. * @param imgUrl Define the lens texture url
  49781. * @param system Define the `lensFlareSystem` this flare is part of
  49782. * @returns The newly created Lens Flare
  49783. */
  49784. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49785. /**
  49786. * Instantiates a new Lens Flare.
  49787. * This represents one of the lens effect in a `lensFlareSystem`.
  49788. * It controls one of the indiviual texture used in the effect.
  49789. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49790. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49791. * @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.
  49792. * @param color Define the lens color
  49793. * @param imgUrl Define the lens texture url
  49794. * @param system Define the `lensFlareSystem` this flare is part of
  49795. */
  49796. constructor(
  49797. /**
  49798. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49799. */
  49800. size: number,
  49801. /**
  49802. * 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.
  49803. */
  49804. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49805. /**
  49806. * Dispose and release the lens flare with its associated resources.
  49807. */
  49808. dispose(): void;
  49809. }
  49810. }
  49811. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49812. import { Nullable } from "babylonjs/types";
  49813. import { Scene } from "babylonjs/scene";
  49814. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49815. import { AbstractScene } from "babylonjs/abstractScene";
  49816. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49817. module "babylonjs/abstractScene" {
  49818. interface AbstractScene {
  49819. /**
  49820. * The list of lens flare system added to the scene
  49821. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49822. */
  49823. lensFlareSystems: Array<LensFlareSystem>;
  49824. /**
  49825. * Removes the given lens flare system from this scene.
  49826. * @param toRemove The lens flare system to remove
  49827. * @returns The index of the removed lens flare system
  49828. */
  49829. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49830. /**
  49831. * Adds the given lens flare system to this scene
  49832. * @param newLensFlareSystem The lens flare system to add
  49833. */
  49834. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49835. /**
  49836. * Gets a lens flare system using its name
  49837. * @param name defines the name to look for
  49838. * @returns the lens flare system or null if not found
  49839. */
  49840. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49841. /**
  49842. * Gets a lens flare system using its id
  49843. * @param id defines the id to look for
  49844. * @returns the lens flare system or null if not found
  49845. */
  49846. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49847. }
  49848. }
  49849. /**
  49850. * Defines the lens flare scene component responsible to manage any lens flares
  49851. * in a given scene.
  49852. */
  49853. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49854. /**
  49855. * The component name helpfull to identify the component in the list of scene components.
  49856. */
  49857. readonly name: string;
  49858. /**
  49859. * The scene the component belongs to.
  49860. */
  49861. scene: Scene;
  49862. /**
  49863. * Creates a new instance of the component for the given scene
  49864. * @param scene Defines the scene to register the component in
  49865. */
  49866. constructor(scene: Scene);
  49867. /**
  49868. * Registers the component in a given scene
  49869. */
  49870. register(): void;
  49871. /**
  49872. * Rebuilds the elements related to this component in case of
  49873. * context lost for instance.
  49874. */
  49875. rebuild(): void;
  49876. /**
  49877. * Adds all the element from the container to the scene
  49878. * @param container the container holding the elements
  49879. */
  49880. addFromContainer(container: AbstractScene): void;
  49881. /**
  49882. * Removes all the elements in the container from the scene
  49883. * @param container contains the elements to remove
  49884. * @param dispose if the removed element should be disposed (default: false)
  49885. */
  49886. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49887. /**
  49888. * Serializes the component data to the specified json object
  49889. * @param serializationObject The object to serialize to
  49890. */
  49891. serialize(serializationObject: any): void;
  49892. /**
  49893. * Disposes the component and the associated ressources.
  49894. */
  49895. dispose(): void;
  49896. private _draw;
  49897. }
  49898. }
  49899. declare module "babylonjs/LensFlares/index" {
  49900. export * from "babylonjs/LensFlares/lensFlare";
  49901. export * from "babylonjs/LensFlares/lensFlareSystem";
  49902. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49903. }
  49904. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49905. import { Scene } from "babylonjs/scene";
  49906. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49907. import { AbstractScene } from "babylonjs/abstractScene";
  49908. /**
  49909. * Defines the shadow generator component responsible to manage any shadow generators
  49910. * in a given scene.
  49911. */
  49912. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49913. /**
  49914. * The component name helpfull to identify the component in the list of scene components.
  49915. */
  49916. readonly name: string;
  49917. /**
  49918. * The scene the component belongs to.
  49919. */
  49920. scene: Scene;
  49921. /**
  49922. * Creates a new instance of the component for the given scene
  49923. * @param scene Defines the scene to register the component in
  49924. */
  49925. constructor(scene: Scene);
  49926. /**
  49927. * Registers the component in a given scene
  49928. */
  49929. register(): void;
  49930. /**
  49931. * Rebuilds the elements related to this component in case of
  49932. * context lost for instance.
  49933. */
  49934. rebuild(): void;
  49935. /**
  49936. * Serializes the component data to the specified json object
  49937. * @param serializationObject The object to serialize to
  49938. */
  49939. serialize(serializationObject: any): void;
  49940. /**
  49941. * Adds all the element from the container to the scene
  49942. * @param container the container holding the elements
  49943. */
  49944. addFromContainer(container: AbstractScene): void;
  49945. /**
  49946. * Removes all the elements in the container from the scene
  49947. * @param container contains the elements to remove
  49948. * @param dispose if the removed element should be disposed (default: false)
  49949. */
  49950. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49951. /**
  49952. * Rebuilds the elements related to this component in case of
  49953. * context lost for instance.
  49954. */
  49955. dispose(): void;
  49956. private _gatherRenderTargets;
  49957. }
  49958. }
  49959. declare module "babylonjs/Lights/Shadows/index" {
  49960. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49961. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49962. }
  49963. declare module "babylonjs/Lights/pointLight" {
  49964. import { Scene } from "babylonjs/scene";
  49965. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49967. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49968. import { Effect } from "babylonjs/Materials/effect";
  49969. /**
  49970. * A point light is a light defined by an unique point in world space.
  49971. * The light is emitted in every direction from this point.
  49972. * A good example of a point light is a standard light bulb.
  49973. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49974. */
  49975. export class PointLight extends ShadowLight {
  49976. private _shadowAngle;
  49977. /**
  49978. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49979. * This specifies what angle the shadow will use to be created.
  49980. *
  49981. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49982. */
  49983. /**
  49984. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49985. * This specifies what angle the shadow will use to be created.
  49986. *
  49987. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49988. */
  49989. shadowAngle: number;
  49990. /**
  49991. * Gets the direction if it has been set.
  49992. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49993. */
  49994. /**
  49995. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49996. */
  49997. direction: Vector3;
  49998. /**
  49999. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50000. * A PointLight emits the light in every direction.
  50001. * It can cast shadows.
  50002. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50003. * ```javascript
  50004. * var pointLight = new PointLight("pl", camera.position, scene);
  50005. * ```
  50006. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50007. * @param name The light friendly name
  50008. * @param position The position of the point light in the scene
  50009. * @param scene The scene the lights belongs to
  50010. */
  50011. constructor(name: string, position: Vector3, scene: Scene);
  50012. /**
  50013. * Returns the string "PointLight"
  50014. * @returns the class name
  50015. */
  50016. getClassName(): string;
  50017. /**
  50018. * Returns the integer 0.
  50019. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50020. */
  50021. getTypeID(): number;
  50022. /**
  50023. * Specifies wether or not the shadowmap should be a cube texture.
  50024. * @returns true if the shadowmap needs to be a cube texture.
  50025. */
  50026. needCube(): boolean;
  50027. /**
  50028. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50029. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50030. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50031. */
  50032. getShadowDirection(faceIndex?: number): Vector3;
  50033. /**
  50034. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50035. * - fov = PI / 2
  50036. * - aspect ratio : 1.0
  50037. * - z-near and far equal to the active camera minZ and maxZ.
  50038. * Returns the PointLight.
  50039. */
  50040. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50041. protected _buildUniformLayout(): void;
  50042. /**
  50043. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50044. * @param effect The effect to update
  50045. * @param lightIndex The index of the light in the effect to update
  50046. * @returns The point light
  50047. */
  50048. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50049. /**
  50050. * Prepares the list of defines specific to the light type.
  50051. * @param defines the list of defines
  50052. * @param lightIndex defines the index of the light for the effect
  50053. */
  50054. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50055. }
  50056. }
  50057. declare module "babylonjs/Lights/index" {
  50058. export * from "babylonjs/Lights/light";
  50059. export * from "babylonjs/Lights/shadowLight";
  50060. export * from "babylonjs/Lights/Shadows/index";
  50061. export * from "babylonjs/Lights/directionalLight";
  50062. export * from "babylonjs/Lights/hemisphericLight";
  50063. export * from "babylonjs/Lights/pointLight";
  50064. export * from "babylonjs/Lights/spotLight";
  50065. }
  50066. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50067. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50068. /**
  50069. * Header information of HDR texture files.
  50070. */
  50071. export interface HDRInfo {
  50072. /**
  50073. * The height of the texture in pixels.
  50074. */
  50075. height: number;
  50076. /**
  50077. * The width of the texture in pixels.
  50078. */
  50079. width: number;
  50080. /**
  50081. * The index of the beginning of the data in the binary file.
  50082. */
  50083. dataPosition: number;
  50084. }
  50085. /**
  50086. * This groups tools to convert HDR texture to native colors array.
  50087. */
  50088. export class HDRTools {
  50089. private static Ldexp;
  50090. private static Rgbe2float;
  50091. private static readStringLine;
  50092. /**
  50093. * Reads header information from an RGBE texture stored in a native array.
  50094. * More information on this format are available here:
  50095. * https://en.wikipedia.org/wiki/RGBE_image_format
  50096. *
  50097. * @param uint8array The binary file stored in native array.
  50098. * @return The header information.
  50099. */
  50100. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50101. /**
  50102. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50103. * This RGBE texture needs to store the information as a panorama.
  50104. *
  50105. * More information on this format are available here:
  50106. * https://en.wikipedia.org/wiki/RGBE_image_format
  50107. *
  50108. * @param buffer The binary file stored in an array buffer.
  50109. * @param size The expected size of the extracted cubemap.
  50110. * @return The Cube Map information.
  50111. */
  50112. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50113. /**
  50114. * Returns the pixels data extracted from an RGBE texture.
  50115. * This pixels will be stored left to right up to down in the R G B order in one array.
  50116. *
  50117. * More information on this format are available here:
  50118. * https://en.wikipedia.org/wiki/RGBE_image_format
  50119. *
  50120. * @param uint8array The binary file stored in an array buffer.
  50121. * @param hdrInfo The header information of the file.
  50122. * @return The pixels data in RGB right to left up to down order.
  50123. */
  50124. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50125. private static RGBE_ReadPixels_RLE;
  50126. }
  50127. }
  50128. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50129. import { Nullable } from "babylonjs/types";
  50130. import { Scene } from "babylonjs/scene";
  50131. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50133. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50134. /**
  50135. * This represents a texture coming from an HDR input.
  50136. *
  50137. * The only supported format is currently panorama picture stored in RGBE format.
  50138. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50139. */
  50140. export class HDRCubeTexture extends BaseTexture {
  50141. private static _facesMapping;
  50142. private _generateHarmonics;
  50143. private _noMipmap;
  50144. private _textureMatrix;
  50145. private _size;
  50146. private _onLoad;
  50147. private _onError;
  50148. /**
  50149. * The texture URL.
  50150. */
  50151. url: string;
  50152. /**
  50153. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50154. */
  50155. coordinatesMode: number;
  50156. protected _isBlocking: boolean;
  50157. /**
  50158. * Sets wether or not the texture is blocking during loading.
  50159. */
  50160. /**
  50161. * Gets wether or not the texture is blocking during loading.
  50162. */
  50163. isBlocking: boolean;
  50164. protected _rotationY: number;
  50165. /**
  50166. * Sets texture matrix rotation angle around Y axis in radians.
  50167. */
  50168. /**
  50169. * Gets texture matrix rotation angle around Y axis radians.
  50170. */
  50171. rotationY: number;
  50172. /**
  50173. * Gets or sets the center of the bounding box associated with the cube texture
  50174. * It must define where the camera used to render the texture was set
  50175. */
  50176. boundingBoxPosition: Vector3;
  50177. private _boundingBoxSize;
  50178. /**
  50179. * Gets or sets the size of the bounding box associated with the cube texture
  50180. * When defined, the cubemap will switch to local mode
  50181. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50182. * @example https://www.babylonjs-playground.com/#RNASML
  50183. */
  50184. boundingBoxSize: Vector3;
  50185. /**
  50186. * Instantiates an HDRTexture from the following parameters.
  50187. *
  50188. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50189. * @param scene The scene the texture will be used in
  50190. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50191. * @param noMipmap Forces to not generate the mipmap if true
  50192. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50193. * @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)
  50194. * @param reserved Reserved flag for internal use.
  50195. */
  50196. 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>);
  50197. /**
  50198. * Get the current class name of the texture useful for serialization or dynamic coding.
  50199. * @returns "HDRCubeTexture"
  50200. */
  50201. getClassName(): string;
  50202. /**
  50203. * Occurs when the file is raw .hdr file.
  50204. */
  50205. private loadTexture;
  50206. clone(): HDRCubeTexture;
  50207. delayLoad(): void;
  50208. /**
  50209. * Get the texture reflection matrix used to rotate/transform the reflection.
  50210. * @returns the reflection matrix
  50211. */
  50212. getReflectionTextureMatrix(): Matrix;
  50213. /**
  50214. * Set the texture reflection matrix used to rotate/transform the reflection.
  50215. * @param value Define the reflection matrix to set
  50216. */
  50217. setReflectionTextureMatrix(value: Matrix): void;
  50218. /**
  50219. * Parses a JSON representation of an HDR Texture in order to create the texture
  50220. * @param parsedTexture Define the JSON representation
  50221. * @param scene Define the scene the texture should be created in
  50222. * @param rootUrl Define the root url in case we need to load relative dependencies
  50223. * @returns the newly created texture after parsing
  50224. */
  50225. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50226. serialize(): any;
  50227. }
  50228. }
  50229. declare module "babylonjs/Physics/physicsEngine" {
  50230. import { Nullable } from "babylonjs/types";
  50231. import { Vector3 } from "babylonjs/Maths/math";
  50232. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50233. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50234. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50235. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50236. /**
  50237. * Class used to control physics engine
  50238. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50239. */
  50240. export class PhysicsEngine implements IPhysicsEngine {
  50241. private _physicsPlugin;
  50242. /**
  50243. * Global value used to control the smallest number supported by the simulation
  50244. */
  50245. static Epsilon: number;
  50246. private _impostors;
  50247. private _joints;
  50248. /**
  50249. * Gets the gravity vector used by the simulation
  50250. */
  50251. gravity: Vector3;
  50252. /**
  50253. * Factory used to create the default physics plugin.
  50254. * @returns The default physics plugin
  50255. */
  50256. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50257. /**
  50258. * Creates a new Physics Engine
  50259. * @param gravity defines the gravity vector used by the simulation
  50260. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50261. */
  50262. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50263. /**
  50264. * Sets the gravity vector used by the simulation
  50265. * @param gravity defines the gravity vector to use
  50266. */
  50267. setGravity(gravity: Vector3): void;
  50268. /**
  50269. * Set the time step of the physics engine.
  50270. * Default is 1/60.
  50271. * To slow it down, enter 1/600 for example.
  50272. * To speed it up, 1/30
  50273. * @param newTimeStep defines the new timestep to apply to this world.
  50274. */
  50275. setTimeStep(newTimeStep?: number): void;
  50276. /**
  50277. * Get the time step of the physics engine.
  50278. * @returns the current time step
  50279. */
  50280. getTimeStep(): number;
  50281. /**
  50282. * Release all resources
  50283. */
  50284. dispose(): void;
  50285. /**
  50286. * Gets the name of the current physics plugin
  50287. * @returns the name of the plugin
  50288. */
  50289. getPhysicsPluginName(): string;
  50290. /**
  50291. * Adding a new impostor for the impostor tracking.
  50292. * This will be done by the impostor itself.
  50293. * @param impostor the impostor to add
  50294. */
  50295. addImpostor(impostor: PhysicsImpostor): void;
  50296. /**
  50297. * Remove an impostor from the engine.
  50298. * This impostor and its mesh will not longer be updated by the physics engine.
  50299. * @param impostor the impostor to remove
  50300. */
  50301. removeImpostor(impostor: PhysicsImpostor): void;
  50302. /**
  50303. * Add a joint to the physics engine
  50304. * @param mainImpostor defines the main impostor to which the joint is added.
  50305. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50306. * @param joint defines the joint that will connect both impostors.
  50307. */
  50308. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50309. /**
  50310. * Removes a joint from the simulation
  50311. * @param mainImpostor defines the impostor used with the joint
  50312. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50313. * @param joint defines the joint to remove
  50314. */
  50315. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50316. /**
  50317. * Called by the scene. No need to call it.
  50318. * @param delta defines the timespam between frames
  50319. */
  50320. _step(delta: number): void;
  50321. /**
  50322. * Gets the current plugin used to run the simulation
  50323. * @returns current plugin
  50324. */
  50325. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50326. /**
  50327. * Gets the list of physic impostors
  50328. * @returns an array of PhysicsImpostor
  50329. */
  50330. getImpostors(): Array<PhysicsImpostor>;
  50331. /**
  50332. * Gets the impostor for a physics enabled object
  50333. * @param object defines the object impersonated by the impostor
  50334. * @returns the PhysicsImpostor or null if not found
  50335. */
  50336. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50337. /**
  50338. * Gets the impostor for a physics body object
  50339. * @param body defines physics body used by the impostor
  50340. * @returns the PhysicsImpostor or null if not found
  50341. */
  50342. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50343. /**
  50344. * Does a raycast in the physics world
  50345. * @param from when should the ray start?
  50346. * @param to when should the ray end?
  50347. * @returns PhysicsRaycastResult
  50348. */
  50349. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50350. }
  50351. }
  50352. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50353. import { Nullable } from "babylonjs/types";
  50354. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50356. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50357. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50358. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50359. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50360. /** @hidden */
  50361. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50362. private _useDeltaForWorldStep;
  50363. world: any;
  50364. name: string;
  50365. private _physicsMaterials;
  50366. private _fixedTimeStep;
  50367. private _cannonRaycastResult;
  50368. private _raycastResult;
  50369. private _removeAfterStep;
  50370. BJSCANNON: any;
  50371. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50372. setGravity(gravity: Vector3): void;
  50373. setTimeStep(timeStep: number): void;
  50374. getTimeStep(): number;
  50375. executeStep(delta: number): void;
  50376. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50377. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50378. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50379. private _processChildMeshes;
  50380. removePhysicsBody(impostor: PhysicsImpostor): void;
  50381. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50382. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50383. private _addMaterial;
  50384. private _checkWithEpsilon;
  50385. private _createShape;
  50386. private _createHeightmap;
  50387. private _minus90X;
  50388. private _plus90X;
  50389. private _tmpPosition;
  50390. private _tmpDeltaPosition;
  50391. private _tmpUnityRotation;
  50392. private _updatePhysicsBodyTransformation;
  50393. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50394. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50395. isSupported(): boolean;
  50396. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50397. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50398. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50399. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50400. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50401. getBodyMass(impostor: PhysicsImpostor): number;
  50402. getBodyFriction(impostor: PhysicsImpostor): number;
  50403. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50404. getBodyRestitution(impostor: PhysicsImpostor): number;
  50405. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50406. sleepBody(impostor: PhysicsImpostor): void;
  50407. wakeUpBody(impostor: PhysicsImpostor): void;
  50408. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50409. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50410. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50411. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50412. getRadius(impostor: PhysicsImpostor): number;
  50413. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50414. dispose(): void;
  50415. private _extendNamespace;
  50416. /**
  50417. * Does a raycast in the physics world
  50418. * @param from when should the ray start?
  50419. * @param to when should the ray end?
  50420. * @returns PhysicsRaycastResult
  50421. */
  50422. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50423. }
  50424. }
  50425. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50426. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50427. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50428. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50430. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50431. import { Nullable } from "babylonjs/types";
  50432. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50433. /** @hidden */
  50434. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50435. world: any;
  50436. name: string;
  50437. BJSOIMO: any;
  50438. private _raycastResult;
  50439. constructor(iterations?: number, oimoInjection?: any);
  50440. setGravity(gravity: Vector3): void;
  50441. setTimeStep(timeStep: number): void;
  50442. getTimeStep(): number;
  50443. private _tmpImpostorsArray;
  50444. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50445. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50446. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50447. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50448. private _tmpPositionVector;
  50449. removePhysicsBody(impostor: PhysicsImpostor): void;
  50450. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50451. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50452. isSupported(): boolean;
  50453. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50454. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50455. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50456. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50457. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50458. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50459. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50460. getBodyMass(impostor: PhysicsImpostor): number;
  50461. getBodyFriction(impostor: PhysicsImpostor): number;
  50462. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50463. getBodyRestitution(impostor: PhysicsImpostor): number;
  50464. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50465. sleepBody(impostor: PhysicsImpostor): void;
  50466. wakeUpBody(impostor: PhysicsImpostor): void;
  50467. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50468. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50469. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50470. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50471. getRadius(impostor: PhysicsImpostor): number;
  50472. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50473. dispose(): void;
  50474. /**
  50475. * Does a raycast in the physics world
  50476. * @param from when should the ray start?
  50477. * @param to when should the ray end?
  50478. * @returns PhysicsRaycastResult
  50479. */
  50480. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50481. }
  50482. }
  50483. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50484. import { Nullable } from "babylonjs/types";
  50485. import { Scene } from "babylonjs/scene";
  50486. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50487. import { Mesh } from "babylonjs/Meshes/mesh";
  50488. /**
  50489. * Class containing static functions to help procedurally build meshes
  50490. */
  50491. export class RibbonBuilder {
  50492. /**
  50493. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50494. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50495. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50496. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50497. * * 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
  50498. * * 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
  50499. * * 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
  50500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50502. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50503. * * 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
  50504. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50505. * * 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
  50506. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50508. * @param name defines the name of the mesh
  50509. * @param options defines the options used to create the mesh
  50510. * @param scene defines the hosting scene
  50511. * @returns the ribbon mesh
  50512. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50513. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50514. */
  50515. static CreateRibbon(name: string, options: {
  50516. pathArray: Vector3[][];
  50517. closeArray?: boolean;
  50518. closePath?: boolean;
  50519. offset?: number;
  50520. updatable?: boolean;
  50521. sideOrientation?: number;
  50522. frontUVs?: Vector4;
  50523. backUVs?: Vector4;
  50524. instance?: Mesh;
  50525. invertUV?: boolean;
  50526. uvs?: Vector2[];
  50527. colors?: Color4[];
  50528. }, scene?: Nullable<Scene>): Mesh;
  50529. }
  50530. }
  50531. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50532. import { Nullable } from "babylonjs/types";
  50533. import { Scene } from "babylonjs/scene";
  50534. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50535. import { Mesh } from "babylonjs/Meshes/mesh";
  50536. /**
  50537. * Class containing static functions to help procedurally build meshes
  50538. */
  50539. export class ShapeBuilder {
  50540. /**
  50541. * 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.
  50542. * * 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.
  50543. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50544. * * 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.
  50545. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50546. * * 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
  50547. * * 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
  50548. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50551. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50553. * @param name defines the name of the mesh
  50554. * @param options defines the options used to create the mesh
  50555. * @param scene defines the hosting scene
  50556. * @returns the extruded shape mesh
  50557. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50559. */
  50560. static ExtrudeShape(name: string, options: {
  50561. shape: Vector3[];
  50562. path: Vector3[];
  50563. scale?: number;
  50564. rotation?: number;
  50565. cap?: number;
  50566. updatable?: boolean;
  50567. sideOrientation?: number;
  50568. frontUVs?: Vector4;
  50569. backUVs?: Vector4;
  50570. instance?: Mesh;
  50571. invertUV?: boolean;
  50572. }, scene?: Nullable<Scene>): Mesh;
  50573. /**
  50574. * Creates an custom extruded shape mesh.
  50575. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50576. * * 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.
  50577. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50578. * * 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
  50579. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50580. * * 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
  50581. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50582. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50583. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50584. * * 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
  50585. * * 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
  50586. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50589. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50591. * @param name defines the name of the mesh
  50592. * @param options defines the options used to create the mesh
  50593. * @param scene defines the hosting scene
  50594. * @returns the custom extruded shape mesh
  50595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50596. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50598. */
  50599. static ExtrudeShapeCustom(name: string, options: {
  50600. shape: Vector3[];
  50601. path: Vector3[];
  50602. scaleFunction?: any;
  50603. rotationFunction?: any;
  50604. ribbonCloseArray?: boolean;
  50605. ribbonClosePath?: boolean;
  50606. cap?: number;
  50607. updatable?: boolean;
  50608. sideOrientation?: number;
  50609. frontUVs?: Vector4;
  50610. backUVs?: Vector4;
  50611. instance?: Mesh;
  50612. invertUV?: boolean;
  50613. }, scene?: Nullable<Scene>): Mesh;
  50614. private static _ExtrudeShapeGeneric;
  50615. }
  50616. }
  50617. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50618. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50619. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50620. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50621. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50622. import { Nullable } from "babylonjs/types";
  50623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50624. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50625. /**
  50626. * AmmoJS Physics plugin
  50627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50628. * @see https://github.com/kripken/ammo.js/
  50629. */
  50630. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50631. private _useDeltaForWorldStep;
  50632. /**
  50633. * Reference to the Ammo library
  50634. */
  50635. bjsAMMO: any;
  50636. /**
  50637. * Created ammoJS world which physics bodies are added to
  50638. */
  50639. world: any;
  50640. /**
  50641. * Name of the plugin
  50642. */
  50643. name: string;
  50644. private _timeStep;
  50645. private _fixedTimeStep;
  50646. private _maxSteps;
  50647. private _tmpQuaternion;
  50648. private _tmpAmmoTransform;
  50649. private _tmpAmmoQuaternion;
  50650. private _tmpAmmoConcreteContactResultCallback;
  50651. private _collisionConfiguration;
  50652. private _dispatcher;
  50653. private _overlappingPairCache;
  50654. private _solver;
  50655. private _softBodySolver;
  50656. private _tmpAmmoVectorA;
  50657. private _tmpAmmoVectorB;
  50658. private _tmpAmmoVectorC;
  50659. private _tmpAmmoVectorD;
  50660. private _tmpContactCallbackResult;
  50661. private _tmpAmmoVectorRCA;
  50662. private _tmpAmmoVectorRCB;
  50663. private _raycastResult;
  50664. private static readonly DISABLE_COLLISION_FLAG;
  50665. private static readonly KINEMATIC_FLAG;
  50666. private static readonly DISABLE_DEACTIVATION_FLAG;
  50667. /**
  50668. * Initializes the ammoJS plugin
  50669. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50670. * @param ammoInjection can be used to inject your own ammo reference
  50671. */
  50672. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50673. /**
  50674. * Sets the gravity of the physics world (m/(s^2))
  50675. * @param gravity Gravity to set
  50676. */
  50677. setGravity(gravity: Vector3): void;
  50678. /**
  50679. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50680. * @param timeStep timestep to use in seconds
  50681. */
  50682. setTimeStep(timeStep: number): void;
  50683. /**
  50684. * 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)
  50685. * @param fixedTimeStep fixedTimeStep to use in seconds
  50686. */
  50687. setFixedTimeStep(fixedTimeStep: number): void;
  50688. /**
  50689. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50690. * @param maxSteps the maximum number of steps by the physics engine per frame
  50691. */
  50692. setMaxSteps(maxSteps: number): void;
  50693. /**
  50694. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50695. * @returns the current timestep in seconds
  50696. */
  50697. getTimeStep(): number;
  50698. private _isImpostorInContact;
  50699. private _isImpostorPairInContact;
  50700. private _stepSimulation;
  50701. /**
  50702. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50703. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50704. * After the step the babylon meshes are set to the position of the physics imposters
  50705. * @param delta amount of time to step forward
  50706. * @param impostors array of imposters to update before/after the step
  50707. */
  50708. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50709. /**
  50710. * Update babylon mesh to match physics world object
  50711. * @param impostor imposter to match
  50712. */
  50713. private _afterSoftStep;
  50714. /**
  50715. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50716. * @param impostor imposter to match
  50717. */
  50718. private _ropeStep;
  50719. /**
  50720. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50721. * @param impostor imposter to match
  50722. */
  50723. private _softbodyOrClothStep;
  50724. private _tmpVector;
  50725. private _tmpMatrix;
  50726. /**
  50727. * Applies an impulse on the imposter
  50728. * @param impostor imposter to apply impulse to
  50729. * @param force amount of force to be applied to the imposter
  50730. * @param contactPoint the location to apply the impulse on the imposter
  50731. */
  50732. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50733. /**
  50734. * Applies a force on the imposter
  50735. * @param impostor imposter to apply force
  50736. * @param force amount of force to be applied to the imposter
  50737. * @param contactPoint the location to apply the force on the imposter
  50738. */
  50739. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50740. /**
  50741. * Creates a physics body using the plugin
  50742. * @param impostor the imposter to create the physics body on
  50743. */
  50744. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50745. /**
  50746. * Removes the physics body from the imposter and disposes of the body's memory
  50747. * @param impostor imposter to remove the physics body from
  50748. */
  50749. removePhysicsBody(impostor: PhysicsImpostor): void;
  50750. /**
  50751. * Generates a joint
  50752. * @param impostorJoint the imposter joint to create the joint with
  50753. */
  50754. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50755. /**
  50756. * Removes a joint
  50757. * @param impostorJoint the imposter joint to remove the joint from
  50758. */
  50759. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50760. private _addMeshVerts;
  50761. /**
  50762. * Initialise the soft body vertices to match its object's (mesh) vertices
  50763. * Softbody vertices (nodes) are in world space and to match this
  50764. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50765. * @param impostor to create the softbody for
  50766. */
  50767. private _softVertexData;
  50768. /**
  50769. * Create an impostor's soft body
  50770. * @param impostor to create the softbody for
  50771. */
  50772. private _createSoftbody;
  50773. /**
  50774. * Create cloth for an impostor
  50775. * @param impostor to create the softbody for
  50776. */
  50777. private _createCloth;
  50778. /**
  50779. * Create rope for an impostor
  50780. * @param impostor to create the softbody for
  50781. */
  50782. private _createRope;
  50783. private _addHullVerts;
  50784. private _createShape;
  50785. /**
  50786. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50787. * @param impostor imposter containing the physics body and babylon object
  50788. */
  50789. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50790. /**
  50791. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50792. * @param impostor imposter containing the physics body and babylon object
  50793. * @param newPosition new position
  50794. * @param newRotation new rotation
  50795. */
  50796. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50797. /**
  50798. * If this plugin is supported
  50799. * @returns true if its supported
  50800. */
  50801. isSupported(): boolean;
  50802. /**
  50803. * Sets the linear velocity of the physics body
  50804. * @param impostor imposter to set the velocity on
  50805. * @param velocity velocity to set
  50806. */
  50807. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50808. /**
  50809. * Sets the angular velocity of the physics body
  50810. * @param impostor imposter to set the velocity on
  50811. * @param velocity velocity to set
  50812. */
  50813. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50814. /**
  50815. * gets the linear velocity
  50816. * @param impostor imposter to get linear velocity from
  50817. * @returns linear velocity
  50818. */
  50819. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50820. /**
  50821. * gets the angular velocity
  50822. * @param impostor imposter to get angular velocity from
  50823. * @returns angular velocity
  50824. */
  50825. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50826. /**
  50827. * Sets the mass of physics body
  50828. * @param impostor imposter to set the mass on
  50829. * @param mass mass to set
  50830. */
  50831. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50832. /**
  50833. * Gets the mass of the physics body
  50834. * @param impostor imposter to get the mass from
  50835. * @returns mass
  50836. */
  50837. getBodyMass(impostor: PhysicsImpostor): number;
  50838. /**
  50839. * Gets friction of the impostor
  50840. * @param impostor impostor to get friction from
  50841. * @returns friction value
  50842. */
  50843. getBodyFriction(impostor: PhysicsImpostor): number;
  50844. /**
  50845. * Sets friction of the impostor
  50846. * @param impostor impostor to set friction on
  50847. * @param friction friction value
  50848. */
  50849. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50850. /**
  50851. * Gets restitution of the impostor
  50852. * @param impostor impostor to get restitution from
  50853. * @returns restitution value
  50854. */
  50855. getBodyRestitution(impostor: PhysicsImpostor): number;
  50856. /**
  50857. * Sets resitution of the impostor
  50858. * @param impostor impostor to set resitution on
  50859. * @param restitution resitution value
  50860. */
  50861. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50862. /**
  50863. * Gets pressure inside the impostor
  50864. * @param impostor impostor to get pressure from
  50865. * @returns pressure value
  50866. */
  50867. getBodyPressure(impostor: PhysicsImpostor): number;
  50868. /**
  50869. * Sets pressure inside a soft body impostor
  50870. * Cloth and rope must remain 0 pressure
  50871. * @param impostor impostor to set pressure on
  50872. * @param pressure pressure value
  50873. */
  50874. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50875. /**
  50876. * Gets stiffness of the impostor
  50877. * @param impostor impostor to get stiffness from
  50878. * @returns pressure value
  50879. */
  50880. getBodyStiffness(impostor: PhysicsImpostor): number;
  50881. /**
  50882. * Sets stiffness of the impostor
  50883. * @param impostor impostor to set stiffness on
  50884. * @param stiffness stiffness value from 0 to 1
  50885. */
  50886. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50887. /**
  50888. * Gets velocityIterations of the impostor
  50889. * @param impostor impostor to get velocity iterations from
  50890. * @returns velocityIterations value
  50891. */
  50892. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50893. /**
  50894. * Sets velocityIterations of the impostor
  50895. * @param impostor impostor to set velocity iterations on
  50896. * @param velocityIterations velocityIterations value
  50897. */
  50898. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50899. /**
  50900. * Gets positionIterations of the impostor
  50901. * @param impostor impostor to get position iterations from
  50902. * @returns positionIterations value
  50903. */
  50904. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50905. /**
  50906. * Sets positionIterations of the impostor
  50907. * @param impostor impostor to set position on
  50908. * @param positionIterations positionIterations value
  50909. */
  50910. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50911. /**
  50912. * Append an anchor to a cloth object
  50913. * @param impostor is the cloth impostor to add anchor to
  50914. * @param otherImpostor is the rigid impostor to anchor to
  50915. * @param width ratio across width from 0 to 1
  50916. * @param height ratio up height from 0 to 1
  50917. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50918. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50919. */
  50920. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50921. /**
  50922. * Append an hook to a rope object
  50923. * @param impostor is the rope impostor to add hook to
  50924. * @param otherImpostor is the rigid impostor to hook to
  50925. * @param length ratio along the rope from 0 to 1
  50926. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50927. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50928. */
  50929. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50930. /**
  50931. * Sleeps the physics body and stops it from being active
  50932. * @param impostor impostor to sleep
  50933. */
  50934. sleepBody(impostor: PhysicsImpostor): void;
  50935. /**
  50936. * Activates the physics body
  50937. * @param impostor impostor to activate
  50938. */
  50939. wakeUpBody(impostor: PhysicsImpostor): void;
  50940. /**
  50941. * Updates the distance parameters of the joint
  50942. * @param joint joint to update
  50943. * @param maxDistance maximum distance of the joint
  50944. * @param minDistance minimum distance of the joint
  50945. */
  50946. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50947. /**
  50948. * Sets a motor on the joint
  50949. * @param joint joint to set motor on
  50950. * @param speed speed of the motor
  50951. * @param maxForce maximum force of the motor
  50952. * @param motorIndex index of the motor
  50953. */
  50954. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50955. /**
  50956. * Sets the motors limit
  50957. * @param joint joint to set limit on
  50958. * @param upperLimit upper limit
  50959. * @param lowerLimit lower limit
  50960. */
  50961. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50962. /**
  50963. * Syncs the position and rotation of a mesh with the impostor
  50964. * @param mesh mesh to sync
  50965. * @param impostor impostor to update the mesh with
  50966. */
  50967. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50968. /**
  50969. * Gets the radius of the impostor
  50970. * @param impostor impostor to get radius from
  50971. * @returns the radius
  50972. */
  50973. getRadius(impostor: PhysicsImpostor): number;
  50974. /**
  50975. * Gets the box size of the impostor
  50976. * @param impostor impostor to get box size from
  50977. * @param result the resulting box size
  50978. */
  50979. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50980. /**
  50981. * Disposes of the impostor
  50982. */
  50983. dispose(): void;
  50984. /**
  50985. * Does a raycast in the physics world
  50986. * @param from when should the ray start?
  50987. * @param to when should the ray end?
  50988. * @returns PhysicsRaycastResult
  50989. */
  50990. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50991. }
  50992. }
  50993. declare module "babylonjs/Probes/reflectionProbe" {
  50994. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50995. import { Vector3 } from "babylonjs/Maths/math";
  50996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50997. import { Nullable } from "babylonjs/types";
  50998. import { Scene } from "babylonjs/scene";
  50999. module "babylonjs/abstractScene" {
  51000. interface AbstractScene {
  51001. /**
  51002. * The list of reflection probes added to the scene
  51003. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51004. */
  51005. reflectionProbes: Array<ReflectionProbe>;
  51006. /**
  51007. * Removes the given reflection probe from this scene.
  51008. * @param toRemove The reflection probe to remove
  51009. * @returns The index of the removed reflection probe
  51010. */
  51011. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51012. /**
  51013. * Adds the given reflection probe to this scene.
  51014. * @param newReflectionProbe The reflection probe to add
  51015. */
  51016. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51017. }
  51018. }
  51019. /**
  51020. * Class used to generate realtime reflection / refraction cube textures
  51021. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51022. */
  51023. export class ReflectionProbe {
  51024. /** defines the name of the probe */
  51025. name: string;
  51026. private _scene;
  51027. private _renderTargetTexture;
  51028. private _projectionMatrix;
  51029. private _viewMatrix;
  51030. private _target;
  51031. private _add;
  51032. private _attachedMesh;
  51033. private _invertYAxis;
  51034. /** Gets or sets probe position (center of the cube map) */
  51035. position: Vector3;
  51036. /**
  51037. * Creates a new reflection probe
  51038. * @param name defines the name of the probe
  51039. * @param size defines the texture resolution (for each face)
  51040. * @param scene defines the hosting scene
  51041. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51042. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51043. */
  51044. constructor(
  51045. /** defines the name of the probe */
  51046. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51047. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51048. samples: number;
  51049. /** Gets or sets the refresh rate to use (on every frame by default) */
  51050. refreshRate: number;
  51051. /**
  51052. * Gets the hosting scene
  51053. * @returns a Scene
  51054. */
  51055. getScene(): Scene;
  51056. /** Gets the internal CubeTexture used to render to */
  51057. readonly cubeTexture: RenderTargetTexture;
  51058. /** Gets the list of meshes to render */
  51059. readonly renderList: Nullable<AbstractMesh[]>;
  51060. /**
  51061. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51062. * @param mesh defines the mesh to attach to
  51063. */
  51064. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51065. /**
  51066. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51067. * @param renderingGroupId The rendering group id corresponding to its index
  51068. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51069. */
  51070. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51071. /**
  51072. * Clean all associated resources
  51073. */
  51074. dispose(): void;
  51075. /**
  51076. * Converts the reflection probe information to a readable string for debug purpose.
  51077. * @param fullDetails Supports for multiple levels of logging within scene loading
  51078. * @returns the human readable reflection probe info
  51079. */
  51080. toString(fullDetails?: boolean): string;
  51081. /**
  51082. * Get the class name of the relfection probe.
  51083. * @returns "ReflectionProbe"
  51084. */
  51085. getClassName(): string;
  51086. /**
  51087. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51088. * @returns The JSON representation of the texture
  51089. */
  51090. serialize(): any;
  51091. /**
  51092. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51093. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51094. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51095. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51096. * @returns The parsed reflection probe if successful
  51097. */
  51098. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51099. }
  51100. }
  51101. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51102. /** @hidden */
  51103. export var _BabylonLoaderRegistered: boolean;
  51104. }
  51105. declare module "babylonjs/Loading/Plugins/index" {
  51106. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51107. }
  51108. declare module "babylonjs/Loading/index" {
  51109. export * from "babylonjs/Loading/loadingScreen";
  51110. export * from "babylonjs/Loading/Plugins/index";
  51111. export * from "babylonjs/Loading/sceneLoader";
  51112. export * from "babylonjs/Loading/sceneLoaderFlags";
  51113. }
  51114. declare module "babylonjs/Materials/Background/index" {
  51115. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51116. }
  51117. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51118. import { Scene } from "babylonjs/scene";
  51119. import { Color3 } from "babylonjs/Maths/math";
  51120. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51122. /**
  51123. * The Physically based simple base material of BJS.
  51124. *
  51125. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51126. * It is used as the base class for both the specGloss and metalRough conventions.
  51127. */
  51128. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51129. /**
  51130. * Number of Simultaneous lights allowed on the material.
  51131. */
  51132. maxSimultaneousLights: number;
  51133. /**
  51134. * If sets to true, disables all the lights affecting the material.
  51135. */
  51136. disableLighting: boolean;
  51137. /**
  51138. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51139. */
  51140. environmentTexture: BaseTexture;
  51141. /**
  51142. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51143. */
  51144. invertNormalMapX: boolean;
  51145. /**
  51146. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51147. */
  51148. invertNormalMapY: boolean;
  51149. /**
  51150. * Normal map used in the model.
  51151. */
  51152. normalTexture: BaseTexture;
  51153. /**
  51154. * Emissivie color used to self-illuminate the model.
  51155. */
  51156. emissiveColor: Color3;
  51157. /**
  51158. * Emissivie texture used to self-illuminate the model.
  51159. */
  51160. emissiveTexture: BaseTexture;
  51161. /**
  51162. * Occlusion Channel Strenght.
  51163. */
  51164. occlusionStrength: number;
  51165. /**
  51166. * Occlusion Texture of the material (adding extra occlusion effects).
  51167. */
  51168. occlusionTexture: BaseTexture;
  51169. /**
  51170. * Defines the alpha limits in alpha test mode.
  51171. */
  51172. alphaCutOff: number;
  51173. /**
  51174. * Gets the current double sided mode.
  51175. */
  51176. /**
  51177. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51178. */
  51179. doubleSided: boolean;
  51180. /**
  51181. * Stores the pre-calculated light information of a mesh in a texture.
  51182. */
  51183. lightmapTexture: BaseTexture;
  51184. /**
  51185. * If true, the light map contains occlusion information instead of lighting info.
  51186. */
  51187. useLightmapAsShadowmap: boolean;
  51188. /**
  51189. * Instantiates a new PBRMaterial instance.
  51190. *
  51191. * @param name The material name
  51192. * @param scene The scene the material will be use in.
  51193. */
  51194. constructor(name: string, scene: Scene);
  51195. getClassName(): string;
  51196. }
  51197. }
  51198. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51199. import { Scene } from "babylonjs/scene";
  51200. import { Color3 } from "babylonjs/Maths/math";
  51201. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51202. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51203. /**
  51204. * The PBR material of BJS following the metal roughness convention.
  51205. *
  51206. * This fits to the PBR convention in the GLTF definition:
  51207. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51208. */
  51209. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51210. /**
  51211. * The base color has two different interpretations depending on the value of metalness.
  51212. * When the material is a metal, the base color is the specific measured reflectance value
  51213. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51214. * of the material.
  51215. */
  51216. baseColor: Color3;
  51217. /**
  51218. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51219. * well as opacity information in the alpha channel.
  51220. */
  51221. baseTexture: BaseTexture;
  51222. /**
  51223. * Specifies the metallic scalar value of the material.
  51224. * Can also be used to scale the metalness values of the metallic texture.
  51225. */
  51226. metallic: number;
  51227. /**
  51228. * Specifies the roughness scalar value of the material.
  51229. * Can also be used to scale the roughness values of the metallic texture.
  51230. */
  51231. roughness: number;
  51232. /**
  51233. * Texture containing both the metallic value in the B channel and the
  51234. * roughness value in the G channel to keep better precision.
  51235. */
  51236. metallicRoughnessTexture: BaseTexture;
  51237. /**
  51238. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51239. *
  51240. * @param name The material name
  51241. * @param scene The scene the material will be use in.
  51242. */
  51243. constructor(name: string, scene: Scene);
  51244. /**
  51245. * Return the currrent class name of the material.
  51246. */
  51247. getClassName(): string;
  51248. /**
  51249. * Makes a duplicate of the current material.
  51250. * @param name - name to use for the new material.
  51251. */
  51252. clone(name: string): PBRMetallicRoughnessMaterial;
  51253. /**
  51254. * Serialize the material to a parsable JSON object.
  51255. */
  51256. serialize(): any;
  51257. /**
  51258. * Parses a JSON object correponding to the serialize function.
  51259. */
  51260. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51261. }
  51262. }
  51263. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51264. import { Scene } from "babylonjs/scene";
  51265. import { Color3 } from "babylonjs/Maths/math";
  51266. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51267. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51268. /**
  51269. * The PBR material of BJS following the specular glossiness convention.
  51270. *
  51271. * This fits to the PBR convention in the GLTF definition:
  51272. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51273. */
  51274. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51275. /**
  51276. * Specifies the diffuse color of the material.
  51277. */
  51278. diffuseColor: Color3;
  51279. /**
  51280. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51281. * channel.
  51282. */
  51283. diffuseTexture: BaseTexture;
  51284. /**
  51285. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51286. */
  51287. specularColor: Color3;
  51288. /**
  51289. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51290. */
  51291. glossiness: number;
  51292. /**
  51293. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51294. */
  51295. specularGlossinessTexture: BaseTexture;
  51296. /**
  51297. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51298. *
  51299. * @param name The material name
  51300. * @param scene The scene the material will be use in.
  51301. */
  51302. constructor(name: string, scene: Scene);
  51303. /**
  51304. * Return the currrent class name of the material.
  51305. */
  51306. getClassName(): string;
  51307. /**
  51308. * Makes a duplicate of the current material.
  51309. * @param name - name to use for the new material.
  51310. */
  51311. clone(name: string): PBRSpecularGlossinessMaterial;
  51312. /**
  51313. * Serialize the material to a parsable JSON object.
  51314. */
  51315. serialize(): any;
  51316. /**
  51317. * Parses a JSON object correponding to the serialize function.
  51318. */
  51319. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51320. }
  51321. }
  51322. declare module "babylonjs/Materials/PBR/index" {
  51323. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51324. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51325. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51326. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51327. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51328. }
  51329. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51330. import { Nullable } from "babylonjs/types";
  51331. import { Scene } from "babylonjs/scene";
  51332. import { Matrix } from "babylonjs/Maths/math";
  51333. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51334. /**
  51335. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51336. * It can help converting any input color in a desired output one. This can then be used to create effects
  51337. * from sepia, black and white to sixties or futuristic rendering...
  51338. *
  51339. * The only supported format is currently 3dl.
  51340. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51341. */
  51342. export class ColorGradingTexture extends BaseTexture {
  51343. /**
  51344. * The current texture matrix. (will always be identity in color grading texture)
  51345. */
  51346. private _textureMatrix;
  51347. /**
  51348. * The texture URL.
  51349. */
  51350. url: string;
  51351. /**
  51352. * Empty line regex stored for GC.
  51353. */
  51354. private static _noneEmptyLineRegex;
  51355. private _engine;
  51356. /**
  51357. * Instantiates a ColorGradingTexture from the following parameters.
  51358. *
  51359. * @param url The location of the color gradind data (currently only supporting 3dl)
  51360. * @param scene The scene the texture will be used in
  51361. */
  51362. constructor(url: string, scene: Scene);
  51363. /**
  51364. * Returns the texture matrix used in most of the material.
  51365. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51366. */
  51367. getTextureMatrix(): Matrix;
  51368. /**
  51369. * Occurs when the file being loaded is a .3dl LUT file.
  51370. */
  51371. private load3dlTexture;
  51372. /**
  51373. * Starts the loading process of the texture.
  51374. */
  51375. private loadTexture;
  51376. /**
  51377. * Clones the color gradind texture.
  51378. */
  51379. clone(): ColorGradingTexture;
  51380. /**
  51381. * Called during delayed load for textures.
  51382. */
  51383. delayLoad(): void;
  51384. /**
  51385. * Parses a color grading texture serialized by Babylon.
  51386. * @param parsedTexture The texture information being parsedTexture
  51387. * @param scene The scene to load the texture in
  51388. * @param rootUrl The root url of the data assets to load
  51389. * @return A color gradind texture
  51390. */
  51391. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51392. /**
  51393. * Serializes the LUT texture to json format.
  51394. */
  51395. serialize(): any;
  51396. }
  51397. }
  51398. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51399. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51400. import { Scene } from "babylonjs/scene";
  51401. import { Nullable } from "babylonjs/types";
  51402. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51403. /**
  51404. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51405. */
  51406. export class EquiRectangularCubeTexture extends BaseTexture {
  51407. /** The six faces of the cube. */
  51408. private static _FacesMapping;
  51409. private _noMipmap;
  51410. private _onLoad;
  51411. private _onError;
  51412. /** The size of the cubemap. */
  51413. private _size;
  51414. /** The buffer of the image. */
  51415. private _buffer;
  51416. /** The width of the input image. */
  51417. private _width;
  51418. /** The height of the input image. */
  51419. private _height;
  51420. /** The URL to the image. */
  51421. url: string;
  51422. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51423. coordinatesMode: number;
  51424. /**
  51425. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51426. * @param url The location of the image
  51427. * @param scene The scene the texture will be used in
  51428. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51429. * @param noMipmap Forces to not generate the mipmap if true
  51430. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51431. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51432. * @param onLoad — defines a callback called when texture is loaded
  51433. * @param onError — defines a callback called if there is an error
  51434. */
  51435. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51436. /**
  51437. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51438. */
  51439. private loadImage;
  51440. /**
  51441. * Convert the image buffer into a cubemap and create a CubeTexture.
  51442. */
  51443. private loadTexture;
  51444. /**
  51445. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51446. * @param buffer The ArrayBuffer that should be converted.
  51447. * @returns The buffer as Float32Array.
  51448. */
  51449. private getFloat32ArrayFromArrayBuffer;
  51450. /**
  51451. * Get the current class name of the texture useful for serialization or dynamic coding.
  51452. * @returns "EquiRectangularCubeTexture"
  51453. */
  51454. getClassName(): string;
  51455. /**
  51456. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51457. * @returns A clone of the current EquiRectangularCubeTexture.
  51458. */
  51459. clone(): EquiRectangularCubeTexture;
  51460. }
  51461. }
  51462. declare module "babylonjs/Misc/tga" {
  51463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51464. /**
  51465. * Based on jsTGALoader - Javascript loader for TGA file
  51466. * By Vincent Thibault
  51467. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51468. */
  51469. export class TGATools {
  51470. private static _TYPE_INDEXED;
  51471. private static _TYPE_RGB;
  51472. private static _TYPE_GREY;
  51473. private static _TYPE_RLE_INDEXED;
  51474. private static _TYPE_RLE_RGB;
  51475. private static _TYPE_RLE_GREY;
  51476. private static _ORIGIN_MASK;
  51477. private static _ORIGIN_SHIFT;
  51478. private static _ORIGIN_BL;
  51479. private static _ORIGIN_BR;
  51480. private static _ORIGIN_UL;
  51481. private static _ORIGIN_UR;
  51482. /**
  51483. * Gets the header of a TGA file
  51484. * @param data defines the TGA data
  51485. * @returns the header
  51486. */
  51487. static GetTGAHeader(data: Uint8Array): any;
  51488. /**
  51489. * Uploads TGA content to a Babylon Texture
  51490. * @hidden
  51491. */
  51492. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51493. /** @hidden */
  51494. 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;
  51495. /** @hidden */
  51496. 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;
  51497. /** @hidden */
  51498. 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;
  51499. /** @hidden */
  51500. 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;
  51501. /** @hidden */
  51502. 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;
  51503. /** @hidden */
  51504. 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;
  51505. }
  51506. }
  51507. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51508. import { Nullable } from "babylonjs/types";
  51509. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51510. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51511. /**
  51512. * Implementation of the TGA Texture Loader.
  51513. * @hidden
  51514. */
  51515. export class _TGATextureLoader implements IInternalTextureLoader {
  51516. /**
  51517. * Defines wether the loader supports cascade loading the different faces.
  51518. */
  51519. readonly supportCascades: boolean;
  51520. /**
  51521. * This returns if the loader support the current file information.
  51522. * @param extension defines the file extension of the file being loaded
  51523. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51524. * @param fallback defines the fallback internal texture if any
  51525. * @param isBase64 defines whether the texture is encoded as a base64
  51526. * @param isBuffer defines whether the texture data are stored as a buffer
  51527. * @returns true if the loader can load the specified file
  51528. */
  51529. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51530. /**
  51531. * Transform the url before loading if required.
  51532. * @param rootUrl the url of the texture
  51533. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51534. * @returns the transformed texture
  51535. */
  51536. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51537. /**
  51538. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51539. * @param rootUrl the url of the texture
  51540. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51541. * @returns the fallback texture
  51542. */
  51543. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51544. /**
  51545. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51546. * @param data contains the texture data
  51547. * @param texture defines the BabylonJS internal texture
  51548. * @param createPolynomials will be true if polynomials have been requested
  51549. * @param onLoad defines the callback to trigger once the texture is ready
  51550. * @param onError defines the callback to trigger in case of error
  51551. */
  51552. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51553. /**
  51554. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51555. * @param data contains the texture data
  51556. * @param texture defines the BabylonJS internal texture
  51557. * @param callback defines the method to call once ready to upload
  51558. */
  51559. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51560. }
  51561. }
  51562. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51563. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51564. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51565. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51566. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51567. }
  51568. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51569. import { Scene } from "babylonjs/scene";
  51570. import { Texture } from "babylonjs/Materials/Textures/texture";
  51571. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51572. /**
  51573. * 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.
  51574. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51575. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51576. */
  51577. export class CustomProceduralTexture extends ProceduralTexture {
  51578. private _animate;
  51579. private _time;
  51580. private _config;
  51581. private _texturePath;
  51582. /**
  51583. * Instantiates a new Custom Procedural Texture.
  51584. * 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.
  51585. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51586. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51587. * @param name Define the name of the texture
  51588. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51589. * @param size Define the size of the texture to create
  51590. * @param scene Define the scene the texture belongs to
  51591. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51592. * @param generateMipMaps Define if the texture should creates mip maps or not
  51593. */
  51594. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51595. private _loadJson;
  51596. /**
  51597. * Is the texture ready to be used ? (rendered at least once)
  51598. * @returns true if ready, otherwise, false.
  51599. */
  51600. isReady(): boolean;
  51601. /**
  51602. * Render the texture to its associated render target.
  51603. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51604. */
  51605. render(useCameraPostProcess?: boolean): void;
  51606. /**
  51607. * Update the list of dependant textures samplers in the shader.
  51608. */
  51609. updateTextures(): void;
  51610. /**
  51611. * Update the uniform values of the procedural texture in the shader.
  51612. */
  51613. updateShaderUniforms(): void;
  51614. /**
  51615. * Define if the texture animates or not.
  51616. */
  51617. animate: boolean;
  51618. }
  51619. }
  51620. declare module "babylonjs/Shaders/noise.fragment" {
  51621. /** @hidden */
  51622. export var noisePixelShader: {
  51623. name: string;
  51624. shader: string;
  51625. };
  51626. }
  51627. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51628. import { Nullable } from "babylonjs/types";
  51629. import { Scene } from "babylonjs/scene";
  51630. import { Texture } from "babylonjs/Materials/Textures/texture";
  51631. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51632. import "babylonjs/Shaders/noise.fragment";
  51633. /**
  51634. * Class used to generate noise procedural textures
  51635. */
  51636. export class NoiseProceduralTexture extends ProceduralTexture {
  51637. private _time;
  51638. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51639. brightness: number;
  51640. /** Defines the number of octaves to process */
  51641. octaves: number;
  51642. /** Defines the level of persistence (0.8 by default) */
  51643. persistence: number;
  51644. /** Gets or sets animation speed factor (default is 1) */
  51645. animationSpeedFactor: number;
  51646. /**
  51647. * Creates a new NoiseProceduralTexture
  51648. * @param name defines the name fo the texture
  51649. * @param size defines the size of the texture (default is 256)
  51650. * @param scene defines the hosting scene
  51651. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51652. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51653. */
  51654. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51655. private _updateShaderUniforms;
  51656. protected _getDefines(): string;
  51657. /** Generate the current state of the procedural texture */
  51658. render(useCameraPostProcess?: boolean): void;
  51659. /**
  51660. * Serializes this noise procedural texture
  51661. * @returns a serialized noise procedural texture object
  51662. */
  51663. serialize(): any;
  51664. /**
  51665. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51666. * @param parsedTexture defines parsed texture data
  51667. * @param scene defines the current scene
  51668. * @param rootUrl defines the root URL containing noise procedural texture information
  51669. * @returns a parsed NoiseProceduralTexture
  51670. */
  51671. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51672. }
  51673. }
  51674. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51675. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51676. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51677. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51678. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51679. }
  51680. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51681. import { Nullable } from "babylonjs/types";
  51682. import { Scene } from "babylonjs/scene";
  51683. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51684. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51685. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51686. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51687. /**
  51688. * Raw cube texture where the raw buffers are passed in
  51689. */
  51690. export class RawCubeTexture extends CubeTexture {
  51691. /**
  51692. * Creates a cube texture where the raw buffers are passed in.
  51693. * @param scene defines the scene the texture is attached to
  51694. * @param data defines the array of data to use to create each face
  51695. * @param size defines the size of the textures
  51696. * @param format defines the format of the data
  51697. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51698. * @param generateMipMaps defines if the engine should generate the mip levels
  51699. * @param invertY defines if data must be stored with Y axis inverted
  51700. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51701. * @param compression defines the compression used (null by default)
  51702. */
  51703. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51704. /**
  51705. * Updates the raw cube texture.
  51706. * @param data defines the data to store
  51707. * @param format defines the data format
  51708. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51709. * @param invertY defines if data must be stored with Y axis inverted
  51710. * @param compression defines the compression used (null by default)
  51711. * @param level defines which level of the texture to update
  51712. */
  51713. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51714. /**
  51715. * Updates a raw cube texture with RGBD encoded data.
  51716. * @param data defines the array of data [mipmap][face] to use to create each face
  51717. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51718. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51719. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51720. * @returns a promsie that resolves when the operation is complete
  51721. */
  51722. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51723. /**
  51724. * Clones the raw cube texture.
  51725. * @return a new cube texture
  51726. */
  51727. clone(): CubeTexture;
  51728. /** @hidden */
  51729. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51730. }
  51731. }
  51732. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51733. import { Scene } from "babylonjs/scene";
  51734. import { Texture } from "babylonjs/Materials/Textures/texture";
  51735. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51736. /**
  51737. * Class used to store 3D textures containing user data
  51738. */
  51739. export class RawTexture3D extends Texture {
  51740. /** Gets or sets the texture format to use */
  51741. format: number;
  51742. private _engine;
  51743. /**
  51744. * Create a new RawTexture3D
  51745. * @param data defines the data of the texture
  51746. * @param width defines the width of the texture
  51747. * @param height defines the height of the texture
  51748. * @param depth defines the depth of the texture
  51749. * @param format defines the texture format to use
  51750. * @param scene defines the hosting scene
  51751. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51752. * @param invertY defines if texture must be stored with Y axis inverted
  51753. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51754. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51755. */
  51756. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51757. /** Gets or sets the texture format to use */
  51758. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51759. /**
  51760. * Update the texture with new data
  51761. * @param data defines the data to store in the texture
  51762. */
  51763. update(data: ArrayBufferView): void;
  51764. }
  51765. }
  51766. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51767. import { Scene } from "babylonjs/scene";
  51768. import { Plane } from "babylonjs/Maths/math";
  51769. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51770. /**
  51771. * Creates a refraction texture used by refraction channel of the standard material.
  51772. * It is like a mirror but to see through a material.
  51773. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51774. */
  51775. export class RefractionTexture extends RenderTargetTexture {
  51776. /**
  51777. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51778. * 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.
  51779. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51780. */
  51781. refractionPlane: Plane;
  51782. /**
  51783. * Define how deep under the surface we should see.
  51784. */
  51785. depth: number;
  51786. /**
  51787. * Creates a refraction texture used by refraction channel of the standard material.
  51788. * It is like a mirror but to see through a material.
  51789. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51790. * @param name Define the texture name
  51791. * @param size Define the size of the underlying texture
  51792. * @param scene Define the scene the refraction belongs to
  51793. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51794. */
  51795. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51796. /**
  51797. * Clone the refraction texture.
  51798. * @returns the cloned texture
  51799. */
  51800. clone(): RefractionTexture;
  51801. /**
  51802. * Serialize the texture to a JSON representation you could use in Parse later on
  51803. * @returns the serialized JSON representation
  51804. */
  51805. serialize(): any;
  51806. }
  51807. }
  51808. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51809. import { Nullable } from "babylonjs/types";
  51810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51811. import { Matrix } from "babylonjs/Maths/math";
  51812. import { Engine } from "babylonjs/Engines/engine";
  51813. import { Scene } from "babylonjs/scene";
  51814. /**
  51815. * Defines the options related to the creation of an HtmlElementTexture
  51816. */
  51817. export interface IHtmlElementTextureOptions {
  51818. /**
  51819. * Defines wether mip maps should be created or not.
  51820. */
  51821. generateMipMaps?: boolean;
  51822. /**
  51823. * Defines the sampling mode of the texture.
  51824. */
  51825. samplingMode?: number;
  51826. /**
  51827. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51828. */
  51829. engine: Nullable<Engine>;
  51830. /**
  51831. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51832. */
  51833. scene: Nullable<Scene>;
  51834. }
  51835. /**
  51836. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51837. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51838. * is automatically managed.
  51839. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51840. * in your application.
  51841. *
  51842. * As the update is not automatic, you need to call them manually.
  51843. */
  51844. export class HtmlElementTexture extends BaseTexture {
  51845. /**
  51846. * The texture URL.
  51847. */
  51848. element: HTMLVideoElement | HTMLCanvasElement;
  51849. private static readonly DefaultOptions;
  51850. private _textureMatrix;
  51851. private _engine;
  51852. private _isVideo;
  51853. private _generateMipMaps;
  51854. private _samplingMode;
  51855. /**
  51856. * Instantiates a HtmlElementTexture from the following parameters.
  51857. *
  51858. * @param name Defines the name of the texture
  51859. * @param element Defines the video or canvas the texture is filled with
  51860. * @param options Defines the other none mandatory texture creation options
  51861. */
  51862. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51863. private _createInternalTexture;
  51864. /**
  51865. * Returns the texture matrix used in most of the material.
  51866. */
  51867. getTextureMatrix(): Matrix;
  51868. /**
  51869. * Updates the content of the texture.
  51870. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51871. */
  51872. update(invertY?: Nullable<boolean>): void;
  51873. }
  51874. }
  51875. declare module "babylonjs/Materials/Textures/index" {
  51876. export * from "babylonjs/Materials/Textures/baseTexture";
  51877. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51878. export * from "babylonjs/Materials/Textures/cubeTexture";
  51879. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51880. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51881. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51882. export * from "babylonjs/Materials/Textures/internalTexture";
  51883. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51884. export * from "babylonjs/Materials/Textures/Loaders/index";
  51885. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51886. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51887. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51888. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51889. export * from "babylonjs/Materials/Textures/rawTexture";
  51890. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51891. export * from "babylonjs/Materials/Textures/refractionTexture";
  51892. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51893. export * from "babylonjs/Materials/Textures/texture";
  51894. export * from "babylonjs/Materials/Textures/videoTexture";
  51895. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51896. }
  51897. declare module "babylonjs/Materials/index" {
  51898. export * from "babylonjs/Materials/Background/index";
  51899. export * from "babylonjs/Materials/colorCurves";
  51900. export * from "babylonjs/Materials/effect";
  51901. export * from "babylonjs/Materials/fresnelParameters";
  51902. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51903. export * from "babylonjs/Materials/material";
  51904. export * from "babylonjs/Materials/materialDefines";
  51905. export * from "babylonjs/Materials/materialHelper";
  51906. export * from "babylonjs/Materials/multiMaterial";
  51907. export * from "babylonjs/Materials/PBR/index";
  51908. export * from "babylonjs/Materials/pushMaterial";
  51909. export * from "babylonjs/Materials/shaderMaterial";
  51910. export * from "babylonjs/Materials/standardMaterial";
  51911. export * from "babylonjs/Materials/Textures/index";
  51912. export * from "babylonjs/Materials/uniformBuffer";
  51913. export * from "babylonjs/Materials/materialFlags";
  51914. }
  51915. declare module "babylonjs/Maths/index" {
  51916. export * from "babylonjs/Maths/math.scalar";
  51917. export * from "babylonjs/Maths/math";
  51918. export * from "babylonjs/Maths/sphericalPolynomial";
  51919. }
  51920. declare module "babylonjs/Misc/workerPool" {
  51921. import { IDisposable } from "babylonjs/scene";
  51922. /**
  51923. * Helper class to push actions to a pool of workers.
  51924. */
  51925. export class WorkerPool implements IDisposable {
  51926. private _workerInfos;
  51927. private _pendingActions;
  51928. /**
  51929. * Constructor
  51930. * @param workers Array of workers to use for actions
  51931. */
  51932. constructor(workers: Array<Worker>);
  51933. /**
  51934. * Terminates all workers and clears any pending actions.
  51935. */
  51936. dispose(): void;
  51937. /**
  51938. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51939. * pended until a worker has completed its action.
  51940. * @param action The action to perform. Call onComplete when the action is complete.
  51941. */
  51942. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51943. private _execute;
  51944. }
  51945. }
  51946. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51947. import { IDisposable } from "babylonjs/scene";
  51948. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51949. /**
  51950. * Configuration for Draco compression
  51951. */
  51952. export interface IDracoCompressionConfiguration {
  51953. /**
  51954. * Configuration for the decoder.
  51955. */
  51956. decoder: {
  51957. /**
  51958. * The url to the WebAssembly module.
  51959. */
  51960. wasmUrl?: string;
  51961. /**
  51962. * The url to the WebAssembly binary.
  51963. */
  51964. wasmBinaryUrl?: string;
  51965. /**
  51966. * The url to the fallback JavaScript module.
  51967. */
  51968. fallbackUrl?: string;
  51969. };
  51970. }
  51971. /**
  51972. * Draco compression (https://google.github.io/draco/)
  51973. *
  51974. * This class wraps the Draco module.
  51975. *
  51976. * **Encoder**
  51977. *
  51978. * The encoder is not currently implemented.
  51979. *
  51980. * **Decoder**
  51981. *
  51982. * 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.
  51983. *
  51984. * To update the configuration, use the following code:
  51985. * ```javascript
  51986. * DracoCompression.Configuration = {
  51987. * decoder: {
  51988. * wasmUrl: "<url to the WebAssembly library>",
  51989. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51990. * fallbackUrl: "<url to the fallback JavaScript library>",
  51991. * }
  51992. * };
  51993. * ```
  51994. *
  51995. * 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.
  51996. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51997. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  51998. *
  51999. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52000. * ```javascript
  52001. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52002. * ```
  52003. *
  52004. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52005. */
  52006. export class DracoCompression implements IDisposable {
  52007. private _workerPoolPromise?;
  52008. private _decoderModulePromise?;
  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 configuration 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. Specify `0` to disable web workers and run synchronously in the current context.
  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. }
  52055. declare module "babylonjs/Meshes/Compression/index" {
  52056. export * from "babylonjs/Meshes/Compression/dracoCompression";
  52057. }
  52058. declare module "babylonjs/Meshes/csg" {
  52059. import { Nullable } from "babylonjs/types";
  52060. import { Scene } from "babylonjs/scene";
  52061. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  52062. import { Mesh } from "babylonjs/Meshes/mesh";
  52063. import { Material } from "babylonjs/Materials/material";
  52064. /**
  52065. * Class for building Constructive Solid Geometry
  52066. */
  52067. export class CSG {
  52068. private polygons;
  52069. /**
  52070. * The world matrix
  52071. */
  52072. matrix: Matrix;
  52073. /**
  52074. * Stores the position
  52075. */
  52076. position: Vector3;
  52077. /**
  52078. * Stores the rotation
  52079. */
  52080. rotation: Vector3;
  52081. /**
  52082. * Stores the rotation quaternion
  52083. */
  52084. rotationQuaternion: Nullable<Quaternion>;
  52085. /**
  52086. * Stores the scaling vector
  52087. */
  52088. scaling: Vector3;
  52089. /**
  52090. * Convert the Mesh to CSG
  52091. * @param mesh The Mesh to convert to CSG
  52092. * @returns A new CSG from the Mesh
  52093. */
  52094. static FromMesh(mesh: Mesh): CSG;
  52095. /**
  52096. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52097. * @param polygons Polygons used to construct a CSG solid
  52098. */
  52099. private static FromPolygons;
  52100. /**
  52101. * Clones, or makes a deep copy, of the CSG
  52102. * @returns A new CSG
  52103. */
  52104. clone(): CSG;
  52105. /**
  52106. * Unions this CSG with another CSG
  52107. * @param csg The CSG to union against this CSG
  52108. * @returns The unioned CSG
  52109. */
  52110. union(csg: CSG): CSG;
  52111. /**
  52112. * Unions this CSG with another CSG in place
  52113. * @param csg The CSG to union against this CSG
  52114. */
  52115. unionInPlace(csg: CSG): void;
  52116. /**
  52117. * Subtracts this CSG with another CSG
  52118. * @param csg The CSG to subtract against this CSG
  52119. * @returns A new CSG
  52120. */
  52121. subtract(csg: CSG): CSG;
  52122. /**
  52123. * Subtracts this CSG with another CSG in place
  52124. * @param csg The CSG to subtact against this CSG
  52125. */
  52126. subtractInPlace(csg: CSG): void;
  52127. /**
  52128. * Intersect this CSG with another CSG
  52129. * @param csg The CSG to intersect against this CSG
  52130. * @returns A new CSG
  52131. */
  52132. intersect(csg: CSG): CSG;
  52133. /**
  52134. * Intersects this CSG with another CSG in place
  52135. * @param csg The CSG to intersect against this CSG
  52136. */
  52137. intersectInPlace(csg: CSG): void;
  52138. /**
  52139. * Return a new CSG solid with solid and empty space switched. This solid is
  52140. * not modified.
  52141. * @returns A new CSG solid with solid and empty space switched
  52142. */
  52143. inverse(): CSG;
  52144. /**
  52145. * Inverses the CSG in place
  52146. */
  52147. inverseInPlace(): void;
  52148. /**
  52149. * This is used to keep meshes transformations so they can be restored
  52150. * when we build back a Babylon Mesh
  52151. * NB : All CSG operations are performed in world coordinates
  52152. * @param csg The CSG to copy the transform attributes from
  52153. * @returns This CSG
  52154. */
  52155. copyTransformAttributes(csg: CSG): CSG;
  52156. /**
  52157. * Build Raw mesh from CSG
  52158. * Coordinates here are in world space
  52159. * @param name The name of the mesh geometry
  52160. * @param scene The Scene
  52161. * @param keepSubMeshes Specifies if the submeshes should be kept
  52162. * @returns A new Mesh
  52163. */
  52164. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52165. /**
  52166. * Build Mesh from CSG taking material and transforms into account
  52167. * @param name The name of the Mesh
  52168. * @param material The material of the Mesh
  52169. * @param scene The Scene
  52170. * @param keepSubMeshes Specifies if submeshes should be kept
  52171. * @returns The new Mesh
  52172. */
  52173. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52174. }
  52175. }
  52176. declare module "babylonjs/Meshes/trailMesh" {
  52177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52178. import { Mesh } from "babylonjs/Meshes/mesh";
  52179. import { Scene } from "babylonjs/scene";
  52180. /**
  52181. * Class used to create a trail following a mesh
  52182. */
  52183. export class TrailMesh extends Mesh {
  52184. private _generator;
  52185. private _autoStart;
  52186. private _running;
  52187. private _diameter;
  52188. private _length;
  52189. private _sectionPolygonPointsCount;
  52190. private _sectionVectors;
  52191. private _sectionNormalVectors;
  52192. private _beforeRenderObserver;
  52193. /**
  52194. * @constructor
  52195. * @param name The value used by scene.getMeshByName() to do a lookup.
  52196. * @param generator The mesh to generate a trail.
  52197. * @param scene The scene to add this mesh to.
  52198. * @param diameter Diameter of trailing mesh. Default is 1.
  52199. * @param length Length of trailing mesh. Default is 60.
  52200. * @param autoStart Automatically start trailing mesh. Default true.
  52201. */
  52202. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52203. /**
  52204. * "TrailMesh"
  52205. * @returns "TrailMesh"
  52206. */
  52207. getClassName(): string;
  52208. private _createMesh;
  52209. /**
  52210. * Start trailing mesh.
  52211. */
  52212. start(): void;
  52213. /**
  52214. * Stop trailing mesh.
  52215. */
  52216. stop(): void;
  52217. /**
  52218. * Update trailing mesh geometry.
  52219. */
  52220. update(): void;
  52221. /**
  52222. * Returns a new TrailMesh object.
  52223. * @param name is a string, the name given to the new mesh
  52224. * @param newGenerator use new generator object for cloned trail mesh
  52225. * @returns a new mesh
  52226. */
  52227. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52228. /**
  52229. * Serializes this trail mesh
  52230. * @param serializationObject object to write serialization to
  52231. */
  52232. serialize(serializationObject: any): void;
  52233. /**
  52234. * Parses a serialized trail mesh
  52235. * @param parsedMesh the serialized mesh
  52236. * @param scene the scene to create the trail mesh in
  52237. * @returns the created trail mesh
  52238. */
  52239. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52240. }
  52241. }
  52242. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  52243. import { Vector4 } from "babylonjs/Maths/math";
  52244. import { Mesh } from "babylonjs/Meshes/mesh";
  52245. /**
  52246. * Class containing static functions to help procedurally build meshes
  52247. */
  52248. export class TorusKnotBuilder {
  52249. /**
  52250. * Creates a torus knot mesh
  52251. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52252. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52253. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52254. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52258. * @param name defines the name of the mesh
  52259. * @param options defines the options used to create the mesh
  52260. * @param scene defines the hosting scene
  52261. * @returns the torus knot mesh
  52262. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52263. */
  52264. static CreateTorusKnot(name: string, options: {
  52265. radius?: number;
  52266. tube?: number;
  52267. radialSegments?: number;
  52268. tubularSegments?: number;
  52269. p?: number;
  52270. q?: number;
  52271. updatable?: boolean;
  52272. sideOrientation?: number;
  52273. frontUVs?: Vector4;
  52274. backUVs?: Vector4;
  52275. }, scene: any): Mesh;
  52276. }
  52277. }
  52278. declare module "babylonjs/Meshes/polygonMesh" {
  52279. import { Scene } from "babylonjs/scene";
  52280. import { Vector2, Path2 } from "babylonjs/Maths/math";
  52281. import { Mesh } from "babylonjs/Meshes/mesh";
  52282. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52283. /**
  52284. * Polygon
  52285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52286. */
  52287. export class Polygon {
  52288. /**
  52289. * Creates a rectangle
  52290. * @param xmin bottom X coord
  52291. * @param ymin bottom Y coord
  52292. * @param xmax top X coord
  52293. * @param ymax top Y coord
  52294. * @returns points that make the resulting rectation
  52295. */
  52296. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52297. /**
  52298. * Creates a circle
  52299. * @param radius radius of circle
  52300. * @param cx scale in x
  52301. * @param cy scale in y
  52302. * @param numberOfSides number of sides that make up the circle
  52303. * @returns points that make the resulting circle
  52304. */
  52305. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52306. /**
  52307. * Creates a polygon from input string
  52308. * @param input Input polygon data
  52309. * @returns the parsed points
  52310. */
  52311. static Parse(input: string): Vector2[];
  52312. /**
  52313. * Starts building a polygon from x and y coordinates
  52314. * @param x x coordinate
  52315. * @param y y coordinate
  52316. * @returns the started path2
  52317. */
  52318. static StartingAt(x: number, y: number): Path2;
  52319. }
  52320. /**
  52321. * Builds a polygon
  52322. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52323. */
  52324. export class PolygonMeshBuilder {
  52325. private _points;
  52326. private _outlinepoints;
  52327. private _holes;
  52328. private _name;
  52329. private _scene;
  52330. private _epoints;
  52331. private _eholes;
  52332. private _addToepoint;
  52333. /**
  52334. * Babylon reference to the earcut plugin.
  52335. */
  52336. bjsEarcut: any;
  52337. /**
  52338. * Creates a PolygonMeshBuilder
  52339. * @param name name of the builder
  52340. * @param contours Path of the polygon
  52341. * @param scene scene to add to when creating the mesh
  52342. * @param earcutInjection can be used to inject your own earcut reference
  52343. */
  52344. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52345. /**
  52346. * Adds a whole within the polygon
  52347. * @param hole Array of points defining the hole
  52348. * @returns this
  52349. */
  52350. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52351. /**
  52352. * Creates the polygon
  52353. * @param updatable If the mesh should be updatable
  52354. * @param depth The depth of the mesh created
  52355. * @returns the created mesh
  52356. */
  52357. build(updatable?: boolean, depth?: number): Mesh;
  52358. /**
  52359. * Creates the polygon
  52360. * @param depth The depth of the mesh created
  52361. * @returns the created VertexData
  52362. */
  52363. buildVertexData(depth?: number): VertexData;
  52364. /**
  52365. * Adds a side to the polygon
  52366. * @param positions points that make the polygon
  52367. * @param normals normals of the polygon
  52368. * @param uvs uvs of the polygon
  52369. * @param indices indices of the polygon
  52370. * @param bounds bounds of the polygon
  52371. * @param points points of the polygon
  52372. * @param depth depth of the polygon
  52373. * @param flip flip of the polygon
  52374. */
  52375. private addSide;
  52376. }
  52377. }
  52378. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52379. import { Scene } from "babylonjs/scene";
  52380. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52381. import { Mesh } from "babylonjs/Meshes/mesh";
  52382. import { Nullable } from "babylonjs/types";
  52383. /**
  52384. * Class containing static functions to help procedurally build meshes
  52385. */
  52386. export class PolygonBuilder {
  52387. /**
  52388. * Creates a polygon mesh
  52389. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52390. * * 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
  52391. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52394. * * Remember you can only change the shape positions, not their number when updating a polygon
  52395. * @param name defines the name of the mesh
  52396. * @param options defines the options used to create the mesh
  52397. * @param scene defines the hosting scene
  52398. * @param earcutInjection can be used to inject your own earcut reference
  52399. * @returns the polygon mesh
  52400. */
  52401. static CreatePolygon(name: string, options: {
  52402. shape: Vector3[];
  52403. holes?: Vector3[][];
  52404. depth?: number;
  52405. faceUV?: Vector4[];
  52406. faceColors?: Color4[];
  52407. updatable?: boolean;
  52408. sideOrientation?: number;
  52409. frontUVs?: Vector4;
  52410. backUVs?: Vector4;
  52411. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52412. /**
  52413. * Creates an extruded polygon mesh, with depth in the Y direction.
  52414. * * 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)
  52415. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52416. * @param name defines the name of the mesh
  52417. * @param options defines the options used to create the mesh
  52418. * @param scene defines the hosting scene
  52419. * @param earcutInjection can be used to inject your own earcut reference
  52420. * @returns the polygon mesh
  52421. */
  52422. static ExtrudePolygon(name: string, options: {
  52423. shape: Vector3[];
  52424. holes?: Vector3[][];
  52425. depth?: number;
  52426. faceUV?: Vector4[];
  52427. faceColors?: Color4[];
  52428. updatable?: boolean;
  52429. sideOrientation?: number;
  52430. frontUVs?: Vector4;
  52431. backUVs?: Vector4;
  52432. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52433. }
  52434. }
  52435. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52436. import { Scene } from "babylonjs/scene";
  52437. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52438. import { Mesh } from "babylonjs/Meshes/mesh";
  52439. import { Nullable } from "babylonjs/types";
  52440. /**
  52441. * Class containing static functions to help procedurally build meshes
  52442. */
  52443. export class LatheBuilder {
  52444. /**
  52445. * Creates lathe mesh.
  52446. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52447. * * 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
  52448. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52449. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52450. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52451. * * 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
  52452. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52453. * * 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
  52454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52458. * @param name defines the name of the mesh
  52459. * @param options defines the options used to create the mesh
  52460. * @param scene defines the hosting scene
  52461. * @returns the lathe mesh
  52462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52463. */
  52464. static CreateLathe(name: string, options: {
  52465. shape: Vector3[];
  52466. radius?: number;
  52467. tessellation?: number;
  52468. clip?: number;
  52469. arc?: number;
  52470. closed?: boolean;
  52471. updatable?: boolean;
  52472. sideOrientation?: number;
  52473. frontUVs?: Vector4;
  52474. backUVs?: Vector4;
  52475. cap?: number;
  52476. invertUV?: boolean;
  52477. }, scene?: Nullable<Scene>): Mesh;
  52478. }
  52479. }
  52480. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52481. import { Nullable } from "babylonjs/types";
  52482. import { Scene } from "babylonjs/scene";
  52483. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52484. import { Mesh } from "babylonjs/Meshes/mesh";
  52485. /**
  52486. * Class containing static functions to help procedurally build meshes
  52487. */
  52488. export class TubeBuilder {
  52489. /**
  52490. * Creates a tube mesh.
  52491. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52492. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52493. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52494. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52495. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52496. * * 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)
  52497. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52498. * * 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
  52499. * * 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
  52500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52502. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52504. * @param name defines the name of the mesh
  52505. * @param options defines the options used to create the mesh
  52506. * @param scene defines the hosting scene
  52507. * @returns the tube mesh
  52508. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52509. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52510. */
  52511. static CreateTube(name: string, options: {
  52512. path: Vector3[];
  52513. radius?: number;
  52514. tessellation?: number;
  52515. radiusFunction?: {
  52516. (i: number, distance: number): number;
  52517. };
  52518. cap?: number;
  52519. arc?: number;
  52520. updatable?: boolean;
  52521. sideOrientation?: number;
  52522. frontUVs?: Vector4;
  52523. backUVs?: Vector4;
  52524. instance?: Mesh;
  52525. invertUV?: boolean;
  52526. }, scene?: Nullable<Scene>): Mesh;
  52527. }
  52528. }
  52529. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52530. import { Scene } from "babylonjs/scene";
  52531. import { Vector4 } from "babylonjs/Maths/math";
  52532. import { Mesh } from "babylonjs/Meshes/mesh";
  52533. import { Nullable } from "babylonjs/types";
  52534. /**
  52535. * Class containing static functions to help procedurally build meshes
  52536. */
  52537. export class IcoSphereBuilder {
  52538. /**
  52539. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52540. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52541. * * 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`)
  52542. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52543. * * 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
  52544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52547. * @param name defines the name of the mesh
  52548. * @param options defines the options used to create the mesh
  52549. * @param scene defines the hosting scene
  52550. * @returns the icosahedron mesh
  52551. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52552. */
  52553. static CreateIcoSphere(name: string, options: {
  52554. radius?: number;
  52555. radiusX?: number;
  52556. radiusY?: number;
  52557. radiusZ?: number;
  52558. flat?: boolean;
  52559. subdivisions?: number;
  52560. sideOrientation?: number;
  52561. frontUVs?: Vector4;
  52562. backUVs?: Vector4;
  52563. updatable?: boolean;
  52564. }, scene?: Nullable<Scene>): Mesh;
  52565. }
  52566. }
  52567. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52568. import { Vector3 } from "babylonjs/Maths/math";
  52569. import { Mesh } from "babylonjs/Meshes/mesh";
  52570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52571. /**
  52572. * Class containing static functions to help procedurally build meshes
  52573. */
  52574. export class DecalBuilder {
  52575. /**
  52576. * Creates a decal mesh.
  52577. * 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
  52578. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52579. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52580. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52581. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52582. * @param name defines the name of the mesh
  52583. * @param sourceMesh defines the mesh where the decal must be applied
  52584. * @param options defines the options used to create the mesh
  52585. * @param scene defines the hosting scene
  52586. * @returns the decal mesh
  52587. * @see https://doc.babylonjs.com/how_to/decals
  52588. */
  52589. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52590. position?: Vector3;
  52591. normal?: Vector3;
  52592. size?: Vector3;
  52593. angle?: number;
  52594. }): Mesh;
  52595. }
  52596. }
  52597. declare module "babylonjs/Meshes/meshBuilder" {
  52598. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52599. import { Nullable } from "babylonjs/types";
  52600. import { Scene } from "babylonjs/scene";
  52601. import { Mesh } from "babylonjs/Meshes/mesh";
  52602. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52603. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52605. /**
  52606. * Class containing static functions to help procedurally build meshes
  52607. */
  52608. export class MeshBuilder {
  52609. /**
  52610. * Creates a box mesh
  52611. * * The parameter `size` sets the size (float) of each box side (default 1)
  52612. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52613. * * 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)
  52614. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52618. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52619. * @param name defines the name of the mesh
  52620. * @param options defines the options used to create the mesh
  52621. * @param scene defines the hosting scene
  52622. * @returns the box mesh
  52623. */
  52624. static CreateBox(name: string, options: {
  52625. size?: number;
  52626. width?: number;
  52627. height?: number;
  52628. depth?: number;
  52629. faceUV?: Vector4[];
  52630. faceColors?: Color4[];
  52631. sideOrientation?: number;
  52632. frontUVs?: Vector4;
  52633. backUVs?: Vector4;
  52634. updatable?: boolean;
  52635. }, scene?: Nullable<Scene>): Mesh;
  52636. /**
  52637. * Creates a sphere mesh
  52638. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52639. * * 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`)
  52640. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52641. * * 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
  52642. * * 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)
  52643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52646. * @param name defines the name of the mesh
  52647. * @param options defines the options used to create the mesh
  52648. * @param scene defines the hosting scene
  52649. * @returns the sphere mesh
  52650. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52651. */
  52652. static CreateSphere(name: string, options: {
  52653. segments?: number;
  52654. diameter?: number;
  52655. diameterX?: number;
  52656. diameterY?: number;
  52657. diameterZ?: number;
  52658. arc?: number;
  52659. slice?: number;
  52660. sideOrientation?: number;
  52661. frontUVs?: Vector4;
  52662. backUVs?: Vector4;
  52663. updatable?: boolean;
  52664. }, scene?: Nullable<Scene>): Mesh;
  52665. /**
  52666. * Creates a plane polygonal mesh. By default, this is a disc
  52667. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52668. * * 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
  52669. * * 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
  52670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52673. * @param name defines the name of the mesh
  52674. * @param options defines the options used to create the mesh
  52675. * @param scene defines the hosting scene
  52676. * @returns the plane polygonal mesh
  52677. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52678. */
  52679. static CreateDisc(name: string, options: {
  52680. radius?: number;
  52681. tessellation?: number;
  52682. arc?: number;
  52683. updatable?: boolean;
  52684. sideOrientation?: number;
  52685. frontUVs?: Vector4;
  52686. backUVs?: Vector4;
  52687. }, scene?: Nullable<Scene>): Mesh;
  52688. /**
  52689. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52690. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52691. * * 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`)
  52692. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52693. * * 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
  52694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52695. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52697. * @param name defines the name of the mesh
  52698. * @param options defines the options used to create the mesh
  52699. * @param scene defines the hosting scene
  52700. * @returns the icosahedron mesh
  52701. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52702. */
  52703. static CreateIcoSphere(name: string, options: {
  52704. radius?: number;
  52705. radiusX?: number;
  52706. radiusY?: number;
  52707. radiusZ?: number;
  52708. flat?: boolean;
  52709. subdivisions?: number;
  52710. sideOrientation?: number;
  52711. frontUVs?: Vector4;
  52712. backUVs?: Vector4;
  52713. updatable?: boolean;
  52714. }, scene?: Nullable<Scene>): Mesh;
  52715. /**
  52716. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52717. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52718. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52719. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52720. * * 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
  52721. * * 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
  52722. * * 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
  52723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52725. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52726. * * 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
  52727. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52728. * * 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
  52729. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52731. * @param name defines the name of the mesh
  52732. * @param options defines the options used to create the mesh
  52733. * @param scene defines the hosting scene
  52734. * @returns the ribbon mesh
  52735. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52736. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52737. */
  52738. static CreateRibbon(name: string, options: {
  52739. pathArray: Vector3[][];
  52740. closeArray?: boolean;
  52741. closePath?: boolean;
  52742. offset?: number;
  52743. updatable?: boolean;
  52744. sideOrientation?: number;
  52745. frontUVs?: Vector4;
  52746. backUVs?: Vector4;
  52747. instance?: Mesh;
  52748. invertUV?: boolean;
  52749. uvs?: Vector2[];
  52750. colors?: Color4[];
  52751. }, scene?: Nullable<Scene>): Mesh;
  52752. /**
  52753. * Creates a cylinder or a cone mesh
  52754. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52755. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52756. * * 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.
  52757. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52758. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52759. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52760. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52761. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52762. * * 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).
  52763. * * 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
  52764. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52765. * * 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
  52766. * * 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.
  52767. * * If `enclose` is false, a ring surface is one element.
  52768. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52769. * * 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
  52770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52773. * @param name defines the name of the mesh
  52774. * @param options defines the options used to create the mesh
  52775. * @param scene defines the hosting scene
  52776. * @returns the cylinder mesh
  52777. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52778. */
  52779. static CreateCylinder(name: string, options: {
  52780. height?: number;
  52781. diameterTop?: number;
  52782. diameterBottom?: number;
  52783. diameter?: number;
  52784. tessellation?: number;
  52785. subdivisions?: number;
  52786. arc?: number;
  52787. faceColors?: Color4[];
  52788. faceUV?: Vector4[];
  52789. updatable?: boolean;
  52790. hasRings?: boolean;
  52791. enclose?: boolean;
  52792. sideOrientation?: number;
  52793. frontUVs?: Vector4;
  52794. backUVs?: Vector4;
  52795. }, scene?: Nullable<Scene>): Mesh;
  52796. /**
  52797. * Creates a torus mesh
  52798. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52799. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52800. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52804. * @param name defines the name of the mesh
  52805. * @param options defines the options used to create the mesh
  52806. * @param scene defines the hosting scene
  52807. * @returns the torus mesh
  52808. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52809. */
  52810. static CreateTorus(name: string, options: {
  52811. diameter?: number;
  52812. thickness?: number;
  52813. tessellation?: number;
  52814. updatable?: boolean;
  52815. sideOrientation?: number;
  52816. frontUVs?: Vector4;
  52817. backUVs?: Vector4;
  52818. }, scene?: Nullable<Scene>): Mesh;
  52819. /**
  52820. * Creates a torus knot mesh
  52821. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52822. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52823. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52824. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52828. * @param name defines the name of the mesh
  52829. * @param options defines the options used to create the mesh
  52830. * @param scene defines the hosting scene
  52831. * @returns the torus knot mesh
  52832. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52833. */
  52834. static CreateTorusKnot(name: string, options: {
  52835. radius?: number;
  52836. tube?: number;
  52837. radialSegments?: number;
  52838. tubularSegments?: number;
  52839. p?: number;
  52840. q?: number;
  52841. updatable?: boolean;
  52842. sideOrientation?: number;
  52843. frontUVs?: Vector4;
  52844. backUVs?: Vector4;
  52845. }, scene?: Nullable<Scene>): Mesh;
  52846. /**
  52847. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52848. * * 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
  52849. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52850. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52851. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52852. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52853. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52854. * * 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
  52855. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52857. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52858. * @param name defines the name of the new line system
  52859. * @param options defines the options used to create the line system
  52860. * @param scene defines the hosting scene
  52861. * @returns a new line system mesh
  52862. */
  52863. static CreateLineSystem(name: string, options: {
  52864. lines: Vector3[][];
  52865. updatable?: boolean;
  52866. instance?: Nullable<LinesMesh>;
  52867. colors?: Nullable<Color4[][]>;
  52868. useVertexAlpha?: boolean;
  52869. }, scene: Nullable<Scene>): LinesMesh;
  52870. /**
  52871. * Creates a line mesh
  52872. * 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
  52873. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52874. * * The parameter `points` is an array successive Vector3
  52875. * * 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
  52876. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52877. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52878. * * When updating an instance, remember that only point positions can change, not the number of points
  52879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52881. * @param name defines the name of the new line system
  52882. * @param options defines the options used to create the line system
  52883. * @param scene defines the hosting scene
  52884. * @returns a new line mesh
  52885. */
  52886. static CreateLines(name: string, options: {
  52887. points: Vector3[];
  52888. updatable?: boolean;
  52889. instance?: Nullable<LinesMesh>;
  52890. colors?: Color4[];
  52891. useVertexAlpha?: boolean;
  52892. }, scene?: Nullable<Scene>): LinesMesh;
  52893. /**
  52894. * Creates a dashed line mesh
  52895. * * 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
  52896. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52897. * * The parameter `points` is an array successive Vector3
  52898. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52899. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52900. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52901. * * 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
  52902. * * When updating an instance, remember that only point positions can change, not the number of points
  52903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52904. * @param name defines the name of the mesh
  52905. * @param options defines the options used to create the mesh
  52906. * @param scene defines the hosting scene
  52907. * @returns the dashed line mesh
  52908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52909. */
  52910. static CreateDashedLines(name: string, options: {
  52911. points: Vector3[];
  52912. dashSize?: number;
  52913. gapSize?: number;
  52914. dashNb?: number;
  52915. updatable?: boolean;
  52916. instance?: LinesMesh;
  52917. }, scene?: Nullable<Scene>): LinesMesh;
  52918. /**
  52919. * 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.
  52920. * * 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.
  52921. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52922. * * 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.
  52923. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52924. * * 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
  52925. * * 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
  52926. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52929. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52931. * @param name defines the name of the mesh
  52932. * @param options defines the options used to create the mesh
  52933. * @param scene defines the hosting scene
  52934. * @returns the extruded shape mesh
  52935. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52937. */
  52938. static ExtrudeShape(name: string, options: {
  52939. shape: Vector3[];
  52940. path: Vector3[];
  52941. scale?: number;
  52942. rotation?: number;
  52943. cap?: number;
  52944. updatable?: boolean;
  52945. sideOrientation?: number;
  52946. frontUVs?: Vector4;
  52947. backUVs?: Vector4;
  52948. instance?: Mesh;
  52949. invertUV?: boolean;
  52950. }, scene?: Nullable<Scene>): Mesh;
  52951. /**
  52952. * Creates an custom extruded shape mesh.
  52953. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52954. * * 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.
  52955. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52956. * * 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
  52957. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52958. * * 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
  52959. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52960. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52961. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52962. * * 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
  52963. * * 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
  52964. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52967. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52969. * @param name defines the name of the mesh
  52970. * @param options defines the options used to create the mesh
  52971. * @param scene defines the hosting scene
  52972. * @returns the custom extruded shape mesh
  52973. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52974. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52975. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52976. */
  52977. static ExtrudeShapeCustom(name: string, options: {
  52978. shape: Vector3[];
  52979. path: Vector3[];
  52980. scaleFunction?: any;
  52981. rotationFunction?: any;
  52982. ribbonCloseArray?: boolean;
  52983. ribbonClosePath?: boolean;
  52984. cap?: number;
  52985. updatable?: boolean;
  52986. sideOrientation?: number;
  52987. frontUVs?: Vector4;
  52988. backUVs?: Vector4;
  52989. instance?: Mesh;
  52990. invertUV?: boolean;
  52991. }, scene?: Nullable<Scene>): Mesh;
  52992. /**
  52993. * Creates lathe mesh.
  52994. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52995. * * 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
  52996. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52997. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52998. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52999. * * 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
  53000. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53001. * * 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
  53002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53004. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53006. * @param name defines the name of the mesh
  53007. * @param options defines the options used to create the mesh
  53008. * @param scene defines the hosting scene
  53009. * @returns the lathe mesh
  53010. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53011. */
  53012. static CreateLathe(name: string, options: {
  53013. shape: Vector3[];
  53014. radius?: number;
  53015. tessellation?: number;
  53016. clip?: number;
  53017. arc?: number;
  53018. closed?: boolean;
  53019. updatable?: boolean;
  53020. sideOrientation?: number;
  53021. frontUVs?: Vector4;
  53022. backUVs?: Vector4;
  53023. cap?: number;
  53024. invertUV?: boolean;
  53025. }, scene?: Nullable<Scene>): Mesh;
  53026. /**
  53027. * Creates a plane mesh
  53028. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53029. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53030. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53034. * @param name defines the name of the mesh
  53035. * @param options defines the options used to create the mesh
  53036. * @param scene defines the hosting scene
  53037. * @returns the plane mesh
  53038. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53039. */
  53040. static CreatePlane(name: string, options: {
  53041. size?: number;
  53042. width?: number;
  53043. height?: number;
  53044. sideOrientation?: number;
  53045. frontUVs?: Vector4;
  53046. backUVs?: Vector4;
  53047. updatable?: boolean;
  53048. sourcePlane?: Plane;
  53049. }, scene?: Nullable<Scene>): Mesh;
  53050. /**
  53051. * Creates a ground mesh
  53052. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53053. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53055. * @param name defines the name of the mesh
  53056. * @param options defines the options used to create the mesh
  53057. * @param scene defines the hosting scene
  53058. * @returns the ground mesh
  53059. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53060. */
  53061. static CreateGround(name: string, options: {
  53062. width?: number;
  53063. height?: number;
  53064. subdivisions?: number;
  53065. subdivisionsX?: number;
  53066. subdivisionsY?: number;
  53067. updatable?: boolean;
  53068. }, scene?: Nullable<Scene>): Mesh;
  53069. /**
  53070. * Creates a tiled ground mesh
  53071. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53072. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53073. * * 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
  53074. * * 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
  53075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53076. * @param name defines the name of the mesh
  53077. * @param options defines the options used to create the mesh
  53078. * @param scene defines the hosting scene
  53079. * @returns the tiled ground mesh
  53080. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53081. */
  53082. static CreateTiledGround(name: string, options: {
  53083. xmin: number;
  53084. zmin: number;
  53085. xmax: number;
  53086. zmax: number;
  53087. subdivisions?: {
  53088. w: number;
  53089. h: number;
  53090. };
  53091. precision?: {
  53092. w: number;
  53093. h: number;
  53094. };
  53095. updatable?: boolean;
  53096. }, scene?: Nullable<Scene>): Mesh;
  53097. /**
  53098. * Creates a ground mesh from a height map
  53099. * * The parameter `url` sets the URL of the height map image resource.
  53100. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53101. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53102. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53103. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53104. * * 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.
  53105. * * 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).
  53106. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53108. * @param name defines the name of the mesh
  53109. * @param url defines the url to the height map
  53110. * @param options defines the options used to create the mesh
  53111. * @param scene defines the hosting scene
  53112. * @returns the ground mesh
  53113. * @see https://doc.babylonjs.com/babylon101/height_map
  53114. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53115. */
  53116. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53117. width?: number;
  53118. height?: number;
  53119. subdivisions?: number;
  53120. minHeight?: number;
  53121. maxHeight?: number;
  53122. colorFilter?: Color3;
  53123. alphaFilter?: number;
  53124. updatable?: boolean;
  53125. onReady?: (mesh: GroundMesh) => void;
  53126. }, scene?: Nullable<Scene>): GroundMesh;
  53127. /**
  53128. * Creates a polygon mesh
  53129. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53130. * * 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
  53131. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  53134. * * Remember you can only change the shape positions, not their number when updating a polygon
  53135. * @param name defines the name of the mesh
  53136. * @param options defines the options used to create the mesh
  53137. * @param scene defines the hosting scene
  53138. * @param earcutInjection can be used to inject your own earcut reference
  53139. * @returns the polygon mesh
  53140. */
  53141. static CreatePolygon(name: string, options: {
  53142. shape: Vector3[];
  53143. holes?: Vector3[][];
  53144. depth?: number;
  53145. faceUV?: Vector4[];
  53146. faceColors?: Color4[];
  53147. updatable?: boolean;
  53148. sideOrientation?: number;
  53149. frontUVs?: Vector4;
  53150. backUVs?: Vector4;
  53151. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53152. /**
  53153. * Creates an extruded polygon mesh, with depth in the Y direction.
  53154. * * 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)
  53155. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53156. * @param name defines the name of the mesh
  53157. * @param options defines the options used to create the mesh
  53158. * @param scene defines the hosting scene
  53159. * @param earcutInjection can be used to inject your own earcut reference
  53160. * @returns the polygon mesh
  53161. */
  53162. static ExtrudePolygon(name: string, options: {
  53163. shape: Vector3[];
  53164. holes?: Vector3[][];
  53165. depth?: number;
  53166. faceUV?: Vector4[];
  53167. faceColors?: Color4[];
  53168. updatable?: boolean;
  53169. sideOrientation?: number;
  53170. frontUVs?: Vector4;
  53171. backUVs?: Vector4;
  53172. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53173. /**
  53174. * Creates a tube mesh.
  53175. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53176. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53177. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53178. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53179. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53180. * * 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)
  53181. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53182. * * 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
  53183. * * 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
  53184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53186. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53188. * @param name defines the name of the mesh
  53189. * @param options defines the options used to create the mesh
  53190. * @param scene defines the hosting scene
  53191. * @returns the tube mesh
  53192. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53193. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53194. */
  53195. static CreateTube(name: string, options: {
  53196. path: Vector3[];
  53197. radius?: number;
  53198. tessellation?: number;
  53199. radiusFunction?: {
  53200. (i: number, distance: number): number;
  53201. };
  53202. cap?: number;
  53203. arc?: number;
  53204. updatable?: boolean;
  53205. sideOrientation?: number;
  53206. frontUVs?: Vector4;
  53207. backUVs?: Vector4;
  53208. instance?: Mesh;
  53209. invertUV?: boolean;
  53210. }, scene?: Nullable<Scene>): Mesh;
  53211. /**
  53212. * Creates a polyhedron mesh
  53213. * * 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
  53214. * * The parameter `size` (positive float, default 1) sets the polygon size
  53215. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53216. * * 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`
  53217. * * 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
  53218. * * 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)`)
  53219. * * 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
  53220. * * 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
  53221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53224. * @param name defines the name of the mesh
  53225. * @param options defines the options used to create the mesh
  53226. * @param scene defines the hosting scene
  53227. * @returns the polyhedron mesh
  53228. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53229. */
  53230. static CreatePolyhedron(name: string, options: {
  53231. type?: number;
  53232. size?: number;
  53233. sizeX?: number;
  53234. sizeY?: number;
  53235. sizeZ?: number;
  53236. custom?: any;
  53237. faceUV?: Vector4[];
  53238. faceColors?: Color4[];
  53239. flat?: boolean;
  53240. updatable?: boolean;
  53241. sideOrientation?: number;
  53242. frontUVs?: Vector4;
  53243. backUVs?: Vector4;
  53244. }, scene?: Nullable<Scene>): Mesh;
  53245. /**
  53246. * Creates a decal mesh.
  53247. * 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
  53248. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53249. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53250. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53251. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53252. * @param name defines the name of the mesh
  53253. * @param sourceMesh defines the mesh where the decal must be applied
  53254. * @param options defines the options used to create the mesh
  53255. * @param scene defines the hosting scene
  53256. * @returns the decal mesh
  53257. * @see https://doc.babylonjs.com/how_to/decals
  53258. */
  53259. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53260. position?: Vector3;
  53261. normal?: Vector3;
  53262. size?: Vector3;
  53263. angle?: number;
  53264. }): Mesh;
  53265. }
  53266. }
  53267. declare module "babylonjs/Meshes/meshSimplification" {
  53268. import { Mesh } from "babylonjs/Meshes/mesh";
  53269. /**
  53270. * A simplifier interface for future simplification implementations
  53271. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53272. */
  53273. export interface ISimplifier {
  53274. /**
  53275. * Simplification of a given mesh according to the given settings.
  53276. * Since this requires computation, it is assumed that the function runs async.
  53277. * @param settings The settings of the simplification, including quality and distance
  53278. * @param successCallback A callback that will be called after the mesh was simplified.
  53279. * @param errorCallback in case of an error, this callback will be called. optional.
  53280. */
  53281. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53282. }
  53283. /**
  53284. * Expected simplification settings.
  53285. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53286. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53287. */
  53288. export interface ISimplificationSettings {
  53289. /**
  53290. * Gets or sets the expected quality
  53291. */
  53292. quality: number;
  53293. /**
  53294. * Gets or sets the distance when this optimized version should be used
  53295. */
  53296. distance: number;
  53297. /**
  53298. * Gets an already optimized mesh
  53299. */
  53300. optimizeMesh?: boolean;
  53301. }
  53302. /**
  53303. * Class used to specify simplification options
  53304. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53305. */
  53306. export class SimplificationSettings implements ISimplificationSettings {
  53307. /** expected quality */
  53308. quality: number;
  53309. /** distance when this optimized version should be used */
  53310. distance: number;
  53311. /** already optimized mesh */
  53312. optimizeMesh?: boolean | undefined;
  53313. /**
  53314. * Creates a SimplificationSettings
  53315. * @param quality expected quality
  53316. * @param distance distance when this optimized version should be used
  53317. * @param optimizeMesh already optimized mesh
  53318. */
  53319. constructor(
  53320. /** expected quality */
  53321. quality: number,
  53322. /** distance when this optimized version should be used */
  53323. distance: number,
  53324. /** already optimized mesh */
  53325. optimizeMesh?: boolean | undefined);
  53326. }
  53327. /**
  53328. * Interface used to define a simplification task
  53329. */
  53330. export interface ISimplificationTask {
  53331. /**
  53332. * Array of settings
  53333. */
  53334. settings: Array<ISimplificationSettings>;
  53335. /**
  53336. * Simplification type
  53337. */
  53338. simplificationType: SimplificationType;
  53339. /**
  53340. * Mesh to simplify
  53341. */
  53342. mesh: Mesh;
  53343. /**
  53344. * Callback called on success
  53345. */
  53346. successCallback?: () => void;
  53347. /**
  53348. * Defines if parallel processing can be used
  53349. */
  53350. parallelProcessing: boolean;
  53351. }
  53352. /**
  53353. * Queue used to order the simplification tasks
  53354. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53355. */
  53356. export class SimplificationQueue {
  53357. private _simplificationArray;
  53358. /**
  53359. * Gets a boolean indicating that the process is still running
  53360. */
  53361. running: boolean;
  53362. /**
  53363. * Creates a new queue
  53364. */
  53365. constructor();
  53366. /**
  53367. * Adds a new simplification task
  53368. * @param task defines a task to add
  53369. */
  53370. addTask(task: ISimplificationTask): void;
  53371. /**
  53372. * Execute next task
  53373. */
  53374. executeNext(): void;
  53375. /**
  53376. * Execute a simplification task
  53377. * @param task defines the task to run
  53378. */
  53379. runSimplification(task: ISimplificationTask): void;
  53380. private getSimplifier;
  53381. }
  53382. /**
  53383. * The implemented types of simplification
  53384. * At the moment only Quadratic Error Decimation is implemented
  53385. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53386. */
  53387. export enum SimplificationType {
  53388. /** Quadratic error decimation */
  53389. QUADRATIC = 0
  53390. }
  53391. }
  53392. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53393. import { Scene } from "babylonjs/scene";
  53394. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53395. import { ISceneComponent } from "babylonjs/sceneComponent";
  53396. module "babylonjs/scene" {
  53397. interface Scene {
  53398. /** @hidden (Backing field) */
  53399. _simplificationQueue: SimplificationQueue;
  53400. /**
  53401. * Gets or sets the simplification queue attached to the scene
  53402. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53403. */
  53404. simplificationQueue: SimplificationQueue;
  53405. }
  53406. }
  53407. module "babylonjs/Meshes/mesh" {
  53408. interface Mesh {
  53409. /**
  53410. * Simplify the mesh according to the given array of settings.
  53411. * Function will return immediately and will simplify async
  53412. * @param settings a collection of simplification settings
  53413. * @param parallelProcessing should all levels calculate parallel or one after the other
  53414. * @param simplificationType the type of simplification to run
  53415. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53416. * @returns the current mesh
  53417. */
  53418. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53419. }
  53420. }
  53421. /**
  53422. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53423. * created in a scene
  53424. */
  53425. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53426. /**
  53427. * The component name helpfull to identify the component in the list of scene components.
  53428. */
  53429. readonly name: string;
  53430. /**
  53431. * The scene the component belongs to.
  53432. */
  53433. scene: Scene;
  53434. /**
  53435. * Creates a new instance of the component for the given scene
  53436. * @param scene Defines the scene to register the component in
  53437. */
  53438. constructor(scene: Scene);
  53439. /**
  53440. * Registers the component in a given scene
  53441. */
  53442. register(): void;
  53443. /**
  53444. * Rebuilds the elements related to this component in case of
  53445. * context lost for instance.
  53446. */
  53447. rebuild(): void;
  53448. /**
  53449. * Disposes the component and the associated ressources
  53450. */
  53451. dispose(): void;
  53452. private _beforeCameraUpdate;
  53453. }
  53454. }
  53455. declare module "babylonjs/Meshes/Builders/index" {
  53456. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53457. export * from "babylonjs/Meshes/Builders/discBuilder";
  53458. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53459. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53460. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53461. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53462. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53463. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53464. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53465. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53466. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53467. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53468. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53469. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53470. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53471. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53472. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53473. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53474. }
  53475. declare module "babylonjs/Meshes/index" {
  53476. export * from "babylonjs/Meshes/abstractMesh";
  53477. export * from "babylonjs/Meshes/buffer";
  53478. export * from "babylonjs/Meshes/Compression/index";
  53479. export * from "babylonjs/Meshes/csg";
  53480. export * from "babylonjs/Meshes/geometry";
  53481. export * from "babylonjs/Meshes/groundMesh";
  53482. export * from "babylonjs/Meshes/trailMesh";
  53483. export * from "babylonjs/Meshes/instancedMesh";
  53484. export * from "babylonjs/Meshes/linesMesh";
  53485. export * from "babylonjs/Meshes/mesh";
  53486. export * from "babylonjs/Meshes/mesh.vertexData";
  53487. export * from "babylonjs/Meshes/meshBuilder";
  53488. export * from "babylonjs/Meshes/meshSimplification";
  53489. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53490. export * from "babylonjs/Meshes/polygonMesh";
  53491. export * from "babylonjs/Meshes/subMesh";
  53492. export * from "babylonjs/Meshes/meshLODLevel";
  53493. export * from "babylonjs/Meshes/transformNode";
  53494. export * from "babylonjs/Meshes/Builders/index";
  53495. export * from "babylonjs/Meshes/dataBuffer";
  53496. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  53497. }
  53498. declare module "babylonjs/Morph/index" {
  53499. export * from "babylonjs/Morph/morphTarget";
  53500. export * from "babylonjs/Morph/morphTargetManager";
  53501. }
  53502. declare module "babylonjs/Offline/database" {
  53503. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53504. /**
  53505. * Class used to enable access to IndexedDB
  53506. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53507. */
  53508. export class Database implements IOfflineProvider {
  53509. private _callbackManifestChecked;
  53510. private _currentSceneUrl;
  53511. private _db;
  53512. private _enableSceneOffline;
  53513. private _enableTexturesOffline;
  53514. private _manifestVersionFound;
  53515. private _mustUpdateRessources;
  53516. private _hasReachedQuota;
  53517. private _isSupported;
  53518. private _idbFactory;
  53519. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53520. private static IsUASupportingBlobStorage;
  53521. /**
  53522. * Gets a boolean indicating if Database storate is enabled (off by default)
  53523. */
  53524. static IDBStorageEnabled: boolean;
  53525. /**
  53526. * Gets a boolean indicating if scene must be saved in the database
  53527. */
  53528. readonly enableSceneOffline: boolean;
  53529. /**
  53530. * Gets a boolean indicating if textures must be saved in the database
  53531. */
  53532. readonly enableTexturesOffline: boolean;
  53533. /**
  53534. * Creates a new Database
  53535. * @param urlToScene defines the url to load the scene
  53536. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53537. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53538. */
  53539. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53540. private static _ParseURL;
  53541. private static _ReturnFullUrlLocation;
  53542. private _checkManifestFile;
  53543. /**
  53544. * Open the database and make it available
  53545. * @param successCallback defines the callback to call on success
  53546. * @param errorCallback defines the callback to call on error
  53547. */
  53548. open(successCallback: () => void, errorCallback: () => void): void;
  53549. /**
  53550. * Loads an image from the database
  53551. * @param url defines the url to load from
  53552. * @param image defines the target DOM image
  53553. */
  53554. loadImage(url: string, image: HTMLImageElement): void;
  53555. private _loadImageFromDBAsync;
  53556. private _saveImageIntoDBAsync;
  53557. private _checkVersionFromDB;
  53558. private _loadVersionFromDBAsync;
  53559. private _saveVersionIntoDBAsync;
  53560. /**
  53561. * Loads a file from database
  53562. * @param url defines the URL to load from
  53563. * @param sceneLoaded defines a callback to call on success
  53564. * @param progressCallBack defines a callback to call when progress changed
  53565. * @param errorCallback defines a callback to call on error
  53566. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53567. */
  53568. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53569. private _loadFileAsync;
  53570. private _saveFileAsync;
  53571. /**
  53572. * Validates if xhr data is correct
  53573. * @param xhr defines the request to validate
  53574. * @param dataType defines the expected data type
  53575. * @returns true if data is correct
  53576. */
  53577. private static _ValidateXHRData;
  53578. }
  53579. }
  53580. declare module "babylonjs/Offline/index" {
  53581. export * from "babylonjs/Offline/database";
  53582. export * from "babylonjs/Offline/IOfflineProvider";
  53583. }
  53584. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53585. /** @hidden */
  53586. export var gpuUpdateParticlesPixelShader: {
  53587. name: string;
  53588. shader: string;
  53589. };
  53590. }
  53591. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53592. /** @hidden */
  53593. export var gpuUpdateParticlesVertexShader: {
  53594. name: string;
  53595. shader: string;
  53596. };
  53597. }
  53598. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53599. /** @hidden */
  53600. export var clipPlaneFragmentDeclaration2: {
  53601. name: string;
  53602. shader: string;
  53603. };
  53604. }
  53605. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53606. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53607. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53608. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53609. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53610. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53611. /** @hidden */
  53612. export var gpuRenderParticlesPixelShader: {
  53613. name: string;
  53614. shader: string;
  53615. };
  53616. }
  53617. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53618. /** @hidden */
  53619. export var clipPlaneVertexDeclaration2: {
  53620. name: string;
  53621. shader: string;
  53622. };
  53623. }
  53624. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53625. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53626. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53627. /** @hidden */
  53628. export var gpuRenderParticlesVertexShader: {
  53629. name: string;
  53630. shader: string;
  53631. };
  53632. }
  53633. declare module "babylonjs/Particles/gpuParticleSystem" {
  53634. import { Nullable } from "babylonjs/types";
  53635. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53636. import { Observable } from "babylonjs/Misc/observable";
  53637. import { Color4, Color3 } from "babylonjs/Maths/math";
  53638. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53639. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53640. import { Scene, IDisposable } from "babylonjs/scene";
  53641. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53642. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53643. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53644. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53645. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53646. /**
  53647. * This represents a GPU particle system in Babylon
  53648. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53649. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53650. */
  53651. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53652. /**
  53653. * The layer mask we are rendering the particles through.
  53654. */
  53655. layerMask: number;
  53656. private _capacity;
  53657. private _activeCount;
  53658. private _currentActiveCount;
  53659. private _accumulatedCount;
  53660. private _renderEffect;
  53661. private _updateEffect;
  53662. private _buffer0;
  53663. private _buffer1;
  53664. private _spriteBuffer;
  53665. private _updateVAO;
  53666. private _renderVAO;
  53667. private _targetIndex;
  53668. private _sourceBuffer;
  53669. private _targetBuffer;
  53670. private _engine;
  53671. private _currentRenderId;
  53672. private _started;
  53673. private _stopped;
  53674. private _timeDelta;
  53675. private _randomTexture;
  53676. private _randomTexture2;
  53677. private _attributesStrideSize;
  53678. private _updateEffectOptions;
  53679. private _randomTextureSize;
  53680. private _actualFrame;
  53681. private readonly _rawTextureWidth;
  53682. /**
  53683. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53684. */
  53685. static readonly IsSupported: boolean;
  53686. /**
  53687. * An event triggered when the system is disposed.
  53688. */
  53689. onDisposeObservable: Observable<GPUParticleSystem>;
  53690. /**
  53691. * Gets the maximum number of particles active at the same time.
  53692. * @returns The max number of active particles.
  53693. */
  53694. getCapacity(): number;
  53695. /**
  53696. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53697. * to override the particles.
  53698. */
  53699. forceDepthWrite: boolean;
  53700. /**
  53701. * Gets or set the number of active particles
  53702. */
  53703. activeParticleCount: number;
  53704. private _preWarmDone;
  53705. /**
  53706. * Is this system ready to be used/rendered
  53707. * @return true if the system is ready
  53708. */
  53709. isReady(): boolean;
  53710. /**
  53711. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53712. * @returns True if it has been started, otherwise false.
  53713. */
  53714. isStarted(): boolean;
  53715. /**
  53716. * Starts the particle system and begins to emit
  53717. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53718. */
  53719. start(delay?: number): void;
  53720. /**
  53721. * Stops the particle system.
  53722. */
  53723. stop(): void;
  53724. /**
  53725. * Remove all active particles
  53726. */
  53727. reset(): void;
  53728. /**
  53729. * Returns the string "GPUParticleSystem"
  53730. * @returns a string containing the class name
  53731. */
  53732. getClassName(): string;
  53733. private _colorGradientsTexture;
  53734. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53735. /**
  53736. * Adds a new color gradient
  53737. * @param gradient defines the gradient to use (between 0 and 1)
  53738. * @param color1 defines the color to affect to the specified gradient
  53739. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53740. * @returns the current particle system
  53741. */
  53742. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53743. /**
  53744. * Remove a specific color gradient
  53745. * @param gradient defines the gradient to remove
  53746. * @returns the current particle system
  53747. */
  53748. removeColorGradient(gradient: number): GPUParticleSystem;
  53749. private _angularSpeedGradientsTexture;
  53750. private _sizeGradientsTexture;
  53751. private _velocityGradientsTexture;
  53752. private _limitVelocityGradientsTexture;
  53753. private _dragGradientsTexture;
  53754. private _addFactorGradient;
  53755. /**
  53756. * Adds a new size gradient
  53757. * @param gradient defines the gradient to use (between 0 and 1)
  53758. * @param factor defines the size factor to affect to the specified gradient
  53759. * @returns the current particle system
  53760. */
  53761. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53762. /**
  53763. * Remove a specific size gradient
  53764. * @param gradient defines the gradient to remove
  53765. * @returns the current particle system
  53766. */
  53767. removeSizeGradient(gradient: number): GPUParticleSystem;
  53768. /**
  53769. * Adds a new angular speed gradient
  53770. * @param gradient defines the gradient to use (between 0 and 1)
  53771. * @param factor defines the angular speed to affect to the specified gradient
  53772. * @returns the current particle system
  53773. */
  53774. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53775. /**
  53776. * Remove a specific angular speed gradient
  53777. * @param gradient defines the gradient to remove
  53778. * @returns the current particle system
  53779. */
  53780. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53781. /**
  53782. * Adds a new velocity gradient
  53783. * @param gradient defines the gradient to use (between 0 and 1)
  53784. * @param factor defines the velocity to affect to the specified gradient
  53785. * @returns the current particle system
  53786. */
  53787. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53788. /**
  53789. * Remove a specific velocity gradient
  53790. * @param gradient defines the gradient to remove
  53791. * @returns the current particle system
  53792. */
  53793. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53794. /**
  53795. * Adds a new limit velocity gradient
  53796. * @param gradient defines the gradient to use (between 0 and 1)
  53797. * @param factor defines the limit velocity value to affect to the specified gradient
  53798. * @returns the current particle system
  53799. */
  53800. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53801. /**
  53802. * Remove a specific limit velocity gradient
  53803. * @param gradient defines the gradient to remove
  53804. * @returns the current particle system
  53805. */
  53806. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53807. /**
  53808. * Adds a new drag gradient
  53809. * @param gradient defines the gradient to use (between 0 and 1)
  53810. * @param factor defines the drag value to affect to the specified gradient
  53811. * @returns the current particle system
  53812. */
  53813. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53814. /**
  53815. * Remove a specific drag gradient
  53816. * @param gradient defines the gradient to remove
  53817. * @returns the current particle system
  53818. */
  53819. removeDragGradient(gradient: number): GPUParticleSystem;
  53820. /**
  53821. * Not supported by GPUParticleSystem
  53822. * @param gradient defines the gradient to use (between 0 and 1)
  53823. * @param factor defines the emit rate value to affect to the specified gradient
  53824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53825. * @returns the current particle system
  53826. */
  53827. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53828. /**
  53829. * Not supported by GPUParticleSystem
  53830. * @param gradient defines the gradient to remove
  53831. * @returns the current particle system
  53832. */
  53833. removeEmitRateGradient(gradient: number): IParticleSystem;
  53834. /**
  53835. * Not supported by GPUParticleSystem
  53836. * @param gradient defines the gradient to use (between 0 and 1)
  53837. * @param factor defines the start size value to affect to the specified gradient
  53838. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53839. * @returns the current particle system
  53840. */
  53841. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53842. /**
  53843. * Not supported by GPUParticleSystem
  53844. * @param gradient defines the gradient to remove
  53845. * @returns the current particle system
  53846. */
  53847. removeStartSizeGradient(gradient: number): IParticleSystem;
  53848. /**
  53849. * Not supported by GPUParticleSystem
  53850. * @param gradient defines the gradient to use (between 0 and 1)
  53851. * @param min defines the color remap minimal range
  53852. * @param max defines the color remap maximal range
  53853. * @returns the current particle system
  53854. */
  53855. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53856. /**
  53857. * Not supported by GPUParticleSystem
  53858. * @param gradient defines the gradient to remove
  53859. * @returns the current particle system
  53860. */
  53861. removeColorRemapGradient(): IParticleSystem;
  53862. /**
  53863. * Not supported by GPUParticleSystem
  53864. * @param gradient defines the gradient to use (between 0 and 1)
  53865. * @param min defines the alpha remap minimal range
  53866. * @param max defines the alpha remap maximal range
  53867. * @returns the current particle system
  53868. */
  53869. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53870. /**
  53871. * Not supported by GPUParticleSystem
  53872. * @param gradient defines the gradient to remove
  53873. * @returns the current particle system
  53874. */
  53875. removeAlphaRemapGradient(): IParticleSystem;
  53876. /**
  53877. * Not supported by GPUParticleSystem
  53878. * @param gradient defines the gradient to use (between 0 and 1)
  53879. * @param color defines the color to affect to the specified gradient
  53880. * @returns the current particle system
  53881. */
  53882. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53883. /**
  53884. * Not supported by GPUParticleSystem
  53885. * @param gradient defines the gradient to remove
  53886. * @returns the current particle system
  53887. */
  53888. removeRampGradient(): IParticleSystem;
  53889. /**
  53890. * Not supported by GPUParticleSystem
  53891. * @returns the list of ramp gradients
  53892. */
  53893. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53894. /**
  53895. * Not supported by GPUParticleSystem
  53896. * Gets or sets a boolean indicating that ramp gradients must be used
  53897. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53898. */
  53899. useRampGradients: boolean;
  53900. /**
  53901. * Not supported by GPUParticleSystem
  53902. * @param gradient defines the gradient to use (between 0 and 1)
  53903. * @param factor defines the life time factor to affect to the specified gradient
  53904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53905. * @returns the current particle system
  53906. */
  53907. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53908. /**
  53909. * Not supported by GPUParticleSystem
  53910. * @param gradient defines the gradient to remove
  53911. * @returns the current particle system
  53912. */
  53913. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53914. /**
  53915. * Instantiates a GPU particle system.
  53916. * 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.
  53917. * @param name The name of the particle system
  53918. * @param options The options used to create the system
  53919. * @param scene The scene the particle system belongs to
  53920. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53921. */
  53922. constructor(name: string, options: Partial<{
  53923. capacity: number;
  53924. randomTextureSize: number;
  53925. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53926. protected _reset(): void;
  53927. private _createUpdateVAO;
  53928. private _createRenderVAO;
  53929. private _initialize;
  53930. /** @hidden */
  53931. _recreateUpdateEffect(): void;
  53932. /** @hidden */
  53933. _recreateRenderEffect(): void;
  53934. /**
  53935. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53936. * @param preWarm defines if we are in the pre-warmimg phase
  53937. */
  53938. animate(preWarm?: boolean): void;
  53939. private _createFactorGradientTexture;
  53940. private _createSizeGradientTexture;
  53941. private _createAngularSpeedGradientTexture;
  53942. private _createVelocityGradientTexture;
  53943. private _createLimitVelocityGradientTexture;
  53944. private _createDragGradientTexture;
  53945. private _createColorGradientTexture;
  53946. /**
  53947. * Renders the particle system in its current state
  53948. * @param preWarm defines if the system should only update the particles but not render them
  53949. * @returns the current number of particles
  53950. */
  53951. render(preWarm?: boolean): number;
  53952. /**
  53953. * Rebuilds the particle system
  53954. */
  53955. rebuild(): void;
  53956. private _releaseBuffers;
  53957. private _releaseVAOs;
  53958. /**
  53959. * Disposes the particle system and free the associated resources
  53960. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53961. */
  53962. dispose(disposeTexture?: boolean): void;
  53963. /**
  53964. * Clones the particle system.
  53965. * @param name The name of the cloned object
  53966. * @param newEmitter The new emitter to use
  53967. * @returns the cloned particle system
  53968. */
  53969. clone(name: string, newEmitter: any): GPUParticleSystem;
  53970. /**
  53971. * Serializes the particle system to a JSON object.
  53972. * @returns the JSON object
  53973. */
  53974. serialize(): any;
  53975. /**
  53976. * Parses a JSON object to create a GPU particle system.
  53977. * @param parsedParticleSystem The JSON object to parse
  53978. * @param scene The scene to create the particle system in
  53979. * @param rootUrl The root url to use to load external dependencies like texture
  53980. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53981. * @returns the parsed GPU particle system
  53982. */
  53983. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53984. }
  53985. }
  53986. declare module "babylonjs/Particles/particleSystemSet" {
  53987. import { Nullable } from "babylonjs/types";
  53988. import { Color3 } from "babylonjs/Maths/math";
  53989. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53991. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53992. import { Scene, IDisposable } from "babylonjs/scene";
  53993. /**
  53994. * Represents a set of particle systems working together to create a specific effect
  53995. */
  53996. export class ParticleSystemSet implements IDisposable {
  53997. private _emitterCreationOptions;
  53998. private _emitterNode;
  53999. /**
  54000. * Gets the particle system list
  54001. */
  54002. systems: IParticleSystem[];
  54003. /**
  54004. * Gets the emitter node used with this set
  54005. */
  54006. readonly emitterNode: Nullable<TransformNode>;
  54007. /**
  54008. * Creates a new emitter mesh as a sphere
  54009. * @param options defines the options used to create the sphere
  54010. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54011. * @param scene defines the hosting scene
  54012. */
  54013. setEmitterAsSphere(options: {
  54014. diameter: number;
  54015. segments: number;
  54016. color: Color3;
  54017. }, renderingGroupId: number, scene: Scene): void;
  54018. /**
  54019. * Starts all particle systems of the set
  54020. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54021. */
  54022. start(emitter?: AbstractMesh): void;
  54023. /**
  54024. * Release all associated resources
  54025. */
  54026. dispose(): void;
  54027. /**
  54028. * Serialize the set into a JSON compatible object
  54029. * @returns a JSON compatible representation of the set
  54030. */
  54031. serialize(): any;
  54032. /**
  54033. * Parse a new ParticleSystemSet from a serialized source
  54034. * @param data defines a JSON compatible representation of the set
  54035. * @param scene defines the hosting scene
  54036. * @param gpu defines if we want GPU particles or CPU particles
  54037. * @returns a new ParticleSystemSet
  54038. */
  54039. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54040. }
  54041. }
  54042. declare module "babylonjs/Particles/particleHelper" {
  54043. import { Nullable } from "babylonjs/types";
  54044. import { Scene } from "babylonjs/scene";
  54045. import { Vector3 } from "babylonjs/Maths/math";
  54046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54047. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54048. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  54049. /**
  54050. * This class is made for on one-liner static method to help creating particle system set.
  54051. */
  54052. export class ParticleHelper {
  54053. /**
  54054. * Gets or sets base Assets URL
  54055. */
  54056. static BaseAssetsUrl: string;
  54057. /**
  54058. * Create a default particle system that you can tweak
  54059. * @param emitter defines the emitter to use
  54060. * @param capacity defines the system capacity (default is 500 particles)
  54061. * @param scene defines the hosting scene
  54062. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54063. * @returns the new Particle system
  54064. */
  54065. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54066. /**
  54067. * This is the main static method (one-liner) of this helper to create different particle systems
  54068. * @param type This string represents the type to the particle system to create
  54069. * @param scene The scene where the particle system should live
  54070. * @param gpu If the system will use gpu
  54071. * @returns the ParticleSystemSet created
  54072. */
  54073. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54074. /**
  54075. * Static function used to export a particle system to a ParticleSystemSet variable.
  54076. * Please note that the emitter shape is not exported
  54077. * @param systems defines the particle systems to export
  54078. * @returns the created particle system set
  54079. */
  54080. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54081. }
  54082. }
  54083. declare module "babylonjs/Particles/particleSystemComponent" {
  54084. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54085. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54086. import "babylonjs/Shaders/particles.vertex";
  54087. module "babylonjs/Engines/engine" {
  54088. interface Engine {
  54089. /**
  54090. * Create an effect to use with particle systems.
  54091. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54092. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54093. * @param uniformsNames defines a list of attribute names
  54094. * @param samplers defines an array of string used to represent textures
  54095. * @param defines defines the string containing the defines to use to compile the shaders
  54096. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54097. * @param onCompiled defines a function to call when the effect creation is successful
  54098. * @param onError defines a function to call when the effect creation has failed
  54099. * @returns the new Effect
  54100. */
  54101. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54102. }
  54103. }
  54104. module "babylonjs/Meshes/mesh" {
  54105. interface Mesh {
  54106. /**
  54107. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54108. * @returns an array of IParticleSystem
  54109. */
  54110. getEmittedParticleSystems(): IParticleSystem[];
  54111. /**
  54112. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54113. * @returns an array of IParticleSystem
  54114. */
  54115. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54116. }
  54117. }
  54118. /**
  54119. * @hidden
  54120. */
  54121. export var _IDoNeedToBeInTheBuild: number;
  54122. }
  54123. declare module "babylonjs/Particles/index" {
  54124. export * from "babylonjs/Particles/baseParticleSystem";
  54125. export * from "babylonjs/Particles/EmitterTypes/index";
  54126. export * from "babylonjs/Particles/gpuParticleSystem";
  54127. export * from "babylonjs/Particles/IParticleSystem";
  54128. export * from "babylonjs/Particles/particle";
  54129. export * from "babylonjs/Particles/particleHelper";
  54130. export * from "babylonjs/Particles/particleSystem";
  54131. export * from "babylonjs/Particles/particleSystemComponent";
  54132. export * from "babylonjs/Particles/particleSystemSet";
  54133. export * from "babylonjs/Particles/solidParticle";
  54134. export * from "babylonjs/Particles/solidParticleSystem";
  54135. export * from "babylonjs/Particles/subEmitter";
  54136. }
  54137. declare module "babylonjs/Physics/physicsEngineComponent" {
  54138. import { Nullable } from "babylonjs/types";
  54139. import { Observable, Observer } from "babylonjs/Misc/observable";
  54140. import { Vector3 } from "babylonjs/Maths/math";
  54141. import { Mesh } from "babylonjs/Meshes/mesh";
  54142. import { ISceneComponent } from "babylonjs/sceneComponent";
  54143. import { Scene } from "babylonjs/scene";
  54144. import { Node } from "babylonjs/node";
  54145. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54146. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54147. module "babylonjs/scene" {
  54148. interface Scene {
  54149. /** @hidden (Backing field) */
  54150. _physicsEngine: Nullable<IPhysicsEngine>;
  54151. /**
  54152. * Gets the current physics engine
  54153. * @returns a IPhysicsEngine or null if none attached
  54154. */
  54155. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54156. /**
  54157. * Enables physics to the current scene
  54158. * @param gravity defines the scene's gravity for the physics engine
  54159. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54160. * @return a boolean indicating if the physics engine was initialized
  54161. */
  54162. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54163. /**
  54164. * Disables and disposes the physics engine associated with the scene
  54165. */
  54166. disablePhysicsEngine(): void;
  54167. /**
  54168. * Gets a boolean indicating if there is an active physics engine
  54169. * @returns a boolean indicating if there is an active physics engine
  54170. */
  54171. isPhysicsEnabled(): boolean;
  54172. /**
  54173. * Deletes a physics compound impostor
  54174. * @param compound defines the compound to delete
  54175. */
  54176. deleteCompoundImpostor(compound: any): void;
  54177. /**
  54178. * An event triggered when physic simulation is about to be run
  54179. */
  54180. onBeforePhysicsObservable: Observable<Scene>;
  54181. /**
  54182. * An event triggered when physic simulation has been done
  54183. */
  54184. onAfterPhysicsObservable: Observable<Scene>;
  54185. }
  54186. }
  54187. module "babylonjs/Meshes/abstractMesh" {
  54188. interface AbstractMesh {
  54189. /** @hidden */
  54190. _physicsImpostor: Nullable<PhysicsImpostor>;
  54191. /**
  54192. * Gets or sets impostor used for physic simulation
  54193. * @see http://doc.babylonjs.com/features/physics_engine
  54194. */
  54195. physicsImpostor: Nullable<PhysicsImpostor>;
  54196. /**
  54197. * Gets the current physics impostor
  54198. * @see http://doc.babylonjs.com/features/physics_engine
  54199. * @returns a physics impostor or null
  54200. */
  54201. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54202. /** Apply a physic impulse to the mesh
  54203. * @param force defines the force to apply
  54204. * @param contactPoint defines where to apply the force
  54205. * @returns the current mesh
  54206. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54207. */
  54208. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54209. /**
  54210. * Creates a physic joint between two meshes
  54211. * @param otherMesh defines the other mesh to use
  54212. * @param pivot1 defines the pivot to use on this mesh
  54213. * @param pivot2 defines the pivot to use on the other mesh
  54214. * @param options defines additional options (can be plugin dependent)
  54215. * @returns the current mesh
  54216. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54217. */
  54218. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54219. /** @hidden */
  54220. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54221. }
  54222. }
  54223. /**
  54224. * Defines the physics engine scene component responsible to manage a physics engine
  54225. */
  54226. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54227. /**
  54228. * The component name helpful to identify the component in the list of scene components.
  54229. */
  54230. readonly name: string;
  54231. /**
  54232. * The scene the component belongs to.
  54233. */
  54234. scene: Scene;
  54235. /**
  54236. * Creates a new instance of the component for the given scene
  54237. * @param scene Defines the scene to register the component in
  54238. */
  54239. constructor(scene: Scene);
  54240. /**
  54241. * Registers the component in a given scene
  54242. */
  54243. register(): void;
  54244. /**
  54245. * Rebuilds the elements related to this component in case of
  54246. * context lost for instance.
  54247. */
  54248. rebuild(): void;
  54249. /**
  54250. * Disposes the component and the associated ressources
  54251. */
  54252. dispose(): void;
  54253. }
  54254. }
  54255. declare module "babylonjs/Physics/physicsHelper" {
  54256. import { Nullable } from "babylonjs/types";
  54257. import { Vector3 } from "babylonjs/Maths/math";
  54258. import { Mesh } from "babylonjs/Meshes/mesh";
  54259. import { Scene } from "babylonjs/scene";
  54260. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54261. /**
  54262. * A helper for physics simulations
  54263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54264. */
  54265. export class PhysicsHelper {
  54266. private _scene;
  54267. private _physicsEngine;
  54268. /**
  54269. * Initializes the Physics helper
  54270. * @param scene Babylon.js scene
  54271. */
  54272. constructor(scene: Scene);
  54273. /**
  54274. * Applies a radial explosion impulse
  54275. * @param origin the origin of the explosion
  54276. * @param radiusOrEventOptions the radius or the options of radial explosion
  54277. * @param strength the explosion strength
  54278. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54279. * @returns A physics radial explosion event, or null
  54280. */
  54281. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54282. /**
  54283. * Applies a radial explosion force
  54284. * @param origin the origin of the explosion
  54285. * @param radiusOrEventOptions the radius or the options of radial explosion
  54286. * @param strength the explosion strength
  54287. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54288. * @returns A physics radial explosion event, or null
  54289. */
  54290. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54291. /**
  54292. * Creates a gravitational field
  54293. * @param origin the origin of the explosion
  54294. * @param radiusOrEventOptions the radius or the options of radial explosion
  54295. * @param strength the explosion strength
  54296. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54297. * @returns A physics gravitational field event, or null
  54298. */
  54299. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54300. /**
  54301. * Creates a physics updraft event
  54302. * @param origin the origin of the updraft
  54303. * @param radiusOrEventOptions the radius or the options of the updraft
  54304. * @param strength the strength of the updraft
  54305. * @param height the height of the updraft
  54306. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54307. * @returns A physics updraft event, or null
  54308. */
  54309. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54310. /**
  54311. * Creates a physics vortex event
  54312. * @param origin the of the vortex
  54313. * @param radiusOrEventOptions the radius or the options of the vortex
  54314. * @param strength the strength of the vortex
  54315. * @param height the height of the vortex
  54316. * @returns a Physics vortex event, or null
  54317. * A physics vortex event or null
  54318. */
  54319. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54320. }
  54321. /**
  54322. * Represents a physics radial explosion event
  54323. */
  54324. class PhysicsRadialExplosionEvent {
  54325. private _scene;
  54326. private _options;
  54327. private _sphere;
  54328. private _dataFetched;
  54329. /**
  54330. * Initializes a radial explosioin event
  54331. * @param _scene BabylonJS scene
  54332. * @param _options The options for the vortex event
  54333. */
  54334. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54335. /**
  54336. * Returns the data related to the radial explosion event (sphere).
  54337. * @returns The radial explosion event data
  54338. */
  54339. getData(): PhysicsRadialExplosionEventData;
  54340. /**
  54341. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54342. * @param impostor A physics imposter
  54343. * @param origin the origin of the explosion
  54344. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54345. */
  54346. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54347. /**
  54348. * Triggers affecterd impostors callbacks
  54349. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54350. */
  54351. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54352. /**
  54353. * Disposes the sphere.
  54354. * @param force Specifies if the sphere should be disposed by force
  54355. */
  54356. dispose(force?: boolean): void;
  54357. /*** Helpers ***/
  54358. private _prepareSphere;
  54359. private _intersectsWithSphere;
  54360. }
  54361. /**
  54362. * Represents a gravitational field event
  54363. */
  54364. class PhysicsGravitationalFieldEvent {
  54365. private _physicsHelper;
  54366. private _scene;
  54367. private _origin;
  54368. private _options;
  54369. private _tickCallback;
  54370. private _sphere;
  54371. private _dataFetched;
  54372. /**
  54373. * Initializes the physics gravitational field event
  54374. * @param _physicsHelper A physics helper
  54375. * @param _scene BabylonJS scene
  54376. * @param _origin The origin position of the gravitational field event
  54377. * @param _options The options for the vortex event
  54378. */
  54379. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54380. /**
  54381. * Returns the data related to the gravitational field event (sphere).
  54382. * @returns A gravitational field event
  54383. */
  54384. getData(): PhysicsGravitationalFieldEventData;
  54385. /**
  54386. * Enables the gravitational field.
  54387. */
  54388. enable(): void;
  54389. /**
  54390. * Disables the gravitational field.
  54391. */
  54392. disable(): void;
  54393. /**
  54394. * Disposes the sphere.
  54395. * @param force The force to dispose from the gravitational field event
  54396. */
  54397. dispose(force?: boolean): void;
  54398. private _tick;
  54399. }
  54400. /**
  54401. * Represents a physics updraft event
  54402. */
  54403. class PhysicsUpdraftEvent {
  54404. private _scene;
  54405. private _origin;
  54406. private _options;
  54407. private _physicsEngine;
  54408. private _originTop;
  54409. private _originDirection;
  54410. private _tickCallback;
  54411. private _cylinder;
  54412. private _cylinderPosition;
  54413. private _dataFetched;
  54414. /**
  54415. * Initializes the physics updraft event
  54416. * @param _scene BabylonJS scene
  54417. * @param _origin The origin position of the updraft
  54418. * @param _options The options for the updraft event
  54419. */
  54420. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54421. /**
  54422. * Returns the data related to the updraft event (cylinder).
  54423. * @returns A physics updraft event
  54424. */
  54425. getData(): PhysicsUpdraftEventData;
  54426. /**
  54427. * Enables the updraft.
  54428. */
  54429. enable(): void;
  54430. /**
  54431. * Disables the updraft.
  54432. */
  54433. disable(): void;
  54434. /**
  54435. * Disposes the cylinder.
  54436. * @param force Specifies if the updraft should be disposed by force
  54437. */
  54438. dispose(force?: boolean): void;
  54439. private getImpostorHitData;
  54440. private _tick;
  54441. /*** Helpers ***/
  54442. private _prepareCylinder;
  54443. private _intersectsWithCylinder;
  54444. }
  54445. /**
  54446. * Represents a physics vortex event
  54447. */
  54448. class PhysicsVortexEvent {
  54449. private _scene;
  54450. private _origin;
  54451. private _options;
  54452. private _physicsEngine;
  54453. private _originTop;
  54454. private _tickCallback;
  54455. private _cylinder;
  54456. private _cylinderPosition;
  54457. private _dataFetched;
  54458. /**
  54459. * Initializes the physics vortex event
  54460. * @param _scene The BabylonJS scene
  54461. * @param _origin The origin position of the vortex
  54462. * @param _options The options for the vortex event
  54463. */
  54464. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54465. /**
  54466. * Returns the data related to the vortex event (cylinder).
  54467. * @returns The physics vortex event data
  54468. */
  54469. getData(): PhysicsVortexEventData;
  54470. /**
  54471. * Enables the vortex.
  54472. */
  54473. enable(): void;
  54474. /**
  54475. * Disables the cortex.
  54476. */
  54477. disable(): void;
  54478. /**
  54479. * Disposes the sphere.
  54480. * @param force
  54481. */
  54482. dispose(force?: boolean): void;
  54483. private getImpostorHitData;
  54484. private _tick;
  54485. /*** Helpers ***/
  54486. private _prepareCylinder;
  54487. private _intersectsWithCylinder;
  54488. }
  54489. /**
  54490. * Options fot the radial explosion event
  54491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54492. */
  54493. export class PhysicsRadialExplosionEventOptions {
  54494. /**
  54495. * The radius of the sphere for the radial explosion.
  54496. */
  54497. radius: number;
  54498. /**
  54499. * The strenth of the explosion.
  54500. */
  54501. strength: number;
  54502. /**
  54503. * The strenght of the force in correspondence to the distance of the affected object
  54504. */
  54505. falloff: PhysicsRadialImpulseFalloff;
  54506. /**
  54507. * Sphere options for the radial explosion.
  54508. */
  54509. sphere: {
  54510. segments: number;
  54511. diameter: number;
  54512. };
  54513. /**
  54514. * Sphere options for the radial explosion.
  54515. */
  54516. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54517. }
  54518. /**
  54519. * Options fot the updraft event
  54520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54521. */
  54522. export class PhysicsUpdraftEventOptions {
  54523. /**
  54524. * The radius of the cylinder for the vortex
  54525. */
  54526. radius: number;
  54527. /**
  54528. * The strenth of the updraft.
  54529. */
  54530. strength: number;
  54531. /**
  54532. * The height of the cylinder for the updraft.
  54533. */
  54534. height: number;
  54535. /**
  54536. * The mode for the the updraft.
  54537. */
  54538. updraftMode: PhysicsUpdraftMode;
  54539. }
  54540. /**
  54541. * Options fot the vortex event
  54542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54543. */
  54544. export class PhysicsVortexEventOptions {
  54545. /**
  54546. * The radius of the cylinder for the vortex
  54547. */
  54548. radius: number;
  54549. /**
  54550. * The strenth of the vortex.
  54551. */
  54552. strength: number;
  54553. /**
  54554. * The height of the cylinder for the vortex.
  54555. */
  54556. height: number;
  54557. /**
  54558. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54559. */
  54560. centripetalForceThreshold: number;
  54561. /**
  54562. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54563. */
  54564. centripetalForceMultiplier: number;
  54565. /**
  54566. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54567. */
  54568. centrifugalForceMultiplier: number;
  54569. /**
  54570. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54571. */
  54572. updraftForceMultiplier: number;
  54573. }
  54574. /**
  54575. * The strenght of the force in correspondence to the distance of the affected object
  54576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54577. */
  54578. export enum PhysicsRadialImpulseFalloff {
  54579. /** Defines that impulse is constant in strength across it's whole radius */
  54580. Constant = 0,
  54581. /** Defines that impulse gets weaker if it's further from the origin */
  54582. Linear = 1
  54583. }
  54584. /**
  54585. * The strength of the force in correspondence to the distance of the affected object
  54586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54587. */
  54588. export enum PhysicsUpdraftMode {
  54589. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54590. Center = 0,
  54591. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54592. Perpendicular = 1
  54593. }
  54594. /**
  54595. * Interface for a physics hit data
  54596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54597. */
  54598. export interface PhysicsHitData {
  54599. /**
  54600. * The force applied at the contact point
  54601. */
  54602. force: Vector3;
  54603. /**
  54604. * The contact point
  54605. */
  54606. contactPoint: Vector3;
  54607. /**
  54608. * The distance from the origin to the contact point
  54609. */
  54610. distanceFromOrigin: number;
  54611. }
  54612. /**
  54613. * Interface for radial explosion event data
  54614. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54615. */
  54616. export interface PhysicsRadialExplosionEventData {
  54617. /**
  54618. * A sphere used for the radial explosion event
  54619. */
  54620. sphere: Mesh;
  54621. }
  54622. /**
  54623. * Interface for gravitational field event data
  54624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54625. */
  54626. export interface PhysicsGravitationalFieldEventData {
  54627. /**
  54628. * A sphere mesh used for the gravitational field event
  54629. */
  54630. sphere: Mesh;
  54631. }
  54632. /**
  54633. * Interface for updraft event data
  54634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54635. */
  54636. export interface PhysicsUpdraftEventData {
  54637. /**
  54638. * A cylinder used for the updraft event
  54639. */
  54640. cylinder: Mesh;
  54641. }
  54642. /**
  54643. * Interface for vortex event data
  54644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54645. */
  54646. export interface PhysicsVortexEventData {
  54647. /**
  54648. * A cylinder used for the vortex event
  54649. */
  54650. cylinder: Mesh;
  54651. }
  54652. /**
  54653. * Interface for an affected physics impostor
  54654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54655. */
  54656. export interface PhysicsAffectedImpostorWithData {
  54657. /**
  54658. * The impostor affected by the effect
  54659. */
  54660. impostor: PhysicsImpostor;
  54661. /**
  54662. * The data about the hit/horce from the explosion
  54663. */
  54664. hitData: PhysicsHitData;
  54665. }
  54666. }
  54667. declare module "babylonjs/Physics/Plugins/index" {
  54668. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54669. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54670. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54671. }
  54672. declare module "babylonjs/Physics/index" {
  54673. export * from "babylonjs/Physics/IPhysicsEngine";
  54674. export * from "babylonjs/Physics/physicsEngine";
  54675. export * from "babylonjs/Physics/physicsEngineComponent";
  54676. export * from "babylonjs/Physics/physicsHelper";
  54677. export * from "babylonjs/Physics/physicsImpostor";
  54678. export * from "babylonjs/Physics/physicsJoint";
  54679. export * from "babylonjs/Physics/Plugins/index";
  54680. }
  54681. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54682. /** @hidden */
  54683. export var blackAndWhitePixelShader: {
  54684. name: string;
  54685. shader: string;
  54686. };
  54687. }
  54688. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54689. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54690. import { Camera } from "babylonjs/Cameras/camera";
  54691. import { Engine } from "babylonjs/Engines/engine";
  54692. import "babylonjs/Shaders/blackAndWhite.fragment";
  54693. /**
  54694. * Post process used to render in black and white
  54695. */
  54696. export class BlackAndWhitePostProcess extends PostProcess {
  54697. /**
  54698. * Linear about to convert he result to black and white (default: 1)
  54699. */
  54700. degree: number;
  54701. /**
  54702. * Creates a black and white post process
  54703. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54704. * @param name The name of the effect.
  54705. * @param options The required width/height ratio to downsize to before computing the render pass.
  54706. * @param camera The camera to apply the render pass to.
  54707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54708. * @param engine The engine which the post process will be applied. (default: current engine)
  54709. * @param reusable If the post process can be reused on the same frame. (default: false)
  54710. */
  54711. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54712. }
  54713. }
  54714. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54715. import { Nullable } from "babylonjs/types";
  54716. import { Camera } from "babylonjs/Cameras/camera";
  54717. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54718. import { Engine } from "babylonjs/Engines/engine";
  54719. /**
  54720. * This represents a set of one or more post processes in Babylon.
  54721. * A post process can be used to apply a shader to a texture after it is rendered.
  54722. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54723. */
  54724. export class PostProcessRenderEffect {
  54725. private _postProcesses;
  54726. private _getPostProcesses;
  54727. private _singleInstance;
  54728. private _cameras;
  54729. private _indicesForCamera;
  54730. /**
  54731. * Name of the effect
  54732. * @hidden
  54733. */
  54734. _name: string;
  54735. /**
  54736. * Instantiates a post process render effect.
  54737. * A post process can be used to apply a shader to a texture after it is rendered.
  54738. * @param engine The engine the effect is tied to
  54739. * @param name The name of the effect
  54740. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54741. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54742. */
  54743. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54744. /**
  54745. * Checks if all the post processes in the effect are supported.
  54746. */
  54747. readonly isSupported: boolean;
  54748. /**
  54749. * Updates the current state of the effect
  54750. * @hidden
  54751. */
  54752. _update(): void;
  54753. /**
  54754. * Attaches the effect on cameras
  54755. * @param cameras The camera to attach to.
  54756. * @hidden
  54757. */
  54758. _attachCameras(cameras: Camera): void;
  54759. /**
  54760. * Attaches the effect on cameras
  54761. * @param cameras The camera to attach to.
  54762. * @hidden
  54763. */
  54764. _attachCameras(cameras: Camera[]): void;
  54765. /**
  54766. * Detaches the effect on cameras
  54767. * @param cameras The camera to detatch from.
  54768. * @hidden
  54769. */
  54770. _detachCameras(cameras: Camera): void;
  54771. /**
  54772. * Detatches the effect on cameras
  54773. * @param cameras The camera to detatch from.
  54774. * @hidden
  54775. */
  54776. _detachCameras(cameras: Camera[]): void;
  54777. /**
  54778. * Enables the effect on given cameras
  54779. * @param cameras The camera to enable.
  54780. * @hidden
  54781. */
  54782. _enable(cameras: Camera): void;
  54783. /**
  54784. * Enables the effect on given cameras
  54785. * @param cameras The camera to enable.
  54786. * @hidden
  54787. */
  54788. _enable(cameras: Nullable<Camera[]>): void;
  54789. /**
  54790. * Disables the effect on the given cameras
  54791. * @param cameras The camera to disable.
  54792. * @hidden
  54793. */
  54794. _disable(cameras: Camera): void;
  54795. /**
  54796. * Disables the effect on the given cameras
  54797. * @param cameras The camera to disable.
  54798. * @hidden
  54799. */
  54800. _disable(cameras: Nullable<Camera[]>): void;
  54801. /**
  54802. * Gets a list of the post processes contained in the effect.
  54803. * @param camera The camera to get the post processes on.
  54804. * @returns The list of the post processes in the effect.
  54805. */
  54806. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54807. }
  54808. }
  54809. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54810. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54811. /** @hidden */
  54812. export var extractHighlightsPixelShader: {
  54813. name: string;
  54814. shader: string;
  54815. };
  54816. }
  54817. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54818. import { Nullable } from "babylonjs/types";
  54819. import { Camera } from "babylonjs/Cameras/camera";
  54820. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54821. import { Engine } from "babylonjs/Engines/engine";
  54822. import "babylonjs/Shaders/extractHighlights.fragment";
  54823. /**
  54824. * 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.
  54825. */
  54826. export class ExtractHighlightsPostProcess extends PostProcess {
  54827. /**
  54828. * The luminance threshold, pixels below this value will be set to black.
  54829. */
  54830. threshold: number;
  54831. /** @hidden */
  54832. _exposure: number;
  54833. /**
  54834. * Post process which has the input texture to be used when performing highlight extraction
  54835. * @hidden
  54836. */
  54837. _inputPostProcess: Nullable<PostProcess>;
  54838. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54839. }
  54840. }
  54841. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54842. /** @hidden */
  54843. export var bloomMergePixelShader: {
  54844. name: string;
  54845. shader: string;
  54846. };
  54847. }
  54848. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54849. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54850. import { Nullable } from "babylonjs/types";
  54851. import { Engine } from "babylonjs/Engines/engine";
  54852. import { Camera } from "babylonjs/Cameras/camera";
  54853. import "babylonjs/Shaders/bloomMerge.fragment";
  54854. /**
  54855. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54856. */
  54857. export class BloomMergePostProcess extends PostProcess {
  54858. /** Weight of the bloom to be added to the original input. */
  54859. weight: number;
  54860. /**
  54861. * Creates a new instance of @see BloomMergePostProcess
  54862. * @param name The name of the effect.
  54863. * @param originalFromInput Post process which's input will be used for the merge.
  54864. * @param blurred Blurred highlights post process which's output will be used.
  54865. * @param weight Weight of the bloom to be added to the original input.
  54866. * @param options The required width/height ratio to downsize to before computing the render pass.
  54867. * @param camera The camera to apply the render pass to.
  54868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54869. * @param engine The engine which the post process will be applied. (default: current engine)
  54870. * @param reusable If the post process can be reused on the same frame. (default: false)
  54871. * @param textureType Type of textures used when performing the post process. (default: 0)
  54872. * @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)
  54873. */
  54874. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54875. /** Weight of the bloom to be added to the original input. */
  54876. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54877. }
  54878. }
  54879. declare module "babylonjs/PostProcesses/bloomEffect" {
  54880. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54881. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54882. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54883. import { Camera } from "babylonjs/Cameras/camera";
  54884. import { Scene } from "babylonjs/scene";
  54885. /**
  54886. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54887. */
  54888. export class BloomEffect extends PostProcessRenderEffect {
  54889. private bloomScale;
  54890. /**
  54891. * @hidden Internal
  54892. */
  54893. _effects: Array<PostProcess>;
  54894. /**
  54895. * @hidden Internal
  54896. */
  54897. _downscale: ExtractHighlightsPostProcess;
  54898. private _blurX;
  54899. private _blurY;
  54900. private _merge;
  54901. /**
  54902. * The luminance threshold to find bright areas of the image to bloom.
  54903. */
  54904. threshold: number;
  54905. /**
  54906. * The strength of the bloom.
  54907. */
  54908. weight: number;
  54909. /**
  54910. * Specifies the size of the bloom blur kernel, relative to the final output size
  54911. */
  54912. kernel: number;
  54913. /**
  54914. * Creates a new instance of @see BloomEffect
  54915. * @param scene The scene the effect belongs to.
  54916. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54917. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54918. * @param bloomWeight The the strength of bloom.
  54919. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54920. * @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)
  54921. */
  54922. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54923. /**
  54924. * Disposes each of the internal effects for a given camera.
  54925. * @param camera The camera to dispose the effect on.
  54926. */
  54927. disposeEffects(camera: Camera): void;
  54928. /**
  54929. * @hidden Internal
  54930. */
  54931. _updateEffects(): void;
  54932. /**
  54933. * Internal
  54934. * @returns if all the contained post processes are ready.
  54935. * @hidden
  54936. */
  54937. _isReady(): boolean;
  54938. }
  54939. }
  54940. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54941. /** @hidden */
  54942. export var chromaticAberrationPixelShader: {
  54943. name: string;
  54944. shader: string;
  54945. };
  54946. }
  54947. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54948. import { Vector2 } from "babylonjs/Maths/math";
  54949. import { Nullable } from "babylonjs/types";
  54950. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54951. import { Camera } from "babylonjs/Cameras/camera";
  54952. import { Engine } from "babylonjs/Engines/engine";
  54953. import "babylonjs/Shaders/chromaticAberration.fragment";
  54954. /**
  54955. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54956. */
  54957. export class ChromaticAberrationPostProcess extends PostProcess {
  54958. /**
  54959. * The amount of seperation of rgb channels (default: 30)
  54960. */
  54961. aberrationAmount: number;
  54962. /**
  54963. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54964. */
  54965. radialIntensity: number;
  54966. /**
  54967. * 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))
  54968. */
  54969. direction: Vector2;
  54970. /**
  54971. * 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))
  54972. */
  54973. centerPosition: Vector2;
  54974. /**
  54975. * Creates a new instance ChromaticAberrationPostProcess
  54976. * @param name The name of the effect.
  54977. * @param screenWidth The width of the screen to apply the effect on.
  54978. * @param screenHeight The height of the screen to apply the effect on.
  54979. * @param options The required width/height ratio to downsize to before computing the render pass.
  54980. * @param camera The camera to apply the render pass to.
  54981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54982. * @param engine The engine which the post process will be applied. (default: current engine)
  54983. * @param reusable If the post process can be reused on the same frame. (default: false)
  54984. * @param textureType Type of textures used when performing the post process. (default: 0)
  54985. * @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)
  54986. */
  54987. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54988. }
  54989. }
  54990. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54991. /** @hidden */
  54992. export var circleOfConfusionPixelShader: {
  54993. name: string;
  54994. shader: string;
  54995. };
  54996. }
  54997. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54998. import { Nullable } from "babylonjs/types";
  54999. import { Engine } from "babylonjs/Engines/engine";
  55000. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55001. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55002. import { Camera } from "babylonjs/Cameras/camera";
  55003. import "babylonjs/Shaders/circleOfConfusion.fragment";
  55004. /**
  55005. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55006. */
  55007. export class CircleOfConfusionPostProcess extends PostProcess {
  55008. /**
  55009. * 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.
  55010. */
  55011. lensSize: number;
  55012. /**
  55013. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55014. */
  55015. fStop: number;
  55016. /**
  55017. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55018. */
  55019. focusDistance: number;
  55020. /**
  55021. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55022. */
  55023. focalLength: number;
  55024. private _depthTexture;
  55025. /**
  55026. * Creates a new instance CircleOfConfusionPostProcess
  55027. * @param name The name of the effect.
  55028. * @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.
  55029. * @param options The required width/height ratio to downsize to before computing the render pass.
  55030. * @param camera The camera to apply the render pass to.
  55031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55032. * @param engine The engine which the post process will be applied. (default: current engine)
  55033. * @param reusable If the post process can be reused on the same frame. (default: false)
  55034. * @param textureType Type of textures used when performing the post process. (default: 0)
  55035. * @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)
  55036. */
  55037. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55038. /**
  55039. * 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.
  55040. */
  55041. depthTexture: RenderTargetTexture;
  55042. }
  55043. }
  55044. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  55045. /** @hidden */
  55046. export var colorCorrectionPixelShader: {
  55047. name: string;
  55048. shader: string;
  55049. };
  55050. }
  55051. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  55052. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55053. import { Engine } from "babylonjs/Engines/engine";
  55054. import { Camera } from "babylonjs/Cameras/camera";
  55055. import "babylonjs/Shaders/colorCorrection.fragment";
  55056. /**
  55057. *
  55058. * This post-process allows the modification of rendered colors by using
  55059. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55060. *
  55061. * The object needs to be provided an url to a texture containing the color
  55062. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55063. * Use an image editing software to tweak the LUT to match your needs.
  55064. *
  55065. * For an example of a color LUT, see here:
  55066. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55067. * For explanations on color grading, see here:
  55068. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55069. *
  55070. */
  55071. export class ColorCorrectionPostProcess extends PostProcess {
  55072. private _colorTableTexture;
  55073. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55074. }
  55075. }
  55076. declare module "babylonjs/Shaders/convolution.fragment" {
  55077. /** @hidden */
  55078. export var convolutionPixelShader: {
  55079. name: string;
  55080. shader: string;
  55081. };
  55082. }
  55083. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  55084. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55085. import { Nullable } from "babylonjs/types";
  55086. import { Camera } from "babylonjs/Cameras/camera";
  55087. import { Engine } from "babylonjs/Engines/engine";
  55088. import "babylonjs/Shaders/convolution.fragment";
  55089. /**
  55090. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55091. * input texture to perform effects such as edge detection or sharpening
  55092. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55093. */
  55094. export class ConvolutionPostProcess extends PostProcess {
  55095. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55096. kernel: number[];
  55097. /**
  55098. * Creates a new instance ConvolutionPostProcess
  55099. * @param name The name of the effect.
  55100. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  55101. * @param options The required width/height ratio to downsize to before computing the render pass.
  55102. * @param camera The camera to apply the render pass to.
  55103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55104. * @param engine The engine which the post process will be applied. (default: current engine)
  55105. * @param reusable If the post process can be reused on the same frame. (default: false)
  55106. * @param textureType Type of textures used when performing the post process. (default: 0)
  55107. */
  55108. constructor(name: string,
  55109. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55110. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55111. /**
  55112. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55113. */
  55114. static EdgeDetect0Kernel: number[];
  55115. /**
  55116. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55117. */
  55118. static EdgeDetect1Kernel: number[];
  55119. /**
  55120. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55121. */
  55122. static EdgeDetect2Kernel: number[];
  55123. /**
  55124. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55125. */
  55126. static SharpenKernel: number[];
  55127. /**
  55128. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55129. */
  55130. static EmbossKernel: number[];
  55131. /**
  55132. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55133. */
  55134. static GaussianKernel: number[];
  55135. }
  55136. }
  55137. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  55138. import { Nullable } from "babylonjs/types";
  55139. import { Vector2 } from "babylonjs/Maths/math";
  55140. import { Camera } from "babylonjs/Cameras/camera";
  55141. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55142. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55143. import { Engine } from "babylonjs/Engines/engine";
  55144. import { Scene } from "babylonjs/scene";
  55145. /**
  55146. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55147. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55148. * based on samples that have a large difference in distance than the center pixel.
  55149. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55150. */
  55151. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55152. direction: Vector2;
  55153. /**
  55154. * Creates a new instance CircleOfConfusionPostProcess
  55155. * @param name The name of the effect.
  55156. * @param scene The scene the effect belongs to.
  55157. * @param direction The direction the blur should be applied.
  55158. * @param kernel The size of the kernel used to blur.
  55159. * @param options The required width/height ratio to downsize to before computing the render pass.
  55160. * @param camera The camera to apply the render pass to.
  55161. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55162. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55164. * @param engine The engine which the post process will be applied. (default: current engine)
  55165. * @param reusable If the post process can be reused on the same frame. (default: false)
  55166. * @param textureType Type of textures used when performing the post process. (default: 0)
  55167. * @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)
  55168. */
  55169. 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);
  55170. }
  55171. }
  55172. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  55173. /** @hidden */
  55174. export var depthOfFieldMergePixelShader: {
  55175. name: string;
  55176. shader: string;
  55177. };
  55178. }
  55179. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  55180. import { Nullable } from "babylonjs/types";
  55181. import { Camera } from "babylonjs/Cameras/camera";
  55182. import { Effect } from "babylonjs/Materials/effect";
  55183. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55184. import { Engine } from "babylonjs/Engines/engine";
  55185. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  55186. /**
  55187. * Options to be set when merging outputs from the default pipeline.
  55188. */
  55189. export class DepthOfFieldMergePostProcessOptions {
  55190. /**
  55191. * The original image to merge on top of
  55192. */
  55193. originalFromInput: PostProcess;
  55194. /**
  55195. * Parameters to perform the merge of the depth of field effect
  55196. */
  55197. depthOfField?: {
  55198. circleOfConfusion: PostProcess;
  55199. blurSteps: Array<PostProcess>;
  55200. };
  55201. /**
  55202. * Parameters to perform the merge of bloom effect
  55203. */
  55204. bloom?: {
  55205. blurred: PostProcess;
  55206. weight: number;
  55207. };
  55208. }
  55209. /**
  55210. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55211. */
  55212. export class DepthOfFieldMergePostProcess extends PostProcess {
  55213. private blurSteps;
  55214. /**
  55215. * Creates a new instance of DepthOfFieldMergePostProcess
  55216. * @param name The name of the effect.
  55217. * @param originalFromInput Post process which's input will be used for the merge.
  55218. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55219. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55220. * @param options The required width/height ratio to downsize to before computing the render pass.
  55221. * @param camera The camera to apply the render pass to.
  55222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55223. * @param engine The engine which the post process will be applied. (default: current engine)
  55224. * @param reusable If the post process can be reused on the same frame. (default: false)
  55225. * @param textureType Type of textures used when performing the post process. (default: 0)
  55226. * @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)
  55227. */
  55228. 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);
  55229. /**
  55230. * Updates the effect with the current post process compile time values and recompiles the shader.
  55231. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55232. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55233. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55234. * @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
  55235. * @param onCompiled Called when the shader has been compiled.
  55236. * @param onError Called if there is an error when compiling a shader.
  55237. */
  55238. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55239. }
  55240. }
  55241. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  55242. import { Nullable } from "babylonjs/types";
  55243. import { Camera } from "babylonjs/Cameras/camera";
  55244. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55245. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55246. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55247. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55248. import { Scene } from "babylonjs/scene";
  55249. /**
  55250. * Specifies the level of max blur that should be applied when using the depth of field effect
  55251. */
  55252. export enum DepthOfFieldEffectBlurLevel {
  55253. /**
  55254. * Subtle blur
  55255. */
  55256. Low = 0,
  55257. /**
  55258. * Medium blur
  55259. */
  55260. Medium = 1,
  55261. /**
  55262. * Large blur
  55263. */
  55264. High = 2
  55265. }
  55266. /**
  55267. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55268. */
  55269. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55270. private _circleOfConfusion;
  55271. /**
  55272. * @hidden Internal, blurs from high to low
  55273. */
  55274. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55275. private _depthOfFieldBlurY;
  55276. private _dofMerge;
  55277. /**
  55278. * @hidden Internal post processes in depth of field effect
  55279. */
  55280. _effects: Array<PostProcess>;
  55281. /**
  55282. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55283. */
  55284. focalLength: number;
  55285. /**
  55286. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55287. */
  55288. fStop: number;
  55289. /**
  55290. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55291. */
  55292. focusDistance: number;
  55293. /**
  55294. * 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.
  55295. */
  55296. lensSize: number;
  55297. /**
  55298. * Creates a new instance DepthOfFieldEffect
  55299. * @param scene The scene the effect belongs to.
  55300. * @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.
  55301. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55302. * @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)
  55303. */
  55304. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55305. /**
  55306. * Get the current class name of the current effet
  55307. * @returns "DepthOfFieldEffect"
  55308. */
  55309. getClassName(): string;
  55310. /**
  55311. * 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.
  55312. */
  55313. depthTexture: RenderTargetTexture;
  55314. /**
  55315. * Disposes each of the internal effects for a given camera.
  55316. * @param camera The camera to dispose the effect on.
  55317. */
  55318. disposeEffects(camera: Camera): void;
  55319. /**
  55320. * @hidden Internal
  55321. */
  55322. _updateEffects(): void;
  55323. /**
  55324. * Internal
  55325. * @returns if all the contained post processes are ready.
  55326. * @hidden
  55327. */
  55328. _isReady(): boolean;
  55329. }
  55330. }
  55331. declare module "babylonjs/Shaders/displayPass.fragment" {
  55332. /** @hidden */
  55333. export var displayPassPixelShader: {
  55334. name: string;
  55335. shader: string;
  55336. };
  55337. }
  55338. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55339. import { Nullable } from "babylonjs/types";
  55340. import { Camera } from "babylonjs/Cameras/camera";
  55341. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55342. import { Engine } from "babylonjs/Engines/engine";
  55343. import "babylonjs/Shaders/displayPass.fragment";
  55344. /**
  55345. * DisplayPassPostProcess which produces an output the same as it's input
  55346. */
  55347. export class DisplayPassPostProcess extends PostProcess {
  55348. /**
  55349. * Creates the DisplayPassPostProcess
  55350. * @param name The name of the effect.
  55351. * @param options The required width/height ratio to downsize to before computing the render pass.
  55352. * @param camera The camera to apply the render pass to.
  55353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55354. * @param engine The engine which the post process will be applied. (default: current engine)
  55355. * @param reusable If the post process can be reused on the same frame. (default: false)
  55356. */
  55357. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55358. }
  55359. }
  55360. declare module "babylonjs/Shaders/filter.fragment" {
  55361. /** @hidden */
  55362. export var filterPixelShader: {
  55363. name: string;
  55364. shader: string;
  55365. };
  55366. }
  55367. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55368. import { Nullable } from "babylonjs/types";
  55369. import { Matrix } from "babylonjs/Maths/math";
  55370. import { Camera } from "babylonjs/Cameras/camera";
  55371. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55372. import { Engine } from "babylonjs/Engines/engine";
  55373. import "babylonjs/Shaders/filter.fragment";
  55374. /**
  55375. * Applies a kernel filter to the image
  55376. */
  55377. export class FilterPostProcess extends PostProcess {
  55378. /** The matrix to be applied to the image */
  55379. kernelMatrix: Matrix;
  55380. /**
  55381. *
  55382. * @param name The name of the effect.
  55383. * @param kernelMatrix The matrix to be applied to the image
  55384. * @param options The required width/height ratio to downsize to before computing the render pass.
  55385. * @param camera The camera to apply the render pass to.
  55386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55387. * @param engine The engine which the post process will be applied. (default: current engine)
  55388. * @param reusable If the post process can be reused on the same frame. (default: false)
  55389. */
  55390. constructor(name: string,
  55391. /** The matrix to be applied to the image */
  55392. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55393. }
  55394. }
  55395. declare module "babylonjs/Shaders/fxaa.fragment" {
  55396. /** @hidden */
  55397. export var fxaaPixelShader: {
  55398. name: string;
  55399. shader: string;
  55400. };
  55401. }
  55402. declare module "babylonjs/Shaders/fxaa.vertex" {
  55403. /** @hidden */
  55404. export var fxaaVertexShader: {
  55405. name: string;
  55406. shader: string;
  55407. };
  55408. }
  55409. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55410. import { Nullable } from "babylonjs/types";
  55411. import { Camera } from "babylonjs/Cameras/camera";
  55412. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55413. import { Engine } from "babylonjs/Engines/engine";
  55414. import "babylonjs/Shaders/fxaa.fragment";
  55415. import "babylonjs/Shaders/fxaa.vertex";
  55416. /**
  55417. * Fxaa post process
  55418. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55419. */
  55420. export class FxaaPostProcess extends PostProcess {
  55421. /** @hidden */
  55422. texelWidth: number;
  55423. /** @hidden */
  55424. texelHeight: number;
  55425. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55426. private _getDefines;
  55427. }
  55428. }
  55429. declare module "babylonjs/Shaders/grain.fragment" {
  55430. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55431. /** @hidden */
  55432. export var grainPixelShader: {
  55433. name: string;
  55434. shader: string;
  55435. };
  55436. }
  55437. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55438. import { Nullable } from "babylonjs/types";
  55439. import { Camera } from "babylonjs/Cameras/camera";
  55440. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55441. import { Engine } from "babylonjs/Engines/engine";
  55442. import "babylonjs/Shaders/grain.fragment";
  55443. /**
  55444. * The GrainPostProcess adds noise to the image at mid luminance levels
  55445. */
  55446. export class GrainPostProcess extends PostProcess {
  55447. /**
  55448. * The intensity of the grain added (default: 30)
  55449. */
  55450. intensity: number;
  55451. /**
  55452. * If the grain should be randomized on every frame
  55453. */
  55454. animated: boolean;
  55455. /**
  55456. * Creates a new instance of @see GrainPostProcess
  55457. * @param name The name of the effect.
  55458. * @param options The required width/height ratio to downsize to before computing the render pass.
  55459. * @param camera The camera to apply the render pass to.
  55460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55461. * @param engine The engine which the post process will be applied. (default: current engine)
  55462. * @param reusable If the post process can be reused on the same frame. (default: false)
  55463. * @param textureType Type of textures used when performing the post process. (default: 0)
  55464. * @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)
  55465. */
  55466. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55467. }
  55468. }
  55469. declare module "babylonjs/Shaders/highlights.fragment" {
  55470. /** @hidden */
  55471. export var highlightsPixelShader: {
  55472. name: string;
  55473. shader: string;
  55474. };
  55475. }
  55476. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55477. import { Nullable } from "babylonjs/types";
  55478. import { Camera } from "babylonjs/Cameras/camera";
  55479. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55480. import { Engine } from "babylonjs/Engines/engine";
  55481. import "babylonjs/Shaders/highlights.fragment";
  55482. /**
  55483. * Extracts highlights from the image
  55484. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55485. */
  55486. export class HighlightsPostProcess extends PostProcess {
  55487. /**
  55488. * Extracts highlights from the image
  55489. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55490. * @param name The name of the effect.
  55491. * @param options The required width/height ratio to downsize to before computing the render pass.
  55492. * @param camera The camera to apply the render pass to.
  55493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55494. * @param engine The engine which the post process will be applied. (default: current engine)
  55495. * @param reusable If the post process can be reused on the same frame. (default: false)
  55496. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55497. */
  55498. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55499. }
  55500. }
  55501. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55502. /** @hidden */
  55503. export var mrtFragmentDeclaration: {
  55504. name: string;
  55505. shader: string;
  55506. };
  55507. }
  55508. declare module "babylonjs/Shaders/geometry.fragment" {
  55509. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55510. /** @hidden */
  55511. export var geometryPixelShader: {
  55512. name: string;
  55513. shader: string;
  55514. };
  55515. }
  55516. declare module "babylonjs/Shaders/geometry.vertex" {
  55517. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55518. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55519. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55520. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55521. /** @hidden */
  55522. export var geometryVertexShader: {
  55523. name: string;
  55524. shader: string;
  55525. };
  55526. }
  55527. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55528. import { Matrix } from "babylonjs/Maths/math";
  55529. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55530. import { Mesh } from "babylonjs/Meshes/mesh";
  55531. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55532. import { Effect } from "babylonjs/Materials/effect";
  55533. import { Scene } from "babylonjs/scene";
  55534. import "babylonjs/Shaders/geometry.fragment";
  55535. import "babylonjs/Shaders/geometry.vertex";
  55536. /**
  55537. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55538. */
  55539. export class GeometryBufferRenderer {
  55540. /**
  55541. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55542. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55543. */
  55544. static readonly POSITION_TEXTURE_TYPE: number;
  55545. /**
  55546. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55547. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55548. */
  55549. static readonly VELOCITY_TEXTURE_TYPE: number;
  55550. /**
  55551. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55552. * in order to compute objects velocities when enableVelocity is set to "true"
  55553. * @hidden
  55554. */
  55555. _previousTransformationMatrices: {
  55556. [index: number]: Matrix;
  55557. };
  55558. private _scene;
  55559. private _multiRenderTarget;
  55560. private _ratio;
  55561. private _enablePosition;
  55562. private _enableVelocity;
  55563. private _positionIndex;
  55564. private _velocityIndex;
  55565. protected _effect: Effect;
  55566. protected _cachedDefines: string;
  55567. /**
  55568. * Set the render list (meshes to be rendered) used in the G buffer.
  55569. */
  55570. renderList: Mesh[];
  55571. /**
  55572. * Gets wether or not G buffer are supported by the running hardware.
  55573. * This requires draw buffer supports
  55574. */
  55575. readonly isSupported: boolean;
  55576. /**
  55577. * Returns the index of the given texture type in the G-Buffer textures array
  55578. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55579. * @returns the index of the given texture type in the G-Buffer textures array
  55580. */
  55581. getTextureIndex(textureType: number): number;
  55582. /**
  55583. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55584. */
  55585. /**
  55586. * Sets whether or not objects positions are enabled for the G buffer.
  55587. */
  55588. enablePosition: boolean;
  55589. /**
  55590. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55591. */
  55592. /**
  55593. * Sets wether or not objects velocities are enabled for the G buffer.
  55594. */
  55595. enableVelocity: boolean;
  55596. /**
  55597. * Gets the scene associated with the buffer.
  55598. */
  55599. readonly scene: Scene;
  55600. /**
  55601. * Gets the ratio used by the buffer during its creation.
  55602. * How big is the buffer related to the main canvas.
  55603. */
  55604. readonly ratio: number;
  55605. /** @hidden */
  55606. static _SceneComponentInitialization: (scene: Scene) => void;
  55607. /**
  55608. * Creates a new G Buffer for the scene
  55609. * @param scene The scene the buffer belongs to
  55610. * @param ratio How big is the buffer related to the main canvas.
  55611. */
  55612. constructor(scene: Scene, ratio?: number);
  55613. /**
  55614. * Checks wether everything is ready to render a submesh to the G buffer.
  55615. * @param subMesh the submesh to check readiness for
  55616. * @param useInstances is the mesh drawn using instance or not
  55617. * @returns true if ready otherwise false
  55618. */
  55619. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55620. /**
  55621. * Gets the current underlying G Buffer.
  55622. * @returns the buffer
  55623. */
  55624. getGBuffer(): MultiRenderTarget;
  55625. /**
  55626. * Gets the number of samples used to render the buffer (anti aliasing).
  55627. */
  55628. /**
  55629. * Sets the number of samples used to render the buffer (anti aliasing).
  55630. */
  55631. samples: number;
  55632. /**
  55633. * Disposes the renderer and frees up associated resources.
  55634. */
  55635. dispose(): void;
  55636. protected _createRenderTargets(): void;
  55637. }
  55638. }
  55639. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55640. import { Nullable } from "babylonjs/types";
  55641. import { Scene } from "babylonjs/scene";
  55642. import { ISceneComponent } from "babylonjs/sceneComponent";
  55643. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55644. module "babylonjs/scene" {
  55645. interface Scene {
  55646. /** @hidden (Backing field) */
  55647. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55648. /**
  55649. * Gets or Sets the current geometry buffer associated to the scene.
  55650. */
  55651. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55652. /**
  55653. * Enables a GeometryBufferRender and associates it with the scene
  55654. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55655. * @returns the GeometryBufferRenderer
  55656. */
  55657. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55658. /**
  55659. * Disables the GeometryBufferRender associated with the scene
  55660. */
  55661. disableGeometryBufferRenderer(): void;
  55662. }
  55663. }
  55664. /**
  55665. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55666. * in several rendering techniques.
  55667. */
  55668. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55669. /**
  55670. * The component name helpful to identify the component in the list of scene components.
  55671. */
  55672. readonly name: string;
  55673. /**
  55674. * The scene the component belongs to.
  55675. */
  55676. scene: Scene;
  55677. /**
  55678. * Creates a new instance of the component for the given scene
  55679. * @param scene Defines the scene to register the component in
  55680. */
  55681. constructor(scene: Scene);
  55682. /**
  55683. * Registers the component in a given scene
  55684. */
  55685. register(): void;
  55686. /**
  55687. * Rebuilds the elements related to this component in case of
  55688. * context lost for instance.
  55689. */
  55690. rebuild(): void;
  55691. /**
  55692. * Disposes the component and the associated ressources
  55693. */
  55694. dispose(): void;
  55695. private _gatherRenderTargets;
  55696. }
  55697. }
  55698. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55699. /** @hidden */
  55700. export var motionBlurPixelShader: {
  55701. name: string;
  55702. shader: string;
  55703. };
  55704. }
  55705. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55706. import { Nullable } from "babylonjs/types";
  55707. import { Camera } from "babylonjs/Cameras/camera";
  55708. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55709. import { Scene } from "babylonjs/scene";
  55710. import "babylonjs/Animations/animatable";
  55711. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55712. import "babylonjs/Shaders/motionBlur.fragment";
  55713. import { Engine } from "babylonjs/Engines/engine";
  55714. /**
  55715. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55716. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55717. * As an example, all you have to do is to create the post-process:
  55718. * var mb = new BABYLON.MotionBlurPostProcess(
  55719. * 'mb', // The name of the effect.
  55720. * scene, // The scene containing the objects to blur according to their velocity.
  55721. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55722. * camera // The camera to apply the render pass to.
  55723. * );
  55724. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55725. */
  55726. export class MotionBlurPostProcess extends PostProcess {
  55727. /**
  55728. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55729. */
  55730. motionStrength: number;
  55731. /**
  55732. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55733. */
  55734. /**
  55735. * Sets the number of iterations to be used for motion blur quality
  55736. */
  55737. motionBlurSamples: number;
  55738. private _motionBlurSamples;
  55739. private _geometryBufferRenderer;
  55740. /**
  55741. * Creates a new instance MotionBlurPostProcess
  55742. * @param name The name of the effect.
  55743. * @param scene The scene containing the objects to blur according to their velocity.
  55744. * @param options The required width/height ratio to downsize to before computing the render pass.
  55745. * @param camera The camera to apply the render pass to.
  55746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55747. * @param engine The engine which the post process will be applied. (default: current engine)
  55748. * @param reusable If the post process can be reused on the same frame. (default: false)
  55749. * @param textureType Type of textures used when performing the post process. (default: 0)
  55750. * @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)
  55751. */
  55752. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55753. /**
  55754. * Disposes the post process.
  55755. * @param camera The camera to dispose the post process on.
  55756. */
  55757. dispose(camera?: Camera): void;
  55758. }
  55759. }
  55760. declare module "babylonjs/Shaders/refraction.fragment" {
  55761. /** @hidden */
  55762. export var refractionPixelShader: {
  55763. name: string;
  55764. shader: string;
  55765. };
  55766. }
  55767. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55768. import { Color3 } from "babylonjs/Maths/math";
  55769. import { Camera } from "babylonjs/Cameras/camera";
  55770. import { Texture } from "babylonjs/Materials/Textures/texture";
  55771. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55772. import { Engine } from "babylonjs/Engines/engine";
  55773. import "babylonjs/Shaders/refraction.fragment";
  55774. /**
  55775. * Post process which applies a refractin texture
  55776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55777. */
  55778. export class RefractionPostProcess extends PostProcess {
  55779. /** the base color of the refraction (used to taint the rendering) */
  55780. color: Color3;
  55781. /** simulated refraction depth */
  55782. depth: number;
  55783. /** the coefficient of the base color (0 to remove base color tainting) */
  55784. colorLevel: number;
  55785. private _refTexture;
  55786. private _ownRefractionTexture;
  55787. /**
  55788. * Gets or sets the refraction texture
  55789. * Please note that you are responsible for disposing the texture if you set it manually
  55790. */
  55791. refractionTexture: Texture;
  55792. /**
  55793. * Initializes the RefractionPostProcess
  55794. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55795. * @param name The name of the effect.
  55796. * @param refractionTextureUrl Url of the refraction texture to use
  55797. * @param color the base color of the refraction (used to taint the rendering)
  55798. * @param depth simulated refraction depth
  55799. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55800. * @param camera The camera to apply the render pass to.
  55801. * @param options The required width/height ratio to downsize to before computing the render pass.
  55802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55803. * @param engine The engine which the post process will be applied. (default: current engine)
  55804. * @param reusable If the post process can be reused on the same frame. (default: false)
  55805. */
  55806. constructor(name: string, refractionTextureUrl: string,
  55807. /** the base color of the refraction (used to taint the rendering) */
  55808. color: Color3,
  55809. /** simulated refraction depth */
  55810. depth: number,
  55811. /** the coefficient of the base color (0 to remove base color tainting) */
  55812. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55813. /**
  55814. * Disposes of the post process
  55815. * @param camera Camera to dispose post process on
  55816. */
  55817. dispose(camera: Camera): void;
  55818. }
  55819. }
  55820. declare module "babylonjs/Shaders/sharpen.fragment" {
  55821. /** @hidden */
  55822. export var sharpenPixelShader: {
  55823. name: string;
  55824. shader: string;
  55825. };
  55826. }
  55827. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55828. import { Nullable } from "babylonjs/types";
  55829. import { Camera } from "babylonjs/Cameras/camera";
  55830. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55831. import "babylonjs/Shaders/sharpen.fragment";
  55832. import { Engine } from "babylonjs/Engines/engine";
  55833. /**
  55834. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55835. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55836. */
  55837. export class SharpenPostProcess extends PostProcess {
  55838. /**
  55839. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55840. */
  55841. colorAmount: number;
  55842. /**
  55843. * How much sharpness should be applied (default: 0.3)
  55844. */
  55845. edgeAmount: number;
  55846. /**
  55847. * Creates a new instance ConvolutionPostProcess
  55848. * @param name The name of the effect.
  55849. * @param options The required width/height ratio to downsize to before computing the render pass.
  55850. * @param camera The camera to apply the render pass to.
  55851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55852. * @param engine The engine which the post process will be applied. (default: current engine)
  55853. * @param reusable If the post process can be reused on the same frame. (default: false)
  55854. * @param textureType Type of textures used when performing the post process. (default: 0)
  55855. * @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)
  55856. */
  55857. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55858. }
  55859. }
  55860. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55861. import { Nullable } from "babylonjs/types";
  55862. import { Camera } from "babylonjs/Cameras/camera";
  55863. import { Engine } from "babylonjs/Engines/engine";
  55864. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55865. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55866. /**
  55867. * PostProcessRenderPipeline
  55868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55869. */
  55870. export class PostProcessRenderPipeline {
  55871. private engine;
  55872. private _renderEffects;
  55873. private _renderEffectsForIsolatedPass;
  55874. /**
  55875. * List of inspectable custom properties (used by the Inspector)
  55876. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55877. */
  55878. inspectableCustomProperties: IInspectable[];
  55879. /**
  55880. * @hidden
  55881. */
  55882. protected _cameras: Camera[];
  55883. /** @hidden */
  55884. _name: string;
  55885. /**
  55886. * Gets pipeline name
  55887. */
  55888. readonly name: string;
  55889. /**
  55890. * Initializes a PostProcessRenderPipeline
  55891. * @param engine engine to add the pipeline to
  55892. * @param name name of the pipeline
  55893. */
  55894. constructor(engine: Engine, name: string);
  55895. /**
  55896. * Gets the class name
  55897. * @returns "PostProcessRenderPipeline"
  55898. */
  55899. getClassName(): string;
  55900. /**
  55901. * If all the render effects in the pipeline are supported
  55902. */
  55903. readonly isSupported: boolean;
  55904. /**
  55905. * Adds an effect to the pipeline
  55906. * @param renderEffect the effect to add
  55907. */
  55908. addEffect(renderEffect: PostProcessRenderEffect): void;
  55909. /** @hidden */
  55910. _rebuild(): void;
  55911. /** @hidden */
  55912. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55913. /** @hidden */
  55914. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55915. /** @hidden */
  55916. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55917. /** @hidden */
  55918. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55919. /** @hidden */
  55920. _attachCameras(cameras: Camera, unique: boolean): void;
  55921. /** @hidden */
  55922. _attachCameras(cameras: Camera[], unique: boolean): void;
  55923. /** @hidden */
  55924. _detachCameras(cameras: Camera): void;
  55925. /** @hidden */
  55926. _detachCameras(cameras: Nullable<Camera[]>): void;
  55927. /** @hidden */
  55928. _update(): void;
  55929. /** @hidden */
  55930. _reset(): void;
  55931. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55932. /**
  55933. * Disposes of the pipeline
  55934. */
  55935. dispose(): void;
  55936. }
  55937. }
  55938. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55939. import { Camera } from "babylonjs/Cameras/camera";
  55940. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55941. /**
  55942. * PostProcessRenderPipelineManager class
  55943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55944. */
  55945. export class PostProcessRenderPipelineManager {
  55946. private _renderPipelines;
  55947. /**
  55948. * Initializes a PostProcessRenderPipelineManager
  55949. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55950. */
  55951. constructor();
  55952. /**
  55953. * Gets the list of supported render pipelines
  55954. */
  55955. readonly supportedPipelines: PostProcessRenderPipeline[];
  55956. /**
  55957. * Adds a pipeline to the manager
  55958. * @param renderPipeline The pipeline to add
  55959. */
  55960. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55961. /**
  55962. * Attaches a camera to the pipeline
  55963. * @param renderPipelineName The name of the pipeline to attach to
  55964. * @param cameras the camera to attach
  55965. * @param unique if the camera can be attached multiple times to the pipeline
  55966. */
  55967. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55968. /**
  55969. * Detaches a camera from the pipeline
  55970. * @param renderPipelineName The name of the pipeline to detach from
  55971. * @param cameras the camera to detach
  55972. */
  55973. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55974. /**
  55975. * Enables an effect by name on a pipeline
  55976. * @param renderPipelineName the name of the pipeline to enable the effect in
  55977. * @param renderEffectName the name of the effect to enable
  55978. * @param cameras the cameras that the effect should be enabled on
  55979. */
  55980. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55981. /**
  55982. * Disables an effect by name on a pipeline
  55983. * @param renderPipelineName the name of the pipeline to disable the effect in
  55984. * @param renderEffectName the name of the effect to disable
  55985. * @param cameras the cameras that the effect should be disabled on
  55986. */
  55987. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55988. /**
  55989. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55990. */
  55991. update(): void;
  55992. /** @hidden */
  55993. _rebuild(): void;
  55994. /**
  55995. * Disposes of the manager and pipelines
  55996. */
  55997. dispose(): void;
  55998. }
  55999. }
  56000. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  56001. import { ISceneComponent } from "babylonjs/sceneComponent";
  56002. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56003. import { Scene } from "babylonjs/scene";
  56004. module "babylonjs/scene" {
  56005. interface Scene {
  56006. /** @hidden (Backing field) */
  56007. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56008. /**
  56009. * Gets the postprocess render pipeline manager
  56010. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56011. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56012. */
  56013. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56014. }
  56015. }
  56016. /**
  56017. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56018. */
  56019. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56020. /**
  56021. * The component name helpfull to identify the component in the list of scene components.
  56022. */
  56023. readonly name: string;
  56024. /**
  56025. * The scene the component belongs to.
  56026. */
  56027. scene: Scene;
  56028. /**
  56029. * Creates a new instance of the component for the given scene
  56030. * @param scene Defines the scene to register the component in
  56031. */
  56032. constructor(scene: Scene);
  56033. /**
  56034. * Registers the component in a given scene
  56035. */
  56036. register(): void;
  56037. /**
  56038. * Rebuilds the elements related to this component in case of
  56039. * context lost for instance.
  56040. */
  56041. rebuild(): void;
  56042. /**
  56043. * Disposes the component and the associated ressources
  56044. */
  56045. dispose(): void;
  56046. private _gatherRenderTargets;
  56047. }
  56048. }
  56049. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  56050. import { Nullable } from "babylonjs/types";
  56051. import { IAnimatable } from "babylonjs/Misc/tools";
  56052. import { Camera } from "babylonjs/Cameras/camera";
  56053. import { IDisposable } from "babylonjs/scene";
  56054. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  56055. import { Scene } from "babylonjs/scene";
  56056. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  56057. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56058. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56059. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  56060. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56061. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56062. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  56063. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56064. import { Animation } from "babylonjs/Animations/animation";
  56065. /**
  56066. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56067. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56068. */
  56069. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56070. private _scene;
  56071. private _camerasToBeAttached;
  56072. /**
  56073. * ID of the sharpen post process,
  56074. */
  56075. private readonly SharpenPostProcessId;
  56076. /**
  56077. * @ignore
  56078. * ID of the image processing post process;
  56079. */
  56080. readonly ImageProcessingPostProcessId: string;
  56081. /**
  56082. * @ignore
  56083. * ID of the Fast Approximate Anti-Aliasing post process;
  56084. */
  56085. readonly FxaaPostProcessId: string;
  56086. /**
  56087. * ID of the chromatic aberration post process,
  56088. */
  56089. private readonly ChromaticAberrationPostProcessId;
  56090. /**
  56091. * ID of the grain post process
  56092. */
  56093. private readonly GrainPostProcessId;
  56094. /**
  56095. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56096. */
  56097. sharpen: SharpenPostProcess;
  56098. private _sharpenEffect;
  56099. private bloom;
  56100. /**
  56101. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56102. */
  56103. depthOfField: DepthOfFieldEffect;
  56104. /**
  56105. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56106. */
  56107. fxaa: FxaaPostProcess;
  56108. /**
  56109. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56110. */
  56111. imageProcessing: ImageProcessingPostProcess;
  56112. /**
  56113. * Chromatic aberration post process which will shift rgb colors in the image
  56114. */
  56115. chromaticAberration: ChromaticAberrationPostProcess;
  56116. private _chromaticAberrationEffect;
  56117. /**
  56118. * Grain post process which add noise to the image
  56119. */
  56120. grain: GrainPostProcess;
  56121. private _grainEffect;
  56122. /**
  56123. * Glow post process which adds a glow to emissive areas of the image
  56124. */
  56125. private _glowLayer;
  56126. /**
  56127. * Animations which can be used to tweak settings over a period of time
  56128. */
  56129. animations: Animation[];
  56130. private _imageProcessingConfigurationObserver;
  56131. private _sharpenEnabled;
  56132. private _bloomEnabled;
  56133. private _depthOfFieldEnabled;
  56134. private _depthOfFieldBlurLevel;
  56135. private _fxaaEnabled;
  56136. private _imageProcessingEnabled;
  56137. private _defaultPipelineTextureType;
  56138. private _bloomScale;
  56139. private _chromaticAberrationEnabled;
  56140. private _grainEnabled;
  56141. private _buildAllowed;
  56142. /**
  56143. * Gets active scene
  56144. */
  56145. readonly scene: Scene;
  56146. /**
  56147. * Enable or disable the sharpen process from the pipeline
  56148. */
  56149. sharpenEnabled: boolean;
  56150. private _resizeObserver;
  56151. private _hardwareScaleLevel;
  56152. private _bloomKernel;
  56153. /**
  56154. * Specifies the size of the bloom blur kernel, relative to the final output size
  56155. */
  56156. bloomKernel: number;
  56157. /**
  56158. * Specifies the weight of the bloom in the final rendering
  56159. */
  56160. private _bloomWeight;
  56161. /**
  56162. * Specifies the luma threshold for the area that will be blurred by the bloom
  56163. */
  56164. private _bloomThreshold;
  56165. private _hdr;
  56166. /**
  56167. * The strength of the bloom.
  56168. */
  56169. bloomWeight: number;
  56170. /**
  56171. * The strength of the bloom.
  56172. */
  56173. bloomThreshold: number;
  56174. /**
  56175. * The scale of the bloom, lower value will provide better performance.
  56176. */
  56177. bloomScale: number;
  56178. /**
  56179. * Enable or disable the bloom from the pipeline
  56180. */
  56181. bloomEnabled: boolean;
  56182. private _rebuildBloom;
  56183. /**
  56184. * If the depth of field is enabled.
  56185. */
  56186. depthOfFieldEnabled: boolean;
  56187. /**
  56188. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56189. */
  56190. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56191. /**
  56192. * If the anti aliasing is enabled.
  56193. */
  56194. fxaaEnabled: boolean;
  56195. private _samples;
  56196. /**
  56197. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56198. */
  56199. samples: number;
  56200. /**
  56201. * If image processing is enabled.
  56202. */
  56203. imageProcessingEnabled: boolean;
  56204. /**
  56205. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56206. */
  56207. glowLayerEnabled: boolean;
  56208. /**
  56209. * Gets the glow layer (or null if not defined)
  56210. */
  56211. readonly glowLayer: Nullable<GlowLayer>;
  56212. /**
  56213. * Enable or disable the chromaticAberration process from the pipeline
  56214. */
  56215. chromaticAberrationEnabled: boolean;
  56216. /**
  56217. * Enable or disable the grain process from the pipeline
  56218. */
  56219. grainEnabled: boolean;
  56220. /**
  56221. * @constructor
  56222. * @param name - The rendering pipeline name (default: "")
  56223. * @param hdr - If high dynamic range textures should be used (default: true)
  56224. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56225. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56226. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56227. */
  56228. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56229. /**
  56230. * Get the class name
  56231. * @returns "DefaultRenderingPipeline"
  56232. */
  56233. getClassName(): string;
  56234. /**
  56235. * Force the compilation of the entire pipeline.
  56236. */
  56237. prepare(): void;
  56238. private _hasCleared;
  56239. private _prevPostProcess;
  56240. private _prevPrevPostProcess;
  56241. private _setAutoClearAndTextureSharing;
  56242. private _depthOfFieldSceneObserver;
  56243. private _buildPipeline;
  56244. private _disposePostProcesses;
  56245. /**
  56246. * Adds a camera to the pipeline
  56247. * @param camera the camera to be added
  56248. */
  56249. addCamera(camera: Camera): void;
  56250. /**
  56251. * Removes a camera from the pipeline
  56252. * @param camera the camera to remove
  56253. */
  56254. removeCamera(camera: Camera): void;
  56255. /**
  56256. * Dispose of the pipeline and stop all post processes
  56257. */
  56258. dispose(): void;
  56259. /**
  56260. * Serialize the rendering pipeline (Used when exporting)
  56261. * @returns the serialized object
  56262. */
  56263. serialize(): any;
  56264. /**
  56265. * Parse the serialized pipeline
  56266. * @param source Source pipeline.
  56267. * @param scene The scene to load the pipeline to.
  56268. * @param rootUrl The URL of the serialized pipeline.
  56269. * @returns An instantiated pipeline from the serialized object.
  56270. */
  56271. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56272. }
  56273. }
  56274. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  56275. /** @hidden */
  56276. export var lensHighlightsPixelShader: {
  56277. name: string;
  56278. shader: string;
  56279. };
  56280. }
  56281. declare module "babylonjs/Shaders/depthOfField.fragment" {
  56282. /** @hidden */
  56283. export var depthOfFieldPixelShader: {
  56284. name: string;
  56285. shader: string;
  56286. };
  56287. }
  56288. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  56289. import { Camera } from "babylonjs/Cameras/camera";
  56290. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56291. import { Scene } from "babylonjs/scene";
  56292. import "babylonjs/Shaders/chromaticAberration.fragment";
  56293. import "babylonjs/Shaders/lensHighlights.fragment";
  56294. import "babylonjs/Shaders/depthOfField.fragment";
  56295. /**
  56296. * BABYLON.JS Chromatic Aberration GLSL Shader
  56297. * Author: Olivier Guyot
  56298. * Separates very slightly R, G and B colors on the edges of the screen
  56299. * Inspired by Francois Tarlier & Martins Upitis
  56300. */
  56301. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56302. /**
  56303. * @ignore
  56304. * The chromatic aberration PostProcess id in the pipeline
  56305. */
  56306. LensChromaticAberrationEffect: string;
  56307. /**
  56308. * @ignore
  56309. * The highlights enhancing PostProcess id in the pipeline
  56310. */
  56311. HighlightsEnhancingEffect: string;
  56312. /**
  56313. * @ignore
  56314. * The depth-of-field PostProcess id in the pipeline
  56315. */
  56316. LensDepthOfFieldEffect: string;
  56317. private _scene;
  56318. private _depthTexture;
  56319. private _grainTexture;
  56320. private _chromaticAberrationPostProcess;
  56321. private _highlightsPostProcess;
  56322. private _depthOfFieldPostProcess;
  56323. private _edgeBlur;
  56324. private _grainAmount;
  56325. private _chromaticAberration;
  56326. private _distortion;
  56327. private _highlightsGain;
  56328. private _highlightsThreshold;
  56329. private _dofDistance;
  56330. private _dofAperture;
  56331. private _dofDarken;
  56332. private _dofPentagon;
  56333. private _blurNoise;
  56334. /**
  56335. * @constructor
  56336. *
  56337. * Effect parameters are as follow:
  56338. * {
  56339. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56340. * edge_blur: number; // from 0 to x (1 for realism)
  56341. * distortion: number; // from 0 to x (1 for realism)
  56342. * grain_amount: number; // from 0 to 1
  56343. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56344. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56345. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56346. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56347. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56348. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56349. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56350. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56351. * }
  56352. * Note: if an effect parameter is unset, effect is disabled
  56353. *
  56354. * @param name The rendering pipeline name
  56355. * @param parameters - An object containing all parameters (see above)
  56356. * @param scene The scene linked to this pipeline
  56357. * @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)
  56358. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56359. */
  56360. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56361. /**
  56362. * Get the class name
  56363. * @returns "LensRenderingPipeline"
  56364. */
  56365. getClassName(): string;
  56366. /**
  56367. * Gets associated scene
  56368. */
  56369. readonly scene: Scene;
  56370. /**
  56371. * Gets or sets the edge blur
  56372. */
  56373. edgeBlur: number;
  56374. /**
  56375. * Gets or sets the grain amount
  56376. */
  56377. grainAmount: number;
  56378. /**
  56379. * Gets or sets the chromatic aberration amount
  56380. */
  56381. chromaticAberration: number;
  56382. /**
  56383. * Gets or sets the depth of field aperture
  56384. */
  56385. dofAperture: number;
  56386. /**
  56387. * Gets or sets the edge distortion
  56388. */
  56389. edgeDistortion: number;
  56390. /**
  56391. * Gets or sets the depth of field distortion
  56392. */
  56393. dofDistortion: number;
  56394. /**
  56395. * Gets or sets the darken out of focus amount
  56396. */
  56397. darkenOutOfFocus: number;
  56398. /**
  56399. * Gets or sets a boolean indicating if blur noise is enabled
  56400. */
  56401. blurNoise: boolean;
  56402. /**
  56403. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56404. */
  56405. pentagonBokeh: boolean;
  56406. /**
  56407. * Gets or sets the highlight grain amount
  56408. */
  56409. highlightsGain: number;
  56410. /**
  56411. * Gets or sets the highlight threshold
  56412. */
  56413. highlightsThreshold: number;
  56414. /**
  56415. * Sets the amount of blur at the edges
  56416. * @param amount blur amount
  56417. */
  56418. setEdgeBlur(amount: number): void;
  56419. /**
  56420. * Sets edge blur to 0
  56421. */
  56422. disableEdgeBlur(): void;
  56423. /**
  56424. * Sets the amout of grain
  56425. * @param amount Amount of grain
  56426. */
  56427. setGrainAmount(amount: number): void;
  56428. /**
  56429. * Set grain amount to 0
  56430. */
  56431. disableGrain(): void;
  56432. /**
  56433. * Sets the chromatic aberration amount
  56434. * @param amount amount of chromatic aberration
  56435. */
  56436. setChromaticAberration(amount: number): void;
  56437. /**
  56438. * Sets chromatic aberration amount to 0
  56439. */
  56440. disableChromaticAberration(): void;
  56441. /**
  56442. * Sets the EdgeDistortion amount
  56443. * @param amount amount of EdgeDistortion
  56444. */
  56445. setEdgeDistortion(amount: number): void;
  56446. /**
  56447. * Sets edge distortion to 0
  56448. */
  56449. disableEdgeDistortion(): void;
  56450. /**
  56451. * Sets the FocusDistance amount
  56452. * @param amount amount of FocusDistance
  56453. */
  56454. setFocusDistance(amount: number): void;
  56455. /**
  56456. * Disables depth of field
  56457. */
  56458. disableDepthOfField(): void;
  56459. /**
  56460. * Sets the Aperture amount
  56461. * @param amount amount of Aperture
  56462. */
  56463. setAperture(amount: number): void;
  56464. /**
  56465. * Sets the DarkenOutOfFocus amount
  56466. * @param amount amount of DarkenOutOfFocus
  56467. */
  56468. setDarkenOutOfFocus(amount: number): void;
  56469. private _pentagonBokehIsEnabled;
  56470. /**
  56471. * Creates a pentagon bokeh effect
  56472. */
  56473. enablePentagonBokeh(): void;
  56474. /**
  56475. * Disables the pentagon bokeh effect
  56476. */
  56477. disablePentagonBokeh(): void;
  56478. /**
  56479. * Enables noise blur
  56480. */
  56481. enableNoiseBlur(): void;
  56482. /**
  56483. * Disables noise blur
  56484. */
  56485. disableNoiseBlur(): void;
  56486. /**
  56487. * Sets the HighlightsGain amount
  56488. * @param amount amount of HighlightsGain
  56489. */
  56490. setHighlightsGain(amount: number): void;
  56491. /**
  56492. * Sets the HighlightsThreshold amount
  56493. * @param amount amount of HighlightsThreshold
  56494. */
  56495. setHighlightsThreshold(amount: number): void;
  56496. /**
  56497. * Disables highlights
  56498. */
  56499. disableHighlights(): void;
  56500. /**
  56501. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56502. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56503. */
  56504. dispose(disableDepthRender?: boolean): void;
  56505. private _createChromaticAberrationPostProcess;
  56506. private _createHighlightsPostProcess;
  56507. private _createDepthOfFieldPostProcess;
  56508. private _createGrainTexture;
  56509. }
  56510. }
  56511. declare module "babylonjs/Shaders/ssao2.fragment" {
  56512. /** @hidden */
  56513. export var ssao2PixelShader: {
  56514. name: string;
  56515. shader: string;
  56516. };
  56517. }
  56518. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56519. /** @hidden */
  56520. export var ssaoCombinePixelShader: {
  56521. name: string;
  56522. shader: string;
  56523. };
  56524. }
  56525. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56526. import { Camera } from "babylonjs/Cameras/camera";
  56527. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56528. import { Scene } from "babylonjs/scene";
  56529. import "babylonjs/Shaders/ssao2.fragment";
  56530. import "babylonjs/Shaders/ssaoCombine.fragment";
  56531. /**
  56532. * Render pipeline to produce ssao effect
  56533. */
  56534. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56535. /**
  56536. * @ignore
  56537. * The PassPostProcess id in the pipeline that contains the original scene color
  56538. */
  56539. SSAOOriginalSceneColorEffect: string;
  56540. /**
  56541. * @ignore
  56542. * The SSAO PostProcess id in the pipeline
  56543. */
  56544. SSAORenderEffect: string;
  56545. /**
  56546. * @ignore
  56547. * The horizontal blur PostProcess id in the pipeline
  56548. */
  56549. SSAOBlurHRenderEffect: string;
  56550. /**
  56551. * @ignore
  56552. * The vertical blur PostProcess id in the pipeline
  56553. */
  56554. SSAOBlurVRenderEffect: string;
  56555. /**
  56556. * @ignore
  56557. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56558. */
  56559. SSAOCombineRenderEffect: string;
  56560. /**
  56561. * The output strength of the SSAO post-process. Default value is 1.0.
  56562. */
  56563. totalStrength: number;
  56564. /**
  56565. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56566. */
  56567. maxZ: number;
  56568. /**
  56569. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56570. */
  56571. minZAspect: number;
  56572. private _samples;
  56573. /**
  56574. * Number of samples used for the SSAO calculations. Default value is 8
  56575. */
  56576. samples: number;
  56577. private _textureSamples;
  56578. /**
  56579. * Number of samples to use for antialiasing
  56580. */
  56581. textureSamples: number;
  56582. /**
  56583. * Ratio object used for SSAO ratio and blur ratio
  56584. */
  56585. private _ratio;
  56586. /**
  56587. * Dynamically generated sphere sampler.
  56588. */
  56589. private _sampleSphere;
  56590. /**
  56591. * Blur filter offsets
  56592. */
  56593. private _samplerOffsets;
  56594. private _expensiveBlur;
  56595. /**
  56596. * If bilateral blur should be used
  56597. */
  56598. expensiveBlur: boolean;
  56599. /**
  56600. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56601. */
  56602. radius: number;
  56603. /**
  56604. * The base color of the SSAO post-process
  56605. * The final result is "base + ssao" between [0, 1]
  56606. */
  56607. base: number;
  56608. /**
  56609. * Support test.
  56610. */
  56611. static readonly IsSupported: boolean;
  56612. private _scene;
  56613. private _depthTexture;
  56614. private _normalTexture;
  56615. private _randomTexture;
  56616. private _originalColorPostProcess;
  56617. private _ssaoPostProcess;
  56618. private _blurHPostProcess;
  56619. private _blurVPostProcess;
  56620. private _ssaoCombinePostProcess;
  56621. private _firstUpdate;
  56622. /**
  56623. * Gets active scene
  56624. */
  56625. readonly scene: Scene;
  56626. /**
  56627. * @constructor
  56628. * @param name The rendering pipeline name
  56629. * @param scene The scene linked to this pipeline
  56630. * @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 }
  56631. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56632. */
  56633. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56634. /**
  56635. * Get the class name
  56636. * @returns "SSAO2RenderingPipeline"
  56637. */
  56638. getClassName(): string;
  56639. /**
  56640. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56641. */
  56642. dispose(disableGeometryBufferRenderer?: boolean): void;
  56643. private _createBlurPostProcess;
  56644. /** @hidden */
  56645. _rebuild(): void;
  56646. private _bits;
  56647. private _radicalInverse_VdC;
  56648. private _hammersley;
  56649. private _hemisphereSample_uniform;
  56650. private _generateHemisphere;
  56651. private _createSSAOPostProcess;
  56652. private _createSSAOCombinePostProcess;
  56653. private _createRandomTexture;
  56654. /**
  56655. * Serialize the rendering pipeline (Used when exporting)
  56656. * @returns the serialized object
  56657. */
  56658. serialize(): any;
  56659. /**
  56660. * Parse the serialized pipeline
  56661. * @param source Source pipeline.
  56662. * @param scene The scene to load the pipeline to.
  56663. * @param rootUrl The URL of the serialized pipeline.
  56664. * @returns An instantiated pipeline from the serialized object.
  56665. */
  56666. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56667. }
  56668. }
  56669. declare module "babylonjs/Shaders/ssao.fragment" {
  56670. /** @hidden */
  56671. export var ssaoPixelShader: {
  56672. name: string;
  56673. shader: string;
  56674. };
  56675. }
  56676. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56677. import { Camera } from "babylonjs/Cameras/camera";
  56678. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56679. import { Scene } from "babylonjs/scene";
  56680. import "babylonjs/Shaders/ssao.fragment";
  56681. import "babylonjs/Shaders/ssaoCombine.fragment";
  56682. /**
  56683. * Render pipeline to produce ssao effect
  56684. */
  56685. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56686. /**
  56687. * @ignore
  56688. * The PassPostProcess id in the pipeline that contains the original scene color
  56689. */
  56690. SSAOOriginalSceneColorEffect: string;
  56691. /**
  56692. * @ignore
  56693. * The SSAO PostProcess id in the pipeline
  56694. */
  56695. SSAORenderEffect: string;
  56696. /**
  56697. * @ignore
  56698. * The horizontal blur PostProcess id in the pipeline
  56699. */
  56700. SSAOBlurHRenderEffect: string;
  56701. /**
  56702. * @ignore
  56703. * The vertical blur PostProcess id in the pipeline
  56704. */
  56705. SSAOBlurVRenderEffect: string;
  56706. /**
  56707. * @ignore
  56708. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56709. */
  56710. SSAOCombineRenderEffect: string;
  56711. /**
  56712. * The output strength of the SSAO post-process. Default value is 1.0.
  56713. */
  56714. totalStrength: number;
  56715. /**
  56716. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56717. */
  56718. radius: number;
  56719. /**
  56720. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56721. * Must not be equal to fallOff and superior to fallOff.
  56722. * Default value is 0.0075
  56723. */
  56724. area: number;
  56725. /**
  56726. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56727. * Must not be equal to area and inferior to area.
  56728. * Default value is 0.000001
  56729. */
  56730. fallOff: number;
  56731. /**
  56732. * The base color of the SSAO post-process
  56733. * The final result is "base + ssao" between [0, 1]
  56734. */
  56735. base: number;
  56736. private _scene;
  56737. private _depthTexture;
  56738. private _randomTexture;
  56739. private _originalColorPostProcess;
  56740. private _ssaoPostProcess;
  56741. private _blurHPostProcess;
  56742. private _blurVPostProcess;
  56743. private _ssaoCombinePostProcess;
  56744. private _firstUpdate;
  56745. /**
  56746. * Gets active scene
  56747. */
  56748. readonly scene: Scene;
  56749. /**
  56750. * @constructor
  56751. * @param name - The rendering pipeline name
  56752. * @param scene - The scene linked to this pipeline
  56753. * @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 }
  56754. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56755. */
  56756. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56757. /**
  56758. * Get the class name
  56759. * @returns "SSAORenderingPipeline"
  56760. */
  56761. getClassName(): string;
  56762. /**
  56763. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56764. */
  56765. dispose(disableDepthRender?: boolean): void;
  56766. private _createBlurPostProcess;
  56767. /** @hidden */
  56768. _rebuild(): void;
  56769. private _createSSAOPostProcess;
  56770. private _createSSAOCombinePostProcess;
  56771. private _createRandomTexture;
  56772. }
  56773. }
  56774. declare module "babylonjs/Shaders/standard.fragment" {
  56775. /** @hidden */
  56776. export var standardPixelShader: {
  56777. name: string;
  56778. shader: string;
  56779. };
  56780. }
  56781. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56782. import { Nullable } from "babylonjs/types";
  56783. import { IAnimatable } from "babylonjs/Misc/tools";
  56784. import { Camera } from "babylonjs/Cameras/camera";
  56785. import { Texture } from "babylonjs/Materials/Textures/texture";
  56786. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56787. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56788. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56789. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56790. import { IDisposable } from "babylonjs/scene";
  56791. import { SpotLight } from "babylonjs/Lights/spotLight";
  56792. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56793. import { Scene } from "babylonjs/scene";
  56794. import { Animation } from "babylonjs/Animations/animation";
  56795. import "babylonjs/Shaders/standard.fragment";
  56796. /**
  56797. * Standard rendering pipeline
  56798. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56799. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56800. */
  56801. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56802. /**
  56803. * Public members
  56804. */
  56805. /**
  56806. * Post-process which contains the original scene color before the pipeline applies all the effects
  56807. */
  56808. originalPostProcess: Nullable<PostProcess>;
  56809. /**
  56810. * Post-process used to down scale an image x4
  56811. */
  56812. downSampleX4PostProcess: Nullable<PostProcess>;
  56813. /**
  56814. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56815. */
  56816. brightPassPostProcess: Nullable<PostProcess>;
  56817. /**
  56818. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56819. */
  56820. blurHPostProcesses: PostProcess[];
  56821. /**
  56822. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56823. */
  56824. blurVPostProcesses: PostProcess[];
  56825. /**
  56826. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56827. */
  56828. textureAdderPostProcess: Nullable<PostProcess>;
  56829. /**
  56830. * Post-process used to create volumetric lighting effect
  56831. */
  56832. volumetricLightPostProcess: Nullable<PostProcess>;
  56833. /**
  56834. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56835. */
  56836. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56837. /**
  56838. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56839. */
  56840. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56841. /**
  56842. * Post-process used to merge the volumetric light effect and the real scene color
  56843. */
  56844. volumetricLightMergePostProces: Nullable<PostProcess>;
  56845. /**
  56846. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56847. */
  56848. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56849. /**
  56850. * Base post-process used to calculate the average luminance of the final image for HDR
  56851. */
  56852. luminancePostProcess: Nullable<PostProcess>;
  56853. /**
  56854. * Post-processes used to create down sample post-processes in order to get
  56855. * the average luminance of the final image for HDR
  56856. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56857. */
  56858. luminanceDownSamplePostProcesses: PostProcess[];
  56859. /**
  56860. * Post-process used to create a HDR effect (light adaptation)
  56861. */
  56862. hdrPostProcess: Nullable<PostProcess>;
  56863. /**
  56864. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56865. */
  56866. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56867. /**
  56868. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56869. */
  56870. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56871. /**
  56872. * Post-process used to merge the final HDR post-process and the real scene color
  56873. */
  56874. hdrFinalPostProcess: Nullable<PostProcess>;
  56875. /**
  56876. * Post-process used to create a lens flare effect
  56877. */
  56878. lensFlarePostProcess: Nullable<PostProcess>;
  56879. /**
  56880. * Post-process that merges the result of the lens flare post-process and the real scene color
  56881. */
  56882. lensFlareComposePostProcess: Nullable<PostProcess>;
  56883. /**
  56884. * Post-process used to create a motion blur effect
  56885. */
  56886. motionBlurPostProcess: Nullable<PostProcess>;
  56887. /**
  56888. * Post-process used to create a depth of field effect
  56889. */
  56890. depthOfFieldPostProcess: Nullable<PostProcess>;
  56891. /**
  56892. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56893. */
  56894. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56895. /**
  56896. * Represents the brightness threshold in order to configure the illuminated surfaces
  56897. */
  56898. brightThreshold: number;
  56899. /**
  56900. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56901. */
  56902. blurWidth: number;
  56903. /**
  56904. * Sets if the blur for highlighted surfaces must be only horizontal
  56905. */
  56906. horizontalBlur: boolean;
  56907. /**
  56908. * Gets the overall exposure used by the pipeline
  56909. */
  56910. /**
  56911. * Sets the overall exposure used by the pipeline
  56912. */
  56913. exposure: number;
  56914. /**
  56915. * Texture used typically to simulate "dirty" on camera lens
  56916. */
  56917. lensTexture: Nullable<Texture>;
  56918. /**
  56919. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56920. */
  56921. volumetricLightCoefficient: number;
  56922. /**
  56923. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56924. */
  56925. volumetricLightPower: number;
  56926. /**
  56927. * Used the set the blur intensity to smooth the volumetric lights
  56928. */
  56929. volumetricLightBlurScale: number;
  56930. /**
  56931. * Light (spot or directional) used to generate the volumetric lights rays
  56932. * The source light must have a shadow generate so the pipeline can get its
  56933. * depth map
  56934. */
  56935. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56936. /**
  56937. * For eye adaptation, represents the minimum luminance the eye can see
  56938. */
  56939. hdrMinimumLuminance: number;
  56940. /**
  56941. * For eye adaptation, represents the decrease luminance speed
  56942. */
  56943. hdrDecreaseRate: number;
  56944. /**
  56945. * For eye adaptation, represents the increase luminance speed
  56946. */
  56947. hdrIncreaseRate: number;
  56948. /**
  56949. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56950. */
  56951. /**
  56952. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56953. */
  56954. hdrAutoExposure: boolean;
  56955. /**
  56956. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56957. */
  56958. lensColorTexture: Nullable<Texture>;
  56959. /**
  56960. * The overall strengh for the lens flare effect
  56961. */
  56962. lensFlareStrength: number;
  56963. /**
  56964. * Dispersion coefficient for lens flare ghosts
  56965. */
  56966. lensFlareGhostDispersal: number;
  56967. /**
  56968. * Main lens flare halo width
  56969. */
  56970. lensFlareHaloWidth: number;
  56971. /**
  56972. * Based on the lens distortion effect, defines how much the lens flare result
  56973. * is distorted
  56974. */
  56975. lensFlareDistortionStrength: number;
  56976. /**
  56977. * Lens star texture must be used to simulate rays on the flares and is available
  56978. * in the documentation
  56979. */
  56980. lensStarTexture: Nullable<Texture>;
  56981. /**
  56982. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56983. * flare effect by taking account of the dirt texture
  56984. */
  56985. lensFlareDirtTexture: Nullable<Texture>;
  56986. /**
  56987. * Represents the focal length for the depth of field effect
  56988. */
  56989. depthOfFieldDistance: number;
  56990. /**
  56991. * Represents the blur intensity for the blurred part of the depth of field effect
  56992. */
  56993. depthOfFieldBlurWidth: number;
  56994. /**
  56995. * For motion blur, defines how much the image is blurred by the movement
  56996. */
  56997. motionStrength: number;
  56998. /**
  56999. * List of animations for the pipeline (IAnimatable implementation)
  57000. */
  57001. animations: Animation[];
  57002. /**
  57003. * Private members
  57004. */
  57005. private _scene;
  57006. private _currentDepthOfFieldSource;
  57007. private _basePostProcess;
  57008. private _fixedExposure;
  57009. private _currentExposure;
  57010. private _hdrAutoExposure;
  57011. private _hdrCurrentLuminance;
  57012. private _floatTextureType;
  57013. private _ratio;
  57014. private _bloomEnabled;
  57015. private _depthOfFieldEnabled;
  57016. private _vlsEnabled;
  57017. private _lensFlareEnabled;
  57018. private _hdrEnabled;
  57019. private _motionBlurEnabled;
  57020. private _fxaaEnabled;
  57021. private _motionBlurSamples;
  57022. private _volumetricLightStepsCount;
  57023. private _samples;
  57024. /**
  57025. * @ignore
  57026. * Specifies if the bloom pipeline is enabled
  57027. */
  57028. BloomEnabled: boolean;
  57029. /**
  57030. * @ignore
  57031. * Specifies if the depth of field pipeline is enabed
  57032. */
  57033. DepthOfFieldEnabled: boolean;
  57034. /**
  57035. * @ignore
  57036. * Specifies if the lens flare pipeline is enabed
  57037. */
  57038. LensFlareEnabled: boolean;
  57039. /**
  57040. * @ignore
  57041. * Specifies if the HDR pipeline is enabled
  57042. */
  57043. HDREnabled: boolean;
  57044. /**
  57045. * @ignore
  57046. * Specifies if the volumetric lights scattering effect is enabled
  57047. */
  57048. VLSEnabled: boolean;
  57049. /**
  57050. * @ignore
  57051. * Specifies if the motion blur effect is enabled
  57052. */
  57053. MotionBlurEnabled: boolean;
  57054. /**
  57055. * Specifies if anti-aliasing is enabled
  57056. */
  57057. fxaaEnabled: boolean;
  57058. /**
  57059. * Specifies the number of steps used to calculate the volumetric lights
  57060. * Typically in interval [50, 200]
  57061. */
  57062. volumetricLightStepsCount: number;
  57063. /**
  57064. * Specifies the number of samples used for the motion blur effect
  57065. * Typically in interval [16, 64]
  57066. */
  57067. motionBlurSamples: number;
  57068. /**
  57069. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57070. */
  57071. samples: number;
  57072. /**
  57073. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57074. * @constructor
  57075. * @param name The rendering pipeline name
  57076. * @param scene The scene linked to this pipeline
  57077. * @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)
  57078. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57079. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57080. */
  57081. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57082. private _buildPipeline;
  57083. private _createDownSampleX4PostProcess;
  57084. private _createBrightPassPostProcess;
  57085. private _createBlurPostProcesses;
  57086. private _createTextureAdderPostProcess;
  57087. private _createVolumetricLightPostProcess;
  57088. private _createLuminancePostProcesses;
  57089. private _createHdrPostProcess;
  57090. private _createLensFlarePostProcess;
  57091. private _createDepthOfFieldPostProcess;
  57092. private _createMotionBlurPostProcess;
  57093. private _getDepthTexture;
  57094. private _disposePostProcesses;
  57095. /**
  57096. * Dispose of the pipeline and stop all post processes
  57097. */
  57098. dispose(): void;
  57099. /**
  57100. * Serialize the rendering pipeline (Used when exporting)
  57101. * @returns the serialized object
  57102. */
  57103. serialize(): any;
  57104. /**
  57105. * Parse the serialized pipeline
  57106. * @param source Source pipeline.
  57107. * @param scene The scene to load the pipeline to.
  57108. * @param rootUrl The URL of the serialized pipeline.
  57109. * @returns An instantiated pipeline from the serialized object.
  57110. */
  57111. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57112. /**
  57113. * Luminance steps
  57114. */
  57115. static LuminanceSteps: number;
  57116. }
  57117. }
  57118. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  57119. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  57120. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  57121. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  57122. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  57123. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  57124. }
  57125. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  57126. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  57127. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57128. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  57129. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  57130. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  57131. }
  57132. declare module "babylonjs/Shaders/tonemap.fragment" {
  57133. /** @hidden */
  57134. export var tonemapPixelShader: {
  57135. name: string;
  57136. shader: string;
  57137. };
  57138. }
  57139. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  57140. import { Camera } from "babylonjs/Cameras/camera";
  57141. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57142. import "babylonjs/Shaders/tonemap.fragment";
  57143. import { Engine } from "babylonjs/Engines/engine";
  57144. /** Defines operator used for tonemapping */
  57145. export enum TonemappingOperator {
  57146. /** Hable */
  57147. Hable = 0,
  57148. /** Reinhard */
  57149. Reinhard = 1,
  57150. /** HejiDawson */
  57151. HejiDawson = 2,
  57152. /** Photographic */
  57153. Photographic = 3
  57154. }
  57155. /**
  57156. * Defines a post process to apply tone mapping
  57157. */
  57158. export class TonemapPostProcess extends PostProcess {
  57159. private _operator;
  57160. /** Defines the required exposure adjustement */
  57161. exposureAdjustment: number;
  57162. /**
  57163. * Creates a new TonemapPostProcess
  57164. * @param name defines the name of the postprocess
  57165. * @param _operator defines the operator to use
  57166. * @param exposureAdjustment defines the required exposure adjustement
  57167. * @param camera defines the camera to use (can be null)
  57168. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57169. * @param engine defines the hosting engine (can be ignore if camera is set)
  57170. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57171. */
  57172. constructor(name: string, _operator: TonemappingOperator,
  57173. /** Defines the required exposure adjustement */
  57174. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57175. }
  57176. }
  57177. declare module "babylonjs/Shaders/depth.vertex" {
  57178. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57179. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57180. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57181. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57182. /** @hidden */
  57183. export var depthVertexShader: {
  57184. name: string;
  57185. shader: string;
  57186. };
  57187. }
  57188. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  57189. /** @hidden */
  57190. export var volumetricLightScatteringPixelShader: {
  57191. name: string;
  57192. shader: string;
  57193. };
  57194. }
  57195. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  57196. /** @hidden */
  57197. export var volumetricLightScatteringPassPixelShader: {
  57198. name: string;
  57199. shader: string;
  57200. };
  57201. }
  57202. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  57203. import { Vector3 } from "babylonjs/Maths/math";
  57204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57205. import { Mesh } from "babylonjs/Meshes/mesh";
  57206. import { Camera } from "babylonjs/Cameras/camera";
  57207. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57208. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57209. import { Scene } from "babylonjs/scene";
  57210. import "babylonjs/Meshes/Builders/planeBuilder";
  57211. import "babylonjs/Shaders/depth.vertex";
  57212. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  57213. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  57214. import { Engine } from "babylonjs/Engines/engine";
  57215. /**
  57216. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57217. */
  57218. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57219. private _volumetricLightScatteringPass;
  57220. private _volumetricLightScatteringRTT;
  57221. private _viewPort;
  57222. private _screenCoordinates;
  57223. private _cachedDefines;
  57224. /**
  57225. * If not undefined, the mesh position is computed from the attached node position
  57226. */
  57227. attachedNode: {
  57228. position: Vector3;
  57229. };
  57230. /**
  57231. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57232. */
  57233. customMeshPosition: Vector3;
  57234. /**
  57235. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57236. */
  57237. useCustomMeshPosition: boolean;
  57238. /**
  57239. * If the post-process should inverse the light scattering direction
  57240. */
  57241. invert: boolean;
  57242. /**
  57243. * The internal mesh used by the post-process
  57244. */
  57245. mesh: Mesh;
  57246. /**
  57247. * @hidden
  57248. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57249. */
  57250. useDiffuseColor: boolean;
  57251. /**
  57252. * Array containing the excluded meshes not rendered in the internal pass
  57253. */
  57254. excludedMeshes: AbstractMesh[];
  57255. /**
  57256. * Controls the overall intensity of the post-process
  57257. */
  57258. exposure: number;
  57259. /**
  57260. * Dissipates each sample's contribution in range [0, 1]
  57261. */
  57262. decay: number;
  57263. /**
  57264. * Controls the overall intensity of each sample
  57265. */
  57266. weight: number;
  57267. /**
  57268. * Controls the density of each sample
  57269. */
  57270. density: number;
  57271. /**
  57272. * @constructor
  57273. * @param name The post-process name
  57274. * @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)
  57275. * @param camera The camera that the post-process will be attached to
  57276. * @param mesh The mesh used to create the light scattering
  57277. * @param samples The post-process quality, default 100
  57278. * @param samplingModeThe post-process filtering mode
  57279. * @param engine The babylon engine
  57280. * @param reusable If the post-process is reusable
  57281. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57282. */
  57283. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57284. /**
  57285. * Returns the string "VolumetricLightScatteringPostProcess"
  57286. * @returns "VolumetricLightScatteringPostProcess"
  57287. */
  57288. getClassName(): string;
  57289. private _isReady;
  57290. /**
  57291. * Sets the new light position for light scattering effect
  57292. * @param position The new custom light position
  57293. */
  57294. setCustomMeshPosition(position: Vector3): void;
  57295. /**
  57296. * Returns the light position for light scattering effect
  57297. * @return Vector3 The custom light position
  57298. */
  57299. getCustomMeshPosition(): Vector3;
  57300. /**
  57301. * Disposes the internal assets and detaches the post-process from the camera
  57302. */
  57303. dispose(camera: Camera): void;
  57304. /**
  57305. * Returns the render target texture used by the post-process
  57306. * @return the render target texture used by the post-process
  57307. */
  57308. getPass(): RenderTargetTexture;
  57309. private _meshExcluded;
  57310. private _createPass;
  57311. private _updateMeshScreenCoordinates;
  57312. /**
  57313. * Creates a default mesh for the Volumeric Light Scattering post-process
  57314. * @param name The mesh name
  57315. * @param scene The scene where to create the mesh
  57316. * @return the default mesh
  57317. */
  57318. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57319. }
  57320. }
  57321. declare module "babylonjs/PostProcesses/index" {
  57322. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57323. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57324. export * from "babylonjs/PostProcesses/bloomEffect";
  57325. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57326. export * from "babylonjs/PostProcesses/blurPostProcess";
  57327. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57328. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57329. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57330. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57331. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57332. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57333. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57334. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57335. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57336. export * from "babylonjs/PostProcesses/filterPostProcess";
  57337. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57338. export * from "babylonjs/PostProcesses/grainPostProcess";
  57339. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57340. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57341. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57342. export * from "babylonjs/PostProcesses/passPostProcess";
  57343. export * from "babylonjs/PostProcesses/postProcess";
  57344. export * from "babylonjs/PostProcesses/postProcessManager";
  57345. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57346. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57347. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57348. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57349. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57350. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57351. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57352. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57353. }
  57354. declare module "babylonjs/Probes/index" {
  57355. export * from "babylonjs/Probes/reflectionProbe";
  57356. }
  57357. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57358. import { Scene } from "babylonjs/scene";
  57359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57360. import { Color3 } from "babylonjs/Maths/math";
  57361. import { SmartArray } from "babylonjs/Misc/smartArray";
  57362. import { ISceneComponent } from "babylonjs/sceneComponent";
  57363. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57364. import "babylonjs/Meshes/Builders/boxBuilder";
  57365. import "babylonjs/Shaders/color.fragment";
  57366. import "babylonjs/Shaders/color.vertex";
  57367. module "babylonjs/scene" {
  57368. interface Scene {
  57369. /** @hidden (Backing field) */
  57370. _boundingBoxRenderer: BoundingBoxRenderer;
  57371. /** @hidden (Backing field) */
  57372. _forceShowBoundingBoxes: boolean;
  57373. /**
  57374. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57375. */
  57376. forceShowBoundingBoxes: boolean;
  57377. /**
  57378. * Gets the bounding box renderer associated with the scene
  57379. * @returns a BoundingBoxRenderer
  57380. */
  57381. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57382. }
  57383. }
  57384. module "babylonjs/Meshes/abstractMesh" {
  57385. interface AbstractMesh {
  57386. /** @hidden (Backing field) */
  57387. _showBoundingBox: boolean;
  57388. /**
  57389. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57390. */
  57391. showBoundingBox: boolean;
  57392. }
  57393. }
  57394. /**
  57395. * Component responsible of rendering the bounding box of the meshes in a scene.
  57396. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57397. */
  57398. export class BoundingBoxRenderer implements ISceneComponent {
  57399. /**
  57400. * The component name helpfull to identify the component in the list of scene components.
  57401. */
  57402. readonly name: string;
  57403. /**
  57404. * The scene the component belongs to.
  57405. */
  57406. scene: Scene;
  57407. /**
  57408. * Color of the bounding box lines placed in front of an object
  57409. */
  57410. frontColor: Color3;
  57411. /**
  57412. * Color of the bounding box lines placed behind an object
  57413. */
  57414. backColor: Color3;
  57415. /**
  57416. * Defines if the renderer should show the back lines or not
  57417. */
  57418. showBackLines: boolean;
  57419. /**
  57420. * @hidden
  57421. */
  57422. renderList: SmartArray<BoundingBox>;
  57423. private _colorShader;
  57424. private _vertexBuffers;
  57425. private _indexBuffer;
  57426. /**
  57427. * Instantiates a new bounding box renderer in a scene.
  57428. * @param scene the scene the renderer renders in
  57429. */
  57430. constructor(scene: Scene);
  57431. /**
  57432. * Registers the component in a given scene
  57433. */
  57434. register(): void;
  57435. private _evaluateSubMesh;
  57436. private _activeMesh;
  57437. private _prepareRessources;
  57438. private _createIndexBuffer;
  57439. /**
  57440. * Rebuilds the elements related to this component in case of
  57441. * context lost for instance.
  57442. */
  57443. rebuild(): void;
  57444. /**
  57445. * @hidden
  57446. */
  57447. reset(): void;
  57448. /**
  57449. * Render the bounding boxes of a specific rendering group
  57450. * @param renderingGroupId defines the rendering group to render
  57451. */
  57452. render(renderingGroupId: number): void;
  57453. /**
  57454. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57455. * @param mesh Define the mesh to render the occlusion bounding box for
  57456. */
  57457. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57458. /**
  57459. * Dispose and release the resources attached to this renderer.
  57460. */
  57461. dispose(): void;
  57462. }
  57463. }
  57464. declare module "babylonjs/Shaders/depth.fragment" {
  57465. /** @hidden */
  57466. export var depthPixelShader: {
  57467. name: string;
  57468. shader: string;
  57469. };
  57470. }
  57471. declare module "babylonjs/Rendering/depthRenderer" {
  57472. import { Nullable } from "babylonjs/types";
  57473. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57474. import { Scene } from "babylonjs/scene";
  57475. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57476. import { Camera } from "babylonjs/Cameras/camera";
  57477. import "babylonjs/Shaders/depth.fragment";
  57478. import "babylonjs/Shaders/depth.vertex";
  57479. /**
  57480. * This represents a depth renderer in Babylon.
  57481. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57482. */
  57483. export class DepthRenderer {
  57484. private _scene;
  57485. private _depthMap;
  57486. private _effect;
  57487. private _cachedDefines;
  57488. private _camera;
  57489. /**
  57490. * Specifiess that the depth renderer will only be used within
  57491. * the camera it is created for.
  57492. * This can help forcing its rendering during the camera processing.
  57493. */
  57494. useOnlyInActiveCamera: boolean;
  57495. /** @hidden */
  57496. static _SceneComponentInitialization: (scene: Scene) => void;
  57497. /**
  57498. * Instantiates a depth renderer
  57499. * @param scene The scene the renderer belongs to
  57500. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57501. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57502. */
  57503. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57504. /**
  57505. * Creates the depth rendering effect and checks if the effect is ready.
  57506. * @param subMesh The submesh to be used to render the depth map of
  57507. * @param useInstances If multiple world instances should be used
  57508. * @returns if the depth renderer is ready to render the depth map
  57509. */
  57510. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57511. /**
  57512. * Gets the texture which the depth map will be written to.
  57513. * @returns The depth map texture
  57514. */
  57515. getDepthMap(): RenderTargetTexture;
  57516. /**
  57517. * Disposes of the depth renderer.
  57518. */
  57519. dispose(): void;
  57520. }
  57521. }
  57522. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57523. import { Nullable } from "babylonjs/types";
  57524. import { Scene } from "babylonjs/scene";
  57525. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57526. import { Camera } from "babylonjs/Cameras/camera";
  57527. import { ISceneComponent } from "babylonjs/sceneComponent";
  57528. module "babylonjs/scene" {
  57529. interface Scene {
  57530. /** @hidden (Backing field) */
  57531. _depthRenderer: {
  57532. [id: string]: DepthRenderer;
  57533. };
  57534. /**
  57535. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57536. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57537. * @returns the created depth renderer
  57538. */
  57539. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57540. /**
  57541. * Disables a depth renderer for a given camera
  57542. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57543. */
  57544. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57545. }
  57546. }
  57547. /**
  57548. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57549. * in several rendering techniques.
  57550. */
  57551. export class DepthRendererSceneComponent implements ISceneComponent {
  57552. /**
  57553. * The component name helpfull to identify the component in the list of scene components.
  57554. */
  57555. readonly name: string;
  57556. /**
  57557. * The scene the component belongs to.
  57558. */
  57559. scene: Scene;
  57560. /**
  57561. * Creates a new instance of the component for the given scene
  57562. * @param scene Defines the scene to register the component in
  57563. */
  57564. constructor(scene: Scene);
  57565. /**
  57566. * Registers the component in a given scene
  57567. */
  57568. register(): void;
  57569. /**
  57570. * Rebuilds the elements related to this component in case of
  57571. * context lost for instance.
  57572. */
  57573. rebuild(): void;
  57574. /**
  57575. * Disposes the component and the associated ressources
  57576. */
  57577. dispose(): void;
  57578. private _gatherRenderTargets;
  57579. private _gatherActiveCameraRenderTargets;
  57580. }
  57581. }
  57582. declare module "babylonjs/Shaders/outline.fragment" {
  57583. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57584. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57585. /** @hidden */
  57586. export var outlinePixelShader: {
  57587. name: string;
  57588. shader: string;
  57589. };
  57590. }
  57591. declare module "babylonjs/Shaders/outline.vertex" {
  57592. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57593. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57594. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57595. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57596. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57597. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57598. /** @hidden */
  57599. export var outlineVertexShader: {
  57600. name: string;
  57601. shader: string;
  57602. };
  57603. }
  57604. declare module "babylonjs/Rendering/outlineRenderer" {
  57605. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57606. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57607. import { Scene } from "babylonjs/scene";
  57608. import { ISceneComponent } from "babylonjs/sceneComponent";
  57609. import "babylonjs/Shaders/outline.fragment";
  57610. import "babylonjs/Shaders/outline.vertex";
  57611. module "babylonjs/scene" {
  57612. interface Scene {
  57613. /** @hidden */
  57614. _outlineRenderer: OutlineRenderer;
  57615. /**
  57616. * Gets the outline renderer associated with the scene
  57617. * @returns a OutlineRenderer
  57618. */
  57619. getOutlineRenderer(): OutlineRenderer;
  57620. }
  57621. }
  57622. module "babylonjs/Meshes/abstractMesh" {
  57623. interface AbstractMesh {
  57624. /** @hidden (Backing field) */
  57625. _renderOutline: boolean;
  57626. /**
  57627. * Gets or sets a boolean indicating if the outline must be rendered as well
  57628. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57629. */
  57630. renderOutline: boolean;
  57631. /** @hidden (Backing field) */
  57632. _renderOverlay: boolean;
  57633. /**
  57634. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57635. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57636. */
  57637. renderOverlay: boolean;
  57638. }
  57639. }
  57640. /**
  57641. * This class is responsible to draw bothe outline/overlay of meshes.
  57642. * It should not be used directly but through the available method on mesh.
  57643. */
  57644. export class OutlineRenderer implements ISceneComponent {
  57645. /**
  57646. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57647. */
  57648. private static _StencilReference;
  57649. /**
  57650. * The name of the component. Each component must have a unique name.
  57651. */
  57652. name: string;
  57653. /**
  57654. * The scene the component belongs to.
  57655. */
  57656. scene: Scene;
  57657. /**
  57658. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57659. */
  57660. zOffset: number;
  57661. private _engine;
  57662. private _effect;
  57663. private _cachedDefines;
  57664. private _savedDepthWrite;
  57665. /**
  57666. * Instantiates a new outline renderer. (There could be only one per scene).
  57667. * @param scene Defines the scene it belongs to
  57668. */
  57669. constructor(scene: Scene);
  57670. /**
  57671. * Register the component to one instance of a scene.
  57672. */
  57673. register(): void;
  57674. /**
  57675. * Rebuilds the elements related to this component in case of
  57676. * context lost for instance.
  57677. */
  57678. rebuild(): void;
  57679. /**
  57680. * Disposes the component and the associated ressources.
  57681. */
  57682. dispose(): void;
  57683. /**
  57684. * Renders the outline in the canvas.
  57685. * @param subMesh Defines the sumesh to render
  57686. * @param batch Defines the batch of meshes in case of instances
  57687. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57688. */
  57689. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57690. /**
  57691. * Returns whether or not the outline renderer is ready for a given submesh.
  57692. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57693. * @param subMesh Defines the submesh to check readyness for
  57694. * @param useInstances Defines wheter wee are trying to render instances or not
  57695. * @returns true if ready otherwise false
  57696. */
  57697. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57698. private _beforeRenderingMesh;
  57699. private _afterRenderingMesh;
  57700. }
  57701. }
  57702. declare module "babylonjs/Rendering/index" {
  57703. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57704. export * from "babylonjs/Rendering/depthRenderer";
  57705. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57706. export * from "babylonjs/Rendering/edgesRenderer";
  57707. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57708. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57709. export * from "babylonjs/Rendering/outlineRenderer";
  57710. export * from "babylonjs/Rendering/renderingGroup";
  57711. export * from "babylonjs/Rendering/renderingManager";
  57712. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57713. }
  57714. declare module "babylonjs/Sprites/index" {
  57715. export * from "babylonjs/Sprites/sprite";
  57716. export * from "babylonjs/Sprites/spriteManager";
  57717. export * from "babylonjs/Sprites/spriteSceneComponent";
  57718. }
  57719. declare module "babylonjs/Misc/assetsManager" {
  57720. import { Scene } from "babylonjs/scene";
  57721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57722. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57723. import { Skeleton } from "babylonjs/Bones/skeleton";
  57724. import { Observable } from "babylonjs/Misc/observable";
  57725. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57726. import { Texture } from "babylonjs/Materials/Textures/texture";
  57727. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57728. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57729. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57730. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57731. /**
  57732. * Defines the list of states available for a task inside a AssetsManager
  57733. */
  57734. export enum AssetTaskState {
  57735. /**
  57736. * Initialization
  57737. */
  57738. INIT = 0,
  57739. /**
  57740. * Running
  57741. */
  57742. RUNNING = 1,
  57743. /**
  57744. * Done
  57745. */
  57746. DONE = 2,
  57747. /**
  57748. * Error
  57749. */
  57750. ERROR = 3
  57751. }
  57752. /**
  57753. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57754. */
  57755. export abstract class AbstractAssetTask {
  57756. /**
  57757. * Task name
  57758. */ name: string;
  57759. /**
  57760. * Callback called when the task is successful
  57761. */
  57762. onSuccess: (task: any) => void;
  57763. /**
  57764. * Callback called when the task is not successful
  57765. */
  57766. onError: (task: any, message?: string, exception?: any) => void;
  57767. /**
  57768. * Creates a new AssetsManager
  57769. * @param name defines the name of the task
  57770. */
  57771. constructor(
  57772. /**
  57773. * Task name
  57774. */ name: string);
  57775. private _isCompleted;
  57776. private _taskState;
  57777. private _errorObject;
  57778. /**
  57779. * Get if the task is completed
  57780. */
  57781. readonly isCompleted: boolean;
  57782. /**
  57783. * Gets the current state of the task
  57784. */
  57785. readonly taskState: AssetTaskState;
  57786. /**
  57787. * Gets the current error object (if task is in error)
  57788. */
  57789. readonly errorObject: {
  57790. message?: string;
  57791. exception?: any;
  57792. };
  57793. /**
  57794. * Internal only
  57795. * @hidden
  57796. */
  57797. _setErrorObject(message?: string, exception?: any): void;
  57798. /**
  57799. * Execute the current task
  57800. * @param scene defines the scene where you want your assets to be loaded
  57801. * @param onSuccess is a callback called when the task is successfully executed
  57802. * @param onError is a callback called if an error occurs
  57803. */
  57804. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57805. /**
  57806. * Execute the current task
  57807. * @param scene defines the scene where you want your assets to be loaded
  57808. * @param onSuccess is a callback called when the task is successfully executed
  57809. * @param onError is a callback called if an error occurs
  57810. */
  57811. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57812. /**
  57813. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57814. * This can be used with failed tasks that have the reason for failure fixed.
  57815. */
  57816. reset(): void;
  57817. private onErrorCallback;
  57818. private onDoneCallback;
  57819. }
  57820. /**
  57821. * Define the interface used by progress events raised during assets loading
  57822. */
  57823. export interface IAssetsProgressEvent {
  57824. /**
  57825. * Defines the number of remaining tasks to process
  57826. */
  57827. remainingCount: number;
  57828. /**
  57829. * Defines the total number of tasks
  57830. */
  57831. totalCount: number;
  57832. /**
  57833. * Defines the task that was just processed
  57834. */
  57835. task: AbstractAssetTask;
  57836. }
  57837. /**
  57838. * Class used to share progress information about assets loading
  57839. */
  57840. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57841. /**
  57842. * Defines the number of remaining tasks to process
  57843. */
  57844. remainingCount: number;
  57845. /**
  57846. * Defines the total number of tasks
  57847. */
  57848. totalCount: number;
  57849. /**
  57850. * Defines the task that was just processed
  57851. */
  57852. task: AbstractAssetTask;
  57853. /**
  57854. * Creates a AssetsProgressEvent
  57855. * @param remainingCount defines the number of remaining tasks to process
  57856. * @param totalCount defines the total number of tasks
  57857. * @param task defines the task that was just processed
  57858. */
  57859. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57860. }
  57861. /**
  57862. * Define a task used by AssetsManager to load meshes
  57863. */
  57864. export class MeshAssetTask extends AbstractAssetTask {
  57865. /**
  57866. * Defines the name of the task
  57867. */
  57868. name: string;
  57869. /**
  57870. * Defines the list of mesh's names you want to load
  57871. */
  57872. meshesNames: any;
  57873. /**
  57874. * Defines the root url to use as a base to load your meshes and associated resources
  57875. */
  57876. rootUrl: string;
  57877. /**
  57878. * Defines the filename of the scene to load from
  57879. */
  57880. sceneFilename: string;
  57881. /**
  57882. * Gets the list of loaded meshes
  57883. */
  57884. loadedMeshes: Array<AbstractMesh>;
  57885. /**
  57886. * Gets the list of loaded particle systems
  57887. */
  57888. loadedParticleSystems: Array<IParticleSystem>;
  57889. /**
  57890. * Gets the list of loaded skeletons
  57891. */
  57892. loadedSkeletons: Array<Skeleton>;
  57893. /**
  57894. * Gets the list of loaded animation groups
  57895. */
  57896. loadedAnimationGroups: Array<AnimationGroup>;
  57897. /**
  57898. * Callback called when the task is successful
  57899. */
  57900. onSuccess: (task: MeshAssetTask) => void;
  57901. /**
  57902. * Callback called when the task is successful
  57903. */
  57904. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57905. /**
  57906. * Creates a new MeshAssetTask
  57907. * @param name defines the name of the task
  57908. * @param meshesNames defines the list of mesh's names you want to load
  57909. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57910. * @param sceneFilename defines the filename of the scene to load from
  57911. */
  57912. constructor(
  57913. /**
  57914. * Defines the name of the task
  57915. */
  57916. name: string,
  57917. /**
  57918. * Defines the list of mesh's names you want to load
  57919. */
  57920. meshesNames: any,
  57921. /**
  57922. * Defines the root url to use as a base to load your meshes and associated resources
  57923. */
  57924. rootUrl: string,
  57925. /**
  57926. * Defines the filename of the scene to load from
  57927. */
  57928. sceneFilename: string);
  57929. /**
  57930. * Execute the current task
  57931. * @param scene defines the scene where you want your assets to be loaded
  57932. * @param onSuccess is a callback called when the task is successfully executed
  57933. * @param onError is a callback called if an error occurs
  57934. */
  57935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57936. }
  57937. /**
  57938. * Define a task used by AssetsManager to load text content
  57939. */
  57940. export class TextFileAssetTask extends AbstractAssetTask {
  57941. /**
  57942. * Defines the name of the task
  57943. */
  57944. name: string;
  57945. /**
  57946. * Defines the location of the file to load
  57947. */
  57948. url: string;
  57949. /**
  57950. * Gets the loaded text string
  57951. */
  57952. text: string;
  57953. /**
  57954. * Callback called when the task is successful
  57955. */
  57956. onSuccess: (task: TextFileAssetTask) => void;
  57957. /**
  57958. * Callback called when the task is successful
  57959. */
  57960. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57961. /**
  57962. * Creates a new TextFileAssetTask object
  57963. * @param name defines the name of the task
  57964. * @param url defines the location of the file to load
  57965. */
  57966. constructor(
  57967. /**
  57968. * Defines the name of the task
  57969. */
  57970. name: string,
  57971. /**
  57972. * Defines the location of the file to load
  57973. */
  57974. url: string);
  57975. /**
  57976. * Execute the current task
  57977. * @param scene defines the scene where you want your assets to be loaded
  57978. * @param onSuccess is a callback called when the task is successfully executed
  57979. * @param onError is a callback called if an error occurs
  57980. */
  57981. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57982. }
  57983. /**
  57984. * Define a task used by AssetsManager to load binary data
  57985. */
  57986. export class BinaryFileAssetTask extends AbstractAssetTask {
  57987. /**
  57988. * Defines the name of the task
  57989. */
  57990. name: string;
  57991. /**
  57992. * Defines the location of the file to load
  57993. */
  57994. url: string;
  57995. /**
  57996. * Gets the lodaded data (as an array buffer)
  57997. */
  57998. data: ArrayBuffer;
  57999. /**
  58000. * Callback called when the task is successful
  58001. */
  58002. onSuccess: (task: BinaryFileAssetTask) => void;
  58003. /**
  58004. * Callback called when the task is successful
  58005. */
  58006. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58007. /**
  58008. * Creates a new BinaryFileAssetTask object
  58009. * @param name defines the name of the new task
  58010. * @param url defines the location of the file to load
  58011. */
  58012. constructor(
  58013. /**
  58014. * Defines the name of the task
  58015. */
  58016. name: string,
  58017. /**
  58018. * Defines the location of the file to load
  58019. */
  58020. url: string);
  58021. /**
  58022. * Execute the current task
  58023. * @param scene defines the scene where you want your assets to be loaded
  58024. * @param onSuccess is a callback called when the task is successfully executed
  58025. * @param onError is a callback called if an error occurs
  58026. */
  58027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58028. }
  58029. /**
  58030. * Define a task used by AssetsManager to load images
  58031. */
  58032. export class ImageAssetTask extends AbstractAssetTask {
  58033. /**
  58034. * Defines the name of the task
  58035. */
  58036. name: string;
  58037. /**
  58038. * Defines the location of the image to load
  58039. */
  58040. url: string;
  58041. /**
  58042. * Gets the loaded images
  58043. */
  58044. image: HTMLImageElement;
  58045. /**
  58046. * Callback called when the task is successful
  58047. */
  58048. onSuccess: (task: ImageAssetTask) => void;
  58049. /**
  58050. * Callback called when the task is successful
  58051. */
  58052. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58053. /**
  58054. * Creates a new ImageAssetTask
  58055. * @param name defines the name of the task
  58056. * @param url defines the location of the image to load
  58057. */
  58058. constructor(
  58059. /**
  58060. * Defines the name of the task
  58061. */
  58062. name: string,
  58063. /**
  58064. * Defines the location of the image to load
  58065. */
  58066. url: string);
  58067. /**
  58068. * Execute the current task
  58069. * @param scene defines the scene where you want your assets to be loaded
  58070. * @param onSuccess is a callback called when the task is successfully executed
  58071. * @param onError is a callback called if an error occurs
  58072. */
  58073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58074. }
  58075. /**
  58076. * Defines the interface used by texture loading tasks
  58077. */
  58078. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58079. /**
  58080. * Gets the loaded texture
  58081. */
  58082. texture: TEX;
  58083. }
  58084. /**
  58085. * Define a task used by AssetsManager to load 2D textures
  58086. */
  58087. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58088. /**
  58089. * Defines the name of the task
  58090. */
  58091. name: string;
  58092. /**
  58093. * Defines the location of the file to load
  58094. */
  58095. url: string;
  58096. /**
  58097. * Defines if mipmap should not be generated (default is false)
  58098. */
  58099. noMipmap?: boolean | undefined;
  58100. /**
  58101. * Defines if texture must be inverted on Y axis (default is false)
  58102. */
  58103. invertY?: boolean | undefined;
  58104. /**
  58105. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58106. */
  58107. samplingMode: number;
  58108. /**
  58109. * Gets the loaded texture
  58110. */
  58111. texture: Texture;
  58112. /**
  58113. * Callback called when the task is successful
  58114. */
  58115. onSuccess: (task: TextureAssetTask) => void;
  58116. /**
  58117. * Callback called when the task is successful
  58118. */
  58119. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58120. /**
  58121. * Creates a new TextureAssetTask object
  58122. * @param name defines the name of the task
  58123. * @param url defines the location of the file to load
  58124. * @param noMipmap defines if mipmap should not be generated (default is false)
  58125. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58126. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58127. */
  58128. constructor(
  58129. /**
  58130. * Defines the name of the task
  58131. */
  58132. name: string,
  58133. /**
  58134. * Defines the location of the file to load
  58135. */
  58136. url: string,
  58137. /**
  58138. * Defines if mipmap should not be generated (default is false)
  58139. */
  58140. noMipmap?: boolean | undefined,
  58141. /**
  58142. * Defines if texture must be inverted on Y axis (default is false)
  58143. */
  58144. invertY?: boolean | undefined,
  58145. /**
  58146. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58147. */
  58148. samplingMode?: number);
  58149. /**
  58150. * Execute the current task
  58151. * @param scene defines the scene where you want your assets to be loaded
  58152. * @param onSuccess is a callback called when the task is successfully executed
  58153. * @param onError is a callback called if an error occurs
  58154. */
  58155. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58156. }
  58157. /**
  58158. * Define a task used by AssetsManager to load cube textures
  58159. */
  58160. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58161. /**
  58162. * Defines the name of the task
  58163. */
  58164. name: string;
  58165. /**
  58166. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58167. */
  58168. url: string;
  58169. /**
  58170. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58171. */
  58172. extensions?: string[] | undefined;
  58173. /**
  58174. * Defines if mipmaps should not be generated (default is false)
  58175. */
  58176. noMipmap?: boolean | undefined;
  58177. /**
  58178. * Defines the explicit list of files (undefined by default)
  58179. */
  58180. files?: string[] | undefined;
  58181. /**
  58182. * Gets the loaded texture
  58183. */
  58184. texture: CubeTexture;
  58185. /**
  58186. * Callback called when the task is successful
  58187. */
  58188. onSuccess: (task: CubeTextureAssetTask) => void;
  58189. /**
  58190. * Callback called when the task is successful
  58191. */
  58192. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58193. /**
  58194. * Creates a new CubeTextureAssetTask
  58195. * @param name defines the name of the task
  58196. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58197. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58198. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58199. * @param files defines the explicit list of files (undefined by default)
  58200. */
  58201. constructor(
  58202. /**
  58203. * Defines the name of the task
  58204. */
  58205. name: string,
  58206. /**
  58207. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58208. */
  58209. url: string,
  58210. /**
  58211. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58212. */
  58213. extensions?: string[] | undefined,
  58214. /**
  58215. * Defines if mipmaps should not be generated (default is false)
  58216. */
  58217. noMipmap?: boolean | undefined,
  58218. /**
  58219. * Defines the explicit list of files (undefined by default)
  58220. */
  58221. files?: string[] | undefined);
  58222. /**
  58223. * Execute the current task
  58224. * @param scene defines the scene where you want your assets to be loaded
  58225. * @param onSuccess is a callback called when the task is successfully executed
  58226. * @param onError is a callback called if an error occurs
  58227. */
  58228. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58229. }
  58230. /**
  58231. * Define a task used by AssetsManager to load HDR cube textures
  58232. */
  58233. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58234. /**
  58235. * Defines the name of the task
  58236. */
  58237. name: string;
  58238. /**
  58239. * Defines the location of the file to load
  58240. */
  58241. url: string;
  58242. /**
  58243. * Defines the desired size (the more it increases the longer the generation will be)
  58244. */
  58245. size: number;
  58246. /**
  58247. * Defines if mipmaps should not be generated (default is false)
  58248. */
  58249. noMipmap: boolean;
  58250. /**
  58251. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58252. */
  58253. generateHarmonics: boolean;
  58254. /**
  58255. * 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)
  58256. */
  58257. gammaSpace: boolean;
  58258. /**
  58259. * Internal Use Only
  58260. */
  58261. reserved: boolean;
  58262. /**
  58263. * Gets the loaded texture
  58264. */
  58265. texture: HDRCubeTexture;
  58266. /**
  58267. * Callback called when the task is successful
  58268. */
  58269. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58270. /**
  58271. * Callback called when the task is successful
  58272. */
  58273. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58274. /**
  58275. * Creates a new HDRCubeTextureAssetTask object
  58276. * @param name defines the name of the task
  58277. * @param url defines the location of the file to load
  58278. * @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.
  58279. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58280. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58281. * @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)
  58282. * @param reserved Internal use only
  58283. */
  58284. constructor(
  58285. /**
  58286. * Defines the name of the task
  58287. */
  58288. name: string,
  58289. /**
  58290. * Defines the location of the file to load
  58291. */
  58292. url: string,
  58293. /**
  58294. * Defines the desired size (the more it increases the longer the generation will be)
  58295. */
  58296. size: number,
  58297. /**
  58298. * Defines if mipmaps should not be generated (default is false)
  58299. */
  58300. noMipmap?: boolean,
  58301. /**
  58302. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58303. */
  58304. generateHarmonics?: boolean,
  58305. /**
  58306. * 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)
  58307. */
  58308. gammaSpace?: boolean,
  58309. /**
  58310. * Internal Use Only
  58311. */
  58312. reserved?: boolean);
  58313. /**
  58314. * Execute the current task
  58315. * @param scene defines the scene where you want your assets to be loaded
  58316. * @param onSuccess is a callback called when the task is successfully executed
  58317. * @param onError is a callback called if an error occurs
  58318. */
  58319. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58320. }
  58321. /**
  58322. * Define a task used by AssetsManager to load Equirectangular cube textures
  58323. */
  58324. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58325. /**
  58326. * Defines the name of the task
  58327. */
  58328. name: string;
  58329. /**
  58330. * Defines the location of the file to load
  58331. */
  58332. url: string;
  58333. /**
  58334. * Defines the desired size (the more it increases the longer the generation will be)
  58335. */
  58336. size: number;
  58337. /**
  58338. * Defines if mipmaps should not be generated (default is false)
  58339. */
  58340. noMipmap: boolean;
  58341. /**
  58342. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58343. * but the standard material would require them in Gamma space) (default is true)
  58344. */
  58345. gammaSpace: boolean;
  58346. /**
  58347. * Gets the loaded texture
  58348. */
  58349. texture: EquiRectangularCubeTexture;
  58350. /**
  58351. * Callback called when the task is successful
  58352. */
  58353. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58354. /**
  58355. * Callback called when the task is successful
  58356. */
  58357. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58358. /**
  58359. * Creates a new EquiRectangularCubeTextureAssetTask object
  58360. * @param name defines the name of the task
  58361. * @param url defines the location of the file to load
  58362. * @param size defines the desired size (the more it increases the longer the generation will be)
  58363. * If the size is omitted this implies you are using a preprocessed cubemap.
  58364. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58365. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58366. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58367. * (default is true)
  58368. */
  58369. constructor(
  58370. /**
  58371. * Defines the name of the task
  58372. */
  58373. name: string,
  58374. /**
  58375. * Defines the location of the file to load
  58376. */
  58377. url: string,
  58378. /**
  58379. * Defines the desired size (the more it increases the longer the generation will be)
  58380. */
  58381. size: number,
  58382. /**
  58383. * Defines if mipmaps should not be generated (default is false)
  58384. */
  58385. noMipmap?: boolean,
  58386. /**
  58387. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58388. * but the standard material would require them in Gamma space) (default is true)
  58389. */
  58390. gammaSpace?: boolean);
  58391. /**
  58392. * Execute the current task
  58393. * @param scene defines the scene where you want your assets to be loaded
  58394. * @param onSuccess is a callback called when the task is successfully executed
  58395. * @param onError is a callback called if an error occurs
  58396. */
  58397. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58398. }
  58399. /**
  58400. * This class can be used to easily import assets into a scene
  58401. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58402. */
  58403. export class AssetsManager {
  58404. private _scene;
  58405. private _isLoading;
  58406. protected _tasks: AbstractAssetTask[];
  58407. protected _waitingTasksCount: number;
  58408. protected _totalTasksCount: number;
  58409. /**
  58410. * Callback called when all tasks are processed
  58411. */
  58412. onFinish: (tasks: AbstractAssetTask[]) => void;
  58413. /**
  58414. * Callback called when a task is successful
  58415. */
  58416. onTaskSuccess: (task: AbstractAssetTask) => void;
  58417. /**
  58418. * Callback called when a task had an error
  58419. */
  58420. onTaskError: (task: AbstractAssetTask) => void;
  58421. /**
  58422. * Callback called when a task is done (whatever the result is)
  58423. */
  58424. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58425. /**
  58426. * Observable called when all tasks are processed
  58427. */
  58428. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58429. /**
  58430. * Observable called when a task had an error
  58431. */
  58432. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58433. /**
  58434. * Observable called when all tasks were executed
  58435. */
  58436. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58437. /**
  58438. * Observable called when a task is done (whatever the result is)
  58439. */
  58440. onProgressObservable: Observable<IAssetsProgressEvent>;
  58441. /**
  58442. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58443. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58444. */
  58445. useDefaultLoadingScreen: boolean;
  58446. /**
  58447. * Creates a new AssetsManager
  58448. * @param scene defines the scene to work on
  58449. */
  58450. constructor(scene: Scene);
  58451. /**
  58452. * Add a MeshAssetTask to the list of active tasks
  58453. * @param taskName defines the name of the new task
  58454. * @param meshesNames defines the name of meshes to load
  58455. * @param rootUrl defines the root url to use to locate files
  58456. * @param sceneFilename defines the filename of the scene file
  58457. * @returns a new MeshAssetTask object
  58458. */
  58459. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58460. /**
  58461. * Add a TextFileAssetTask to the list of active tasks
  58462. * @param taskName defines the name of the new task
  58463. * @param url defines the url of the file to load
  58464. * @returns a new TextFileAssetTask object
  58465. */
  58466. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58467. /**
  58468. * Add a BinaryFileAssetTask to the list of active tasks
  58469. * @param taskName defines the name of the new task
  58470. * @param url defines the url of the file to load
  58471. * @returns a new BinaryFileAssetTask object
  58472. */
  58473. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58474. /**
  58475. * Add a ImageAssetTask to the list of active tasks
  58476. * @param taskName defines the name of the new task
  58477. * @param url defines the url of the file to load
  58478. * @returns a new ImageAssetTask object
  58479. */
  58480. addImageTask(taskName: string, url: string): ImageAssetTask;
  58481. /**
  58482. * Add a TextureAssetTask to the list of active tasks
  58483. * @param taskName defines the name of the new task
  58484. * @param url defines the url of the file to load
  58485. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58486. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58487. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58488. * @returns a new TextureAssetTask object
  58489. */
  58490. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58491. /**
  58492. * Add a CubeTextureAssetTask to the list of active tasks
  58493. * @param taskName defines the name of the new task
  58494. * @param url defines the url of the file to load
  58495. * @param extensions defines the extension to use to load the cube map (can be null)
  58496. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58497. * @param files defines the list of files to load (can be null)
  58498. * @returns a new CubeTextureAssetTask object
  58499. */
  58500. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58501. /**
  58502. *
  58503. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58504. * @param taskName defines the name of the new task
  58505. * @param url defines the url of the file to load
  58506. * @param size defines the size you want for the cubemap (can be null)
  58507. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58508. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58509. * @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)
  58510. * @param reserved Internal use only
  58511. * @returns a new HDRCubeTextureAssetTask object
  58512. */
  58513. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58514. /**
  58515. *
  58516. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58517. * @param taskName defines the name of the new task
  58518. * @param url defines the url of the file to load
  58519. * @param size defines the size you want for the cubemap (can be null)
  58520. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58521. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58522. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58523. * @returns a new EquiRectangularCubeTextureAssetTask object
  58524. */
  58525. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58526. /**
  58527. * Remove a task from the assets manager.
  58528. * @param task the task to remove
  58529. */
  58530. removeTask(task: AbstractAssetTask): void;
  58531. private _decreaseWaitingTasksCount;
  58532. private _runTask;
  58533. /**
  58534. * Reset the AssetsManager and remove all tasks
  58535. * @return the current instance of the AssetsManager
  58536. */
  58537. reset(): AssetsManager;
  58538. /**
  58539. * Start the loading process
  58540. * @return the current instance of the AssetsManager
  58541. */
  58542. load(): AssetsManager;
  58543. /**
  58544. * Start the loading process as an async operation
  58545. * @return a promise returning the list of failed tasks
  58546. */
  58547. loadAsync(): Promise<void>;
  58548. }
  58549. }
  58550. declare module "babylonjs/Misc/deferred" {
  58551. /**
  58552. * Wrapper class for promise with external resolve and reject.
  58553. */
  58554. export class Deferred<T> {
  58555. /**
  58556. * The promise associated with this deferred object.
  58557. */
  58558. readonly promise: Promise<T>;
  58559. private _resolve;
  58560. private _reject;
  58561. /**
  58562. * The resolve method of the promise associated with this deferred object.
  58563. */
  58564. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58565. /**
  58566. * The reject method of the promise associated with this deferred object.
  58567. */
  58568. readonly reject: (reason?: any) => void;
  58569. /**
  58570. * Constructor for this deferred object.
  58571. */
  58572. constructor();
  58573. }
  58574. }
  58575. declare module "babylonjs/Misc/meshExploder" {
  58576. import { Mesh } from "babylonjs/Meshes/mesh";
  58577. /**
  58578. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58579. */
  58580. export class MeshExploder {
  58581. private _centerMesh;
  58582. private _meshes;
  58583. private _meshesOrigins;
  58584. private _toCenterVectors;
  58585. private _scaledDirection;
  58586. private _newPosition;
  58587. private _centerPosition;
  58588. /**
  58589. * Explodes meshes from a center mesh.
  58590. * @param meshes The meshes to explode.
  58591. * @param centerMesh The mesh to be center of explosion.
  58592. */
  58593. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58594. private _setCenterMesh;
  58595. /**
  58596. * Get class name
  58597. * @returns "MeshExploder"
  58598. */
  58599. getClassName(): string;
  58600. /**
  58601. * "Exploded meshes"
  58602. * @returns Array of meshes with the centerMesh at index 0.
  58603. */
  58604. getMeshes(): Array<Mesh>;
  58605. /**
  58606. * Explodes meshes giving a specific direction
  58607. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58608. */
  58609. explode(direction?: number): void;
  58610. }
  58611. }
  58612. declare module "babylonjs/Misc/filesInput" {
  58613. import { Engine } from "babylonjs/Engines/engine";
  58614. import { Scene } from "babylonjs/scene";
  58615. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58616. /**
  58617. * Class used to help managing file picking and drag'n'drop
  58618. */
  58619. export class FilesInput {
  58620. /**
  58621. * List of files ready to be loaded
  58622. */
  58623. static readonly FilesToLoad: {
  58624. [key: string]: File;
  58625. };
  58626. /**
  58627. * Callback called when a file is processed
  58628. */
  58629. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58630. private _engine;
  58631. private _currentScene;
  58632. private _sceneLoadedCallback;
  58633. private _progressCallback;
  58634. private _additionalRenderLoopLogicCallback;
  58635. private _textureLoadingCallback;
  58636. private _startingProcessingFilesCallback;
  58637. private _onReloadCallback;
  58638. private _errorCallback;
  58639. private _elementToMonitor;
  58640. private _sceneFileToLoad;
  58641. private _filesToLoad;
  58642. /**
  58643. * Creates a new FilesInput
  58644. * @param engine defines the rendering engine
  58645. * @param scene defines the hosting scene
  58646. * @param sceneLoadedCallback callback called when scene is loaded
  58647. * @param progressCallback callback called to track progress
  58648. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58649. * @param textureLoadingCallback callback called when a texture is loading
  58650. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58651. * @param onReloadCallback callback called when a reload is requested
  58652. * @param errorCallback callback call if an error occurs
  58653. */
  58654. 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);
  58655. private _dragEnterHandler;
  58656. private _dragOverHandler;
  58657. private _dropHandler;
  58658. /**
  58659. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58660. * @param elementToMonitor defines the DOM element to track
  58661. */
  58662. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58663. /**
  58664. * Release all associated resources
  58665. */
  58666. dispose(): void;
  58667. private renderFunction;
  58668. private drag;
  58669. private drop;
  58670. private _traverseFolder;
  58671. private _processFiles;
  58672. /**
  58673. * Load files from a drop event
  58674. * @param event defines the drop event to use as source
  58675. */
  58676. loadFiles(event: any): void;
  58677. private _processReload;
  58678. /**
  58679. * Reload the current scene from the loaded files
  58680. */
  58681. reload(): void;
  58682. }
  58683. }
  58684. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58685. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58686. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58687. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58688. }
  58689. declare module "babylonjs/Misc/sceneOptimizer" {
  58690. import { Scene, IDisposable } from "babylonjs/scene";
  58691. import { Observable } from "babylonjs/Misc/observable";
  58692. /**
  58693. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58694. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58695. */
  58696. export class SceneOptimization {
  58697. /**
  58698. * Defines the priority of this optimization (0 by default which means first in the list)
  58699. */
  58700. priority: number;
  58701. /**
  58702. * Gets a string describing the action executed by the current optimization
  58703. * @returns description string
  58704. */
  58705. getDescription(): string;
  58706. /**
  58707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58708. * @param scene defines the current scene where to apply this optimization
  58709. * @param optimizer defines the current optimizer
  58710. * @returns true if everything that can be done was applied
  58711. */
  58712. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58713. /**
  58714. * Creates the SceneOptimization object
  58715. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58716. * @param desc defines the description associated with the optimization
  58717. */
  58718. constructor(
  58719. /**
  58720. * Defines the priority of this optimization (0 by default which means first in the list)
  58721. */
  58722. priority?: number);
  58723. }
  58724. /**
  58725. * Defines an optimization used to reduce the size of render target textures
  58726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58727. */
  58728. export class TextureOptimization extends SceneOptimization {
  58729. /**
  58730. * Defines the priority of this optimization (0 by default which means first in the list)
  58731. */
  58732. priority: number;
  58733. /**
  58734. * 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
  58735. */
  58736. maximumSize: number;
  58737. /**
  58738. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58739. */
  58740. step: number;
  58741. /**
  58742. * Gets a string describing the action executed by the current optimization
  58743. * @returns description string
  58744. */
  58745. getDescription(): string;
  58746. /**
  58747. * Creates the TextureOptimization object
  58748. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58749. * @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
  58750. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58751. */
  58752. constructor(
  58753. /**
  58754. * Defines the priority of this optimization (0 by default which means first in the list)
  58755. */
  58756. priority?: number,
  58757. /**
  58758. * 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
  58759. */
  58760. maximumSize?: number,
  58761. /**
  58762. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58763. */
  58764. step?: number);
  58765. /**
  58766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58767. * @param scene defines the current scene where to apply this optimization
  58768. * @param optimizer defines the current optimizer
  58769. * @returns true if everything that can be done was applied
  58770. */
  58771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58772. }
  58773. /**
  58774. * Defines an optimization used to increase or decrease the rendering resolution
  58775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58776. */
  58777. export class HardwareScalingOptimization extends SceneOptimization {
  58778. /**
  58779. * Defines the priority of this optimization (0 by default which means first in the list)
  58780. */
  58781. priority: number;
  58782. /**
  58783. * Defines the maximum scale to use (2 by default)
  58784. */
  58785. maximumScale: number;
  58786. /**
  58787. * Defines the step to use between two passes (0.5 by default)
  58788. */
  58789. step: number;
  58790. private _currentScale;
  58791. private _directionOffset;
  58792. /**
  58793. * Gets a string describing the action executed by the current optimization
  58794. * @return description string
  58795. */
  58796. getDescription(): string;
  58797. /**
  58798. * Creates the HardwareScalingOptimization object
  58799. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58800. * @param maximumScale defines the maximum scale to use (2 by default)
  58801. * @param step defines the step to use between two passes (0.5 by default)
  58802. */
  58803. constructor(
  58804. /**
  58805. * Defines the priority of this optimization (0 by default which means first in the list)
  58806. */
  58807. priority?: number,
  58808. /**
  58809. * Defines the maximum scale to use (2 by default)
  58810. */
  58811. maximumScale?: number,
  58812. /**
  58813. * Defines the step to use between two passes (0.5 by default)
  58814. */
  58815. step?: number);
  58816. /**
  58817. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58818. * @param scene defines the current scene where to apply this optimization
  58819. * @param optimizer defines the current optimizer
  58820. * @returns true if everything that can be done was applied
  58821. */
  58822. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58823. }
  58824. /**
  58825. * Defines an optimization used to remove shadows
  58826. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58827. */
  58828. export class ShadowsOptimization extends SceneOptimization {
  58829. /**
  58830. * Gets a string describing the action executed by the current optimization
  58831. * @return description string
  58832. */
  58833. getDescription(): string;
  58834. /**
  58835. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58836. * @param scene defines the current scene where to apply this optimization
  58837. * @param optimizer defines the current optimizer
  58838. * @returns true if everything that can be done was applied
  58839. */
  58840. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58841. }
  58842. /**
  58843. * Defines an optimization used to turn post-processes off
  58844. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58845. */
  58846. export class PostProcessesOptimization extends SceneOptimization {
  58847. /**
  58848. * Gets a string describing the action executed by the current optimization
  58849. * @return description string
  58850. */
  58851. getDescription(): string;
  58852. /**
  58853. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58854. * @param scene defines the current scene where to apply this optimization
  58855. * @param optimizer defines the current optimizer
  58856. * @returns true if everything that can be done was applied
  58857. */
  58858. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58859. }
  58860. /**
  58861. * Defines an optimization used to turn lens flares off
  58862. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58863. */
  58864. export class LensFlaresOptimization extends SceneOptimization {
  58865. /**
  58866. * Gets a string describing the action executed by the current optimization
  58867. * @return description string
  58868. */
  58869. getDescription(): string;
  58870. /**
  58871. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58872. * @param scene defines the current scene where to apply this optimization
  58873. * @param optimizer defines the current optimizer
  58874. * @returns true if everything that can be done was applied
  58875. */
  58876. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58877. }
  58878. /**
  58879. * Defines an optimization based on user defined callback.
  58880. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58881. */
  58882. export class CustomOptimization extends SceneOptimization {
  58883. /**
  58884. * Callback called to apply the custom optimization.
  58885. */
  58886. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58887. /**
  58888. * Callback called to get custom description
  58889. */
  58890. onGetDescription: () => string;
  58891. /**
  58892. * Gets a string describing the action executed by the current optimization
  58893. * @returns description string
  58894. */
  58895. getDescription(): string;
  58896. /**
  58897. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58898. * @param scene defines the current scene where to apply this optimization
  58899. * @param optimizer defines the current optimizer
  58900. * @returns true if everything that can be done was applied
  58901. */
  58902. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58903. }
  58904. /**
  58905. * Defines an optimization used to turn particles off
  58906. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58907. */
  58908. export class ParticlesOptimization extends SceneOptimization {
  58909. /**
  58910. * Gets a string describing the action executed by the current optimization
  58911. * @return description string
  58912. */
  58913. getDescription(): string;
  58914. /**
  58915. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58916. * @param scene defines the current scene where to apply this optimization
  58917. * @param optimizer defines the current optimizer
  58918. * @returns true if everything that can be done was applied
  58919. */
  58920. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58921. }
  58922. /**
  58923. * Defines an optimization used to turn render targets off
  58924. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58925. */
  58926. export class RenderTargetsOptimization extends SceneOptimization {
  58927. /**
  58928. * Gets a string describing the action executed by the current optimization
  58929. * @return description string
  58930. */
  58931. getDescription(): string;
  58932. /**
  58933. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58934. * @param scene defines the current scene where to apply this optimization
  58935. * @param optimizer defines the current optimizer
  58936. * @returns true if everything that can be done was applied
  58937. */
  58938. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58939. }
  58940. /**
  58941. * Defines an optimization used to merge meshes with compatible materials
  58942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58943. */
  58944. export class MergeMeshesOptimization extends SceneOptimization {
  58945. private static _UpdateSelectionTree;
  58946. /**
  58947. * Gets or sets a boolean which defines if optimization octree has to be updated
  58948. */
  58949. /**
  58950. * Gets or sets a boolean which defines if optimization octree has to be updated
  58951. */
  58952. static UpdateSelectionTree: boolean;
  58953. /**
  58954. * Gets a string describing the action executed by the current optimization
  58955. * @return description string
  58956. */
  58957. getDescription(): string;
  58958. private _canBeMerged;
  58959. /**
  58960. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58961. * @param scene defines the current scene where to apply this optimization
  58962. * @param optimizer defines the current optimizer
  58963. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58964. * @returns true if everything that can be done was applied
  58965. */
  58966. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58967. }
  58968. /**
  58969. * Defines a list of options used by SceneOptimizer
  58970. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58971. */
  58972. export class SceneOptimizerOptions {
  58973. /**
  58974. * Defines the target frame rate to reach (60 by default)
  58975. */
  58976. targetFrameRate: number;
  58977. /**
  58978. * Defines the interval between two checkes (2000ms by default)
  58979. */
  58980. trackerDuration: number;
  58981. /**
  58982. * Gets the list of optimizations to apply
  58983. */
  58984. optimizations: SceneOptimization[];
  58985. /**
  58986. * Creates a new list of options used by SceneOptimizer
  58987. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58988. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58989. */
  58990. constructor(
  58991. /**
  58992. * Defines the target frame rate to reach (60 by default)
  58993. */
  58994. targetFrameRate?: number,
  58995. /**
  58996. * Defines the interval between two checkes (2000ms by default)
  58997. */
  58998. trackerDuration?: number);
  58999. /**
  59000. * Add a new optimization
  59001. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59002. * @returns the current SceneOptimizerOptions
  59003. */
  59004. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59005. /**
  59006. * Add a new custom optimization
  59007. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59008. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59009. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59010. * @returns the current SceneOptimizerOptions
  59011. */
  59012. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59013. /**
  59014. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59015. * @param targetFrameRate defines the target frame rate (60 by default)
  59016. * @returns a SceneOptimizerOptions object
  59017. */
  59018. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59019. /**
  59020. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59021. * @param targetFrameRate defines the target frame rate (60 by default)
  59022. * @returns a SceneOptimizerOptions object
  59023. */
  59024. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59025. /**
  59026. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59027. * @param targetFrameRate defines the target frame rate (60 by default)
  59028. * @returns a SceneOptimizerOptions object
  59029. */
  59030. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59031. }
  59032. /**
  59033. * Class used to run optimizations in order to reach a target frame rate
  59034. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59035. */
  59036. export class SceneOptimizer implements IDisposable {
  59037. private _isRunning;
  59038. private _options;
  59039. private _scene;
  59040. private _currentPriorityLevel;
  59041. private _targetFrameRate;
  59042. private _trackerDuration;
  59043. private _currentFrameRate;
  59044. private _sceneDisposeObserver;
  59045. private _improvementMode;
  59046. /**
  59047. * Defines an observable called when the optimizer reaches the target frame rate
  59048. */
  59049. onSuccessObservable: Observable<SceneOptimizer>;
  59050. /**
  59051. * Defines an observable called when the optimizer enables an optimization
  59052. */
  59053. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59054. /**
  59055. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59056. */
  59057. onFailureObservable: Observable<SceneOptimizer>;
  59058. /**
  59059. * Gets a boolean indicating if the optimizer is in improvement mode
  59060. */
  59061. readonly isInImprovementMode: boolean;
  59062. /**
  59063. * Gets the current priority level (0 at start)
  59064. */
  59065. readonly currentPriorityLevel: number;
  59066. /**
  59067. * Gets the current frame rate checked by the SceneOptimizer
  59068. */
  59069. readonly currentFrameRate: number;
  59070. /**
  59071. * Gets or sets the current target frame rate (60 by default)
  59072. */
  59073. /**
  59074. * Gets or sets the current target frame rate (60 by default)
  59075. */
  59076. targetFrameRate: number;
  59077. /**
  59078. * Gets or sets the current interval between two checks (every 2000ms by default)
  59079. */
  59080. /**
  59081. * Gets or sets the current interval between two checks (every 2000ms by default)
  59082. */
  59083. trackerDuration: number;
  59084. /**
  59085. * Gets the list of active optimizations
  59086. */
  59087. readonly optimizations: SceneOptimization[];
  59088. /**
  59089. * Creates a new SceneOptimizer
  59090. * @param scene defines the scene to work on
  59091. * @param options defines the options to use with the SceneOptimizer
  59092. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59093. * @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)
  59094. */
  59095. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59096. /**
  59097. * Stops the current optimizer
  59098. */
  59099. stop(): void;
  59100. /**
  59101. * Reset the optimizer to initial step (current priority level = 0)
  59102. */
  59103. reset(): void;
  59104. /**
  59105. * Start the optimizer. By default it will try to reach a specific framerate
  59106. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59107. */
  59108. start(): void;
  59109. private _checkCurrentState;
  59110. /**
  59111. * Release all resources
  59112. */
  59113. dispose(): void;
  59114. /**
  59115. * Helper function to create a SceneOptimizer with one single line of code
  59116. * @param scene defines the scene to work on
  59117. * @param options defines the options to use with the SceneOptimizer
  59118. * @param onSuccess defines a callback to call on success
  59119. * @param onFailure defines a callback to call on failure
  59120. * @returns the new SceneOptimizer object
  59121. */
  59122. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59123. }
  59124. }
  59125. declare module "babylonjs/Misc/sceneSerializer" {
  59126. import { Scene } from "babylonjs/scene";
  59127. /**
  59128. * Class used to serialize a scene into a string
  59129. */
  59130. export class SceneSerializer {
  59131. /**
  59132. * Clear cache used by a previous serialization
  59133. */
  59134. static ClearCache(): void;
  59135. /**
  59136. * Serialize a scene into a JSON compatible object
  59137. * @param scene defines the scene to serialize
  59138. * @returns a JSON compatible object
  59139. */
  59140. static Serialize(scene: Scene): any;
  59141. /**
  59142. * Serialize a mesh into a JSON compatible object
  59143. * @param toSerialize defines the mesh to serialize
  59144. * @param withParents defines if parents must be serialized as well
  59145. * @param withChildren defines if children must be serialized as well
  59146. * @returns a JSON compatible object
  59147. */
  59148. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59149. }
  59150. }
  59151. declare module "babylonjs/Misc/textureTools" {
  59152. import { Texture } from "babylonjs/Materials/Textures/texture";
  59153. /**
  59154. * Class used to host texture specific utilities
  59155. */
  59156. export class TextureTools {
  59157. /**
  59158. * Uses the GPU to create a copy texture rescaled at a given size
  59159. * @param texture Texture to copy from
  59160. * @param width defines the desired width
  59161. * @param height defines the desired height
  59162. * @param useBilinearMode defines if bilinear mode has to be used
  59163. * @return the generated texture
  59164. */
  59165. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59166. }
  59167. }
  59168. declare module "babylonjs/Misc/videoRecorder" {
  59169. import { Nullable } from "babylonjs/types";
  59170. import { Engine } from "babylonjs/Engines/engine";
  59171. /**
  59172. * This represents the different options avilable for the video capture.
  59173. */
  59174. export interface VideoRecorderOptions {
  59175. /** Defines the mime type of the video */
  59176. mimeType: string;
  59177. /** Defines the video the video should be recorded at */
  59178. fps: number;
  59179. /** Defines the chunk size for the recording data */
  59180. recordChunckSize: number;
  59181. /** The audio tracks to attach to the record */
  59182. audioTracks?: MediaStreamTrack[];
  59183. }
  59184. /**
  59185. * This can helps recording videos from BabylonJS.
  59186. * This is based on the available WebRTC functionalities of the browser.
  59187. *
  59188. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59189. */
  59190. export class VideoRecorder {
  59191. private static readonly _defaultOptions;
  59192. /**
  59193. * Returns wehther or not the VideoRecorder is available in your browser.
  59194. * @param engine Defines the Babylon Engine to check the support for
  59195. * @returns true if supported otherwise false
  59196. */
  59197. static IsSupported(engine: Engine): boolean;
  59198. private readonly _options;
  59199. private _canvas;
  59200. private _mediaRecorder;
  59201. private _recordedChunks;
  59202. private _fileName;
  59203. private _resolve;
  59204. private _reject;
  59205. /**
  59206. * True wether a recording is already in progress.
  59207. */
  59208. readonly isRecording: boolean;
  59209. /**
  59210. * Create a new VideoCapture object which can help converting what you see in Babylon to
  59211. * a video file.
  59212. * @param engine Defines the BabylonJS Engine you wish to record
  59213. * @param options Defines options that can be used to customized the capture
  59214. */
  59215. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59216. /**
  59217. * Stops the current recording before the default capture timeout passed in the startRecording
  59218. * functions.
  59219. */
  59220. stopRecording(): void;
  59221. /**
  59222. * Starts recording the canvas for a max duration specified in parameters.
  59223. * @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.
  59224. * @param maxDuration Defines the maximum recording time in seconds.
  59225. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59226. * @return a promise callback at the end of the recording with the video data in Blob.
  59227. */
  59228. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59229. /**
  59230. * Releases internal resources used during the recording.
  59231. */
  59232. dispose(): void;
  59233. private _handleDataAvailable;
  59234. private _handleError;
  59235. private _handleStop;
  59236. }
  59237. }
  59238. declare module "babylonjs/Misc/screenshotTools" {
  59239. import { Camera } from "babylonjs/Cameras/camera";
  59240. import { Engine } from "babylonjs/Engines/engine";
  59241. /**
  59242. * Class containing a set of static utilities functions for screenshots
  59243. */
  59244. export class ScreenshotTools {
  59245. /**
  59246. * Captures a screenshot of the current rendering
  59247. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59248. * @param engine defines the rendering engine
  59249. * @param camera defines the source camera
  59250. * @param size This parameter can be set to a single number or to an object with the
  59251. * following (optional) properties: precision, width, height. If a single number is passed,
  59252. * it will be used for both width and height. If an object is passed, the screenshot size
  59253. * will be derived from the parameters. The precision property is a multiplier allowing
  59254. * rendering at a higher or lower resolution
  59255. * @param successCallback defines the callback receives a single parameter which contains the
  59256. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59257. * src parameter of an <img> to display it
  59258. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59259. * Check your browser for supported MIME types
  59260. */
  59261. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59262. /**
  59263. * Generates an image screenshot from the specified camera.
  59264. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59265. * @param engine The engine to use for rendering
  59266. * @param camera The camera to use for rendering
  59267. * @param size This parameter can be set to a single number or to an object with the
  59268. * following (optional) properties: precision, width, height. If a single number is passed,
  59269. * it will be used for both width and height. If an object is passed, the screenshot size
  59270. * will be derived from the parameters. The precision property is a multiplier allowing
  59271. * rendering at a higher or lower resolution
  59272. * @param successCallback The callback receives a single parameter which contains the
  59273. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59274. * src parameter of an <img> to display it
  59275. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59276. * Check your browser for supported MIME types
  59277. * @param samples Texture samples (default: 1)
  59278. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59279. * @param fileName A name for for the downloaded file.
  59280. */
  59281. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59282. }
  59283. }
  59284. declare module "babylonjs/Misc/index" {
  59285. export * from "babylonjs/Misc/andOrNotEvaluator";
  59286. export * from "babylonjs/Misc/assetsManager";
  59287. export * from "babylonjs/Misc/dds";
  59288. export * from "babylonjs/Misc/decorators";
  59289. export * from "babylonjs/Misc/deferred";
  59290. export * from "babylonjs/Misc/environmentTextureTools";
  59291. export * from "babylonjs/Misc/meshExploder";
  59292. export * from "babylonjs/Misc/filesInput";
  59293. export * from "babylonjs/Misc/HighDynamicRange/index";
  59294. export * from "babylonjs/Misc/khronosTextureContainer";
  59295. export * from "babylonjs/Misc/observable";
  59296. export * from "babylonjs/Misc/performanceMonitor";
  59297. export * from "babylonjs/Misc/promise";
  59298. export * from "babylonjs/Misc/sceneOptimizer";
  59299. export * from "babylonjs/Misc/sceneSerializer";
  59300. export * from "babylonjs/Misc/smartArray";
  59301. export * from "babylonjs/Misc/stringDictionary";
  59302. export * from "babylonjs/Misc/tags";
  59303. export * from "babylonjs/Misc/textureTools";
  59304. export * from "babylonjs/Misc/tga";
  59305. export * from "babylonjs/Misc/tools";
  59306. export * from "babylonjs/Misc/videoRecorder";
  59307. export * from "babylonjs/Misc/virtualJoystick";
  59308. export * from "babylonjs/Misc/workerPool";
  59309. export * from "babylonjs/Misc/logger";
  59310. export * from "babylonjs/Misc/typeStore";
  59311. export * from "babylonjs/Misc/filesInputStore";
  59312. export * from "babylonjs/Misc/deepCopier";
  59313. export * from "babylonjs/Misc/pivotTools";
  59314. export * from "babylonjs/Misc/precisionDate";
  59315. export * from "babylonjs/Misc/screenshotTools";
  59316. export * from "babylonjs/Misc/typeStore";
  59317. export * from "babylonjs/Misc/webRequest";
  59318. export * from "babylonjs/Misc/iInspectable";
  59319. }
  59320. declare module "babylonjs/index" {
  59321. export * from "babylonjs/abstractScene";
  59322. export * from "babylonjs/Actions/index";
  59323. export * from "babylonjs/Animations/index";
  59324. export * from "babylonjs/assetContainer";
  59325. export * from "babylonjs/Audio/index";
  59326. export * from "babylonjs/Behaviors/index";
  59327. export * from "babylonjs/Bones/index";
  59328. export * from "babylonjs/Cameras/index";
  59329. export * from "babylonjs/Collisions/index";
  59330. export * from "babylonjs/Culling/index";
  59331. export * from "babylonjs/Debug/index";
  59332. export * from "babylonjs/Engines/index";
  59333. export * from "babylonjs/Events/index";
  59334. export * from "babylonjs/Gamepads/index";
  59335. export * from "babylonjs/Gizmos/index";
  59336. export * from "babylonjs/Helpers/index";
  59337. export * from "babylonjs/Instrumentation/index";
  59338. export * from "babylonjs/Layers/index";
  59339. export * from "babylonjs/LensFlares/index";
  59340. export * from "babylonjs/Lights/index";
  59341. export * from "babylonjs/Loading/index";
  59342. export * from "babylonjs/Materials/index";
  59343. export * from "babylonjs/Maths/index";
  59344. export * from "babylonjs/Meshes/index";
  59345. export * from "babylonjs/Morph/index";
  59346. export * from "babylonjs/node";
  59347. export * from "babylonjs/Offline/index";
  59348. export * from "babylonjs/Particles/index";
  59349. export * from "babylonjs/Physics/index";
  59350. export * from "babylonjs/PostProcesses/index";
  59351. export * from "babylonjs/Probes/index";
  59352. export * from "babylonjs/Rendering/index";
  59353. export * from "babylonjs/scene";
  59354. export * from "babylonjs/sceneComponent";
  59355. export * from "babylonjs/Sprites/index";
  59356. export * from "babylonjs/States/index";
  59357. export * from "babylonjs/Misc/index";
  59358. export * from "babylonjs/types";
  59359. }
  59360. declare module "babylonjs/Animations/pathCursor" {
  59361. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59362. /**
  59363. * A cursor which tracks a point on a path
  59364. */
  59365. export class PathCursor {
  59366. private path;
  59367. /**
  59368. * Stores path cursor callbacks for when an onchange event is triggered
  59369. */
  59370. private _onchange;
  59371. /**
  59372. * The value of the path cursor
  59373. */
  59374. value: number;
  59375. /**
  59376. * The animation array of the path cursor
  59377. */
  59378. animations: Animation[];
  59379. /**
  59380. * Initializes the path cursor
  59381. * @param path The path to track
  59382. */
  59383. constructor(path: Path2);
  59384. /**
  59385. * Gets the cursor point on the path
  59386. * @returns A point on the path cursor at the cursor location
  59387. */
  59388. getPoint(): Vector3;
  59389. /**
  59390. * Moves the cursor ahead by the step amount
  59391. * @param step The amount to move the cursor forward
  59392. * @returns This path cursor
  59393. */
  59394. moveAhead(step?: number): PathCursor;
  59395. /**
  59396. * Moves the cursor behind by the step amount
  59397. * @param step The amount to move the cursor back
  59398. * @returns This path cursor
  59399. */
  59400. moveBack(step?: number): PathCursor;
  59401. /**
  59402. * Moves the cursor by the step amount
  59403. * If the step amount is greater than one, an exception is thrown
  59404. * @param step The amount to move the cursor
  59405. * @returns This path cursor
  59406. */
  59407. move(step: number): PathCursor;
  59408. /**
  59409. * Ensures that the value is limited between zero and one
  59410. * @returns This path cursor
  59411. */
  59412. private ensureLimits;
  59413. /**
  59414. * Runs onchange callbacks on change (used by the animation engine)
  59415. * @returns This path cursor
  59416. */
  59417. private raiseOnChange;
  59418. /**
  59419. * Executes a function on change
  59420. * @param f A path cursor onchange callback
  59421. * @returns This path cursor
  59422. */
  59423. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59424. }
  59425. }
  59426. declare module "babylonjs/Legacy/legacy" {
  59427. import * as Babylon from "babylonjs/index";
  59428. export * from "babylonjs/index";
  59429. }
  59430. declare module "babylonjs/Shaders/blur.fragment" {
  59431. /** @hidden */
  59432. export var blurPixelShader: {
  59433. name: string;
  59434. shader: string;
  59435. };
  59436. }
  59437. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59438. /** @hidden */
  59439. export var bones300Declaration: {
  59440. name: string;
  59441. shader: string;
  59442. };
  59443. }
  59444. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59445. /** @hidden */
  59446. export var instances300Declaration: {
  59447. name: string;
  59448. shader: string;
  59449. };
  59450. }
  59451. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59452. /** @hidden */
  59453. export var pointCloudVertexDeclaration: {
  59454. name: string;
  59455. shader: string;
  59456. };
  59457. }
  59458. // Mixins
  59459. interface Window {
  59460. mozIndexedDB: IDBFactory;
  59461. webkitIndexedDB: IDBFactory;
  59462. msIndexedDB: IDBFactory;
  59463. webkitURL: typeof URL;
  59464. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59465. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59466. WebGLRenderingContext: WebGLRenderingContext;
  59467. MSGesture: MSGesture;
  59468. CANNON: any;
  59469. AudioContext: AudioContext;
  59470. webkitAudioContext: AudioContext;
  59471. PointerEvent: any;
  59472. Math: Math;
  59473. Uint8Array: Uint8ArrayConstructor;
  59474. Float32Array: Float32ArrayConstructor;
  59475. mozURL: typeof URL;
  59476. msURL: typeof URL;
  59477. VRFrameData: any; // WebVR, from specs 1.1
  59478. DracoDecoderModule: any;
  59479. setImmediate(handler: (...args: any[]) => void): number;
  59480. }
  59481. interface HTMLCanvasElement {
  59482. requestPointerLock(): void;
  59483. msRequestPointerLock?(): void;
  59484. mozRequestPointerLock?(): void;
  59485. webkitRequestPointerLock?(): void;
  59486. /** Track wether a record is in progress */
  59487. isRecording: boolean;
  59488. /** Capture Stream method defined by some browsers */
  59489. captureStream(fps?: number): MediaStream;
  59490. }
  59491. interface CanvasRenderingContext2D {
  59492. msImageSmoothingEnabled: boolean;
  59493. }
  59494. interface MouseEvent {
  59495. mozMovementX: number;
  59496. mozMovementY: number;
  59497. webkitMovementX: number;
  59498. webkitMovementY: number;
  59499. msMovementX: number;
  59500. msMovementY: number;
  59501. }
  59502. interface Navigator {
  59503. mozGetVRDevices: (any: any) => any;
  59504. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59505. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59506. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59507. webkitGetGamepads(): Gamepad[];
  59508. msGetGamepads(): Gamepad[];
  59509. webkitGamepads(): Gamepad[];
  59510. }
  59511. interface HTMLVideoElement {
  59512. mozSrcObject: any;
  59513. }
  59514. interface Math {
  59515. fround(x: number): number;
  59516. imul(a: number, b: number): number;
  59517. }
  59518. interface WebGLRenderingContext {
  59519. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59520. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59521. vertexAttribDivisor(index: number, divisor: number): void;
  59522. createVertexArray(): any;
  59523. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59524. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59525. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59526. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59527. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59528. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59529. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59530. // Queries
  59531. createQuery(): WebGLQuery;
  59532. deleteQuery(query: WebGLQuery): void;
  59533. beginQuery(target: number, query: WebGLQuery): void;
  59534. endQuery(target: number): void;
  59535. getQueryParameter(query: WebGLQuery, pname: number): any;
  59536. getQuery(target: number, pname: number): any;
  59537. MAX_SAMPLES: number;
  59538. RGBA8: number;
  59539. READ_FRAMEBUFFER: number;
  59540. DRAW_FRAMEBUFFER: number;
  59541. UNIFORM_BUFFER: number;
  59542. HALF_FLOAT_OES: number;
  59543. RGBA16F: number;
  59544. RGBA32F: number;
  59545. R32F: number;
  59546. RG32F: number;
  59547. RGB32F: number;
  59548. R16F: number;
  59549. RG16F: number;
  59550. RGB16F: number;
  59551. RED: number;
  59552. RG: number;
  59553. R8: number;
  59554. RG8: number;
  59555. UNSIGNED_INT_24_8: number;
  59556. DEPTH24_STENCIL8: number;
  59557. /* Multiple Render Targets */
  59558. drawBuffers(buffers: number[]): void;
  59559. readBuffer(src: number): void;
  59560. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59561. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59562. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59563. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59564. // Occlusion Query
  59565. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59566. ANY_SAMPLES_PASSED: number;
  59567. QUERY_RESULT_AVAILABLE: number;
  59568. QUERY_RESULT: number;
  59569. }
  59570. interface WebGLProgram {
  59571. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59572. }
  59573. interface EXT_disjoint_timer_query {
  59574. QUERY_COUNTER_BITS_EXT: number;
  59575. TIME_ELAPSED_EXT: number;
  59576. TIMESTAMP_EXT: number;
  59577. GPU_DISJOINT_EXT: number;
  59578. QUERY_RESULT_EXT: number;
  59579. QUERY_RESULT_AVAILABLE_EXT: number;
  59580. queryCounterEXT(query: WebGLQuery, target: number): void;
  59581. createQueryEXT(): WebGLQuery;
  59582. beginQueryEXT(target: number, query: WebGLQuery): void;
  59583. endQueryEXT(target: number): void;
  59584. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59585. deleteQueryEXT(query: WebGLQuery): void;
  59586. }
  59587. interface WebGLUniformLocation {
  59588. _currentState: any;
  59589. }
  59590. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59591. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59592. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59593. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59594. interface WebGLRenderingContext {
  59595. readonly RASTERIZER_DISCARD: number;
  59596. readonly DEPTH_COMPONENT24: number;
  59597. readonly TEXTURE_3D: number;
  59598. readonly TEXTURE_2D_ARRAY: number;
  59599. readonly TEXTURE_COMPARE_FUNC: number;
  59600. readonly TEXTURE_COMPARE_MODE: number;
  59601. readonly COMPARE_REF_TO_TEXTURE: number;
  59602. readonly TEXTURE_WRAP_R: number;
  59603. readonly HALF_FLOAT: number;
  59604. readonly RGB8: number;
  59605. readonly RED_INTEGER: number;
  59606. readonly RG_INTEGER: number;
  59607. readonly RGB_INTEGER: number;
  59608. readonly RGBA_INTEGER: number;
  59609. readonly R8_SNORM: number;
  59610. readonly RG8_SNORM: number;
  59611. readonly RGB8_SNORM: number;
  59612. readonly RGBA8_SNORM: number;
  59613. readonly R8I: number;
  59614. readonly RG8I: number;
  59615. readonly RGB8I: number;
  59616. readonly RGBA8I: number;
  59617. readonly R8UI: number;
  59618. readonly RG8UI: number;
  59619. readonly RGB8UI: number;
  59620. readonly RGBA8UI: number;
  59621. readonly R16I: number;
  59622. readonly RG16I: number;
  59623. readonly RGB16I: number;
  59624. readonly RGBA16I: number;
  59625. readonly R16UI: number;
  59626. readonly RG16UI: number;
  59627. readonly RGB16UI: number;
  59628. readonly RGBA16UI: number;
  59629. readonly R32I: number;
  59630. readonly RG32I: number;
  59631. readonly RGB32I: number;
  59632. readonly RGBA32I: number;
  59633. readonly R32UI: number;
  59634. readonly RG32UI: number;
  59635. readonly RGB32UI: number;
  59636. readonly RGBA32UI: number;
  59637. readonly RGB10_A2UI: number;
  59638. readonly R11F_G11F_B10F: number;
  59639. readonly RGB9_E5: number;
  59640. readonly RGB10_A2: number;
  59641. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59642. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59643. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59644. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59645. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59646. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59647. 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;
  59648. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59649. readonly TRANSFORM_FEEDBACK: number;
  59650. readonly INTERLEAVED_ATTRIBS: number;
  59651. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59652. createTransformFeedback(): WebGLTransformFeedback;
  59653. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59654. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59655. beginTransformFeedback(primitiveMode: number): void;
  59656. endTransformFeedback(): void;
  59657. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59658. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59659. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59660. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59661. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59662. }
  59663. interface ImageBitmap {
  59664. readonly width: number;
  59665. readonly height: number;
  59666. close(): void;
  59667. }
  59668. interface WebGLQuery extends WebGLObject {
  59669. }
  59670. declare var WebGLQuery: {
  59671. prototype: WebGLQuery;
  59672. new(): WebGLQuery;
  59673. };
  59674. interface WebGLSampler extends WebGLObject {
  59675. }
  59676. declare var WebGLSampler: {
  59677. prototype: WebGLSampler;
  59678. new(): WebGLSampler;
  59679. };
  59680. interface WebGLSync extends WebGLObject {
  59681. }
  59682. declare var WebGLSync: {
  59683. prototype: WebGLSync;
  59684. new(): WebGLSync;
  59685. };
  59686. interface WebGLTransformFeedback extends WebGLObject {
  59687. }
  59688. declare var WebGLTransformFeedback: {
  59689. prototype: WebGLTransformFeedback;
  59690. new(): WebGLTransformFeedback;
  59691. };
  59692. interface WebGLVertexArrayObject extends WebGLObject {
  59693. }
  59694. declare var WebGLVertexArrayObject: {
  59695. prototype: WebGLVertexArrayObject;
  59696. new(): WebGLVertexArrayObject;
  59697. };
  59698. // Type definitions for WebVR API
  59699. // Project: https://w3c.github.io/webvr/
  59700. // Definitions by: six a <https://github.com/lostfictions>
  59701. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59702. interface VRDisplay extends EventTarget {
  59703. /**
  59704. * Dictionary of capabilities describing the VRDisplay.
  59705. */
  59706. readonly capabilities: VRDisplayCapabilities;
  59707. /**
  59708. * z-depth defining the far plane of the eye view frustum
  59709. * enables mapping of values in the render target depth
  59710. * attachment to scene coordinates. Initially set to 10000.0.
  59711. */
  59712. depthFar: number;
  59713. /**
  59714. * z-depth defining the near plane of the eye view frustum
  59715. * enables mapping of values in the render target depth
  59716. * attachment to scene coordinates. Initially set to 0.01.
  59717. */
  59718. depthNear: number;
  59719. /**
  59720. * An identifier for this distinct VRDisplay. Used as an
  59721. * association point in the Gamepad API.
  59722. */
  59723. readonly displayId: number;
  59724. /**
  59725. * A display name, a user-readable name identifying it.
  59726. */
  59727. readonly displayName: string;
  59728. readonly isConnected: boolean;
  59729. readonly isPresenting: boolean;
  59730. /**
  59731. * If this VRDisplay supports room-scale experiences, the optional
  59732. * stage attribute contains details on the room-scale parameters.
  59733. */
  59734. readonly stageParameters: VRStageParameters | null;
  59735. /**
  59736. * Passing the value returned by `requestAnimationFrame` to
  59737. * `cancelAnimationFrame` will unregister the callback.
  59738. * @param handle Define the hanle of the request to cancel
  59739. */
  59740. cancelAnimationFrame(handle: number): void;
  59741. /**
  59742. * Stops presenting to the VRDisplay.
  59743. * @returns a promise to know when it stopped
  59744. */
  59745. exitPresent(): Promise<void>;
  59746. /**
  59747. * Return the current VREyeParameters for the given eye.
  59748. * @param whichEye Define the eye we want the parameter for
  59749. * @returns the eye parameters
  59750. */
  59751. getEyeParameters(whichEye: string): VREyeParameters;
  59752. /**
  59753. * Populates the passed VRFrameData with the information required to render
  59754. * the current frame.
  59755. * @param frameData Define the data structure to populate
  59756. * @returns true if ok otherwise false
  59757. */
  59758. getFrameData(frameData: VRFrameData): boolean;
  59759. /**
  59760. * Get the layers currently being presented.
  59761. * @returns the list of VR layers
  59762. */
  59763. getLayers(): VRLayer[];
  59764. /**
  59765. * Return a VRPose containing the future predicted pose of the VRDisplay
  59766. * when the current frame will be presented. The value returned will not
  59767. * change until JavaScript has returned control to the browser.
  59768. *
  59769. * The VRPose will contain the position, orientation, velocity,
  59770. * and acceleration of each of these properties.
  59771. * @returns the pose object
  59772. */
  59773. getPose(): VRPose;
  59774. /**
  59775. * Return the current instantaneous pose of the VRDisplay, with no
  59776. * prediction applied.
  59777. * @returns the current instantaneous pose
  59778. */
  59779. getImmediatePose(): VRPose;
  59780. /**
  59781. * The callback passed to `requestAnimationFrame` will be called
  59782. * any time a new frame should be rendered. When the VRDisplay is
  59783. * presenting the callback will be called at the native refresh
  59784. * rate of the HMD. When not presenting this function acts
  59785. * identically to how window.requestAnimationFrame acts. Content should
  59786. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59787. * asynchronously from other displays and at differing refresh rates.
  59788. * @param callback Define the eaction to run next frame
  59789. * @returns the request handle it
  59790. */
  59791. requestAnimationFrame(callback: FrameRequestCallback): number;
  59792. /**
  59793. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59794. * Repeat calls while already presenting will update the VRLayers being displayed.
  59795. * @param layers Define the list of layer to present
  59796. * @returns a promise to know when the request has been fulfilled
  59797. */
  59798. requestPresent(layers: VRLayer[]): Promise<void>;
  59799. /**
  59800. * Reset the pose for this display, treating its current position and
  59801. * orientation as the "origin/zero" values. VRPose.position,
  59802. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59803. * updated when calling resetPose(). This should be called in only
  59804. * sitting-space experiences.
  59805. */
  59806. resetPose(): void;
  59807. /**
  59808. * The VRLayer provided to the VRDisplay will be captured and presented
  59809. * in the HMD. Calling this function has the same effect on the source
  59810. * canvas as any other operation that uses its source image, and canvases
  59811. * created without preserveDrawingBuffer set to true will be cleared.
  59812. * @param pose Define the pose to submit
  59813. */
  59814. submitFrame(pose?: VRPose): void;
  59815. }
  59816. declare var VRDisplay: {
  59817. prototype: VRDisplay;
  59818. new(): VRDisplay;
  59819. };
  59820. interface VRLayer {
  59821. leftBounds?: number[] | Float32Array | null;
  59822. rightBounds?: number[] | Float32Array | null;
  59823. source?: HTMLCanvasElement | null;
  59824. }
  59825. interface VRDisplayCapabilities {
  59826. readonly canPresent: boolean;
  59827. readonly hasExternalDisplay: boolean;
  59828. readonly hasOrientation: boolean;
  59829. readonly hasPosition: boolean;
  59830. readonly maxLayers: number;
  59831. }
  59832. interface VREyeParameters {
  59833. /** @deprecated */
  59834. readonly fieldOfView: VRFieldOfView;
  59835. readonly offset: Float32Array;
  59836. readonly renderHeight: number;
  59837. readonly renderWidth: number;
  59838. }
  59839. interface VRFieldOfView {
  59840. readonly downDegrees: number;
  59841. readonly leftDegrees: number;
  59842. readonly rightDegrees: number;
  59843. readonly upDegrees: number;
  59844. }
  59845. interface VRFrameData {
  59846. readonly leftProjectionMatrix: Float32Array;
  59847. readonly leftViewMatrix: Float32Array;
  59848. readonly pose: VRPose;
  59849. readonly rightProjectionMatrix: Float32Array;
  59850. readonly rightViewMatrix: Float32Array;
  59851. readonly timestamp: number;
  59852. }
  59853. interface VRPose {
  59854. readonly angularAcceleration: Float32Array | null;
  59855. readonly angularVelocity: Float32Array | null;
  59856. readonly linearAcceleration: Float32Array | null;
  59857. readonly linearVelocity: Float32Array | null;
  59858. readonly orientation: Float32Array | null;
  59859. readonly position: Float32Array | null;
  59860. readonly timestamp: number;
  59861. }
  59862. interface VRStageParameters {
  59863. sittingToStandingTransform?: Float32Array;
  59864. sizeX?: number;
  59865. sizeY?: number;
  59866. }
  59867. interface Navigator {
  59868. getVRDisplays(): Promise<VRDisplay[]>;
  59869. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59870. }
  59871. interface Window {
  59872. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59873. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59874. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59875. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59876. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59877. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59878. }
  59879. interface Gamepad {
  59880. readonly displayId: number;
  59881. }
  59882. interface XRDevice {
  59883. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59884. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59885. }
  59886. interface XRSession {
  59887. getInputSources(): Array<any>;
  59888. baseLayer: XRWebGLLayer;
  59889. requestFrameOfReference(type: string): Promise<void>;
  59890. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59891. end(): Promise<void>;
  59892. requestAnimationFrame: Function;
  59893. addEventListener: Function;
  59894. }
  59895. interface XRSessionCreationOptions {
  59896. outputContext?: WebGLRenderingContext | null;
  59897. immersive?: boolean;
  59898. environmentIntegration?: boolean;
  59899. }
  59900. interface XRLayer {
  59901. getViewport: Function;
  59902. framebufferWidth: number;
  59903. framebufferHeight: number;
  59904. }
  59905. interface XRView {
  59906. projectionMatrix: Float32Array;
  59907. }
  59908. interface XRFrame {
  59909. getDevicePose: Function;
  59910. getInputPose: Function;
  59911. views: Array<XRView>;
  59912. baseLayer: XRLayer;
  59913. }
  59914. interface XRFrameOfReference {
  59915. }
  59916. interface XRWebGLLayer extends XRLayer {
  59917. framebuffer: WebGLFramebuffer;
  59918. }
  59919. declare var XRWebGLLayer: {
  59920. prototype: XRWebGLLayer;
  59921. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59922. };
  59923. declare module "babylonjs" {
  59924. export * from "babylonjs/Legacy/legacy";
  59925. }
  59926. declare module BABYLON {
  59927. /** Alias type for value that can be null */
  59928. export type Nullable<T> = T | null;
  59929. /**
  59930. * Alias type for number that are floats
  59931. * @ignorenaming
  59932. */
  59933. export type float = number;
  59934. /**
  59935. * Alias type for number that are doubles.
  59936. * @ignorenaming
  59937. */
  59938. export type double = number;
  59939. /**
  59940. * Alias type for number that are integer
  59941. * @ignorenaming
  59942. */
  59943. export type int = number;
  59944. /** Alias type for number array or Float32Array */
  59945. export type FloatArray = number[] | Float32Array;
  59946. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59947. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59948. /**
  59949. * Alias for types that can be used by a Buffer or VertexBuffer.
  59950. */
  59951. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59952. /**
  59953. * Alias type for primitive types
  59954. * @ignorenaming
  59955. */
  59956. type Primitive = undefined | null | boolean | string | number | Function;
  59957. /**
  59958. * Type modifier to make all the properties of an object Readonly
  59959. */
  59960. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59961. /**
  59962. * Type modifier to make all the properties of an object Readonly recursively
  59963. */
  59964. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59965. /** @hidden */
  59966. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59967. }
  59968. /** @hidden */
  59969. /** @hidden */
  59970. type DeepImmutableObject<T> = {
  59971. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59972. };
  59973. }
  59974. declare module BABYLON {
  59975. /**
  59976. * Class containing a set of static utilities functions for arrays.
  59977. */
  59978. export class ArrayTools {
  59979. /**
  59980. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59981. * @param size the number of element to construct and put in the array
  59982. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59983. * @returns a new array filled with new objects
  59984. */
  59985. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59986. }
  59987. }
  59988. declare module BABYLON {
  59989. /**
  59990. * Scalar computation library
  59991. */
  59992. export class Scalar {
  59993. /**
  59994. * Two pi constants convenient for computation.
  59995. */
  59996. static TwoPi: number;
  59997. /**
  59998. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59999. * @param a number
  60000. * @param b number
  60001. * @param epsilon (default = 1.401298E-45)
  60002. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60003. */
  60004. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  60005. /**
  60006. * Returns a string : the upper case translation of the number i to hexadecimal.
  60007. * @param i number
  60008. * @returns the upper case translation of the number i to hexadecimal.
  60009. */
  60010. static ToHex(i: number): string;
  60011. /**
  60012. * Returns -1 if value is negative and +1 is value is positive.
  60013. * @param value the value
  60014. * @returns the value itself if it's equal to zero.
  60015. */
  60016. static Sign(value: number): number;
  60017. /**
  60018. * Returns the value itself if it's between min and max.
  60019. * Returns min if the value is lower than min.
  60020. * Returns max if the value is greater than max.
  60021. * @param value the value to clmap
  60022. * @param min the min value to clamp to (default: 0)
  60023. * @param max the max value to clamp to (default: 1)
  60024. * @returns the clamped value
  60025. */
  60026. static Clamp(value: number, min?: number, max?: number): number;
  60027. /**
  60028. * the log2 of value.
  60029. * @param value the value to compute log2 of
  60030. * @returns the log2 of value.
  60031. */
  60032. static Log2(value: number): number;
  60033. /**
  60034. * Loops the value, so that it is never larger than length and never smaller than 0.
  60035. *
  60036. * This is similar to the modulo operator but it works with floating point numbers.
  60037. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  60038. * With t = 5 and length = 2.5, the result would be 0.0.
  60039. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  60040. * @param value the value
  60041. * @param length the length
  60042. * @returns the looped value
  60043. */
  60044. static Repeat(value: number, length: number): number;
  60045. /**
  60046. * Normalize the value between 0.0 and 1.0 using min and max values
  60047. * @param value value to normalize
  60048. * @param min max to normalize between
  60049. * @param max min to normalize between
  60050. * @returns the normalized value
  60051. */
  60052. static Normalize(value: number, min: number, max: number): number;
  60053. /**
  60054. * Denormalize the value from 0.0 and 1.0 using min and max values
  60055. * @param normalized value to denormalize
  60056. * @param min max to denormalize between
  60057. * @param max min to denormalize between
  60058. * @returns the denormalized value
  60059. */
  60060. static Denormalize(normalized: number, min: number, max: number): number;
  60061. /**
  60062. * Calculates the shortest difference between two given angles given in degrees.
  60063. * @param current current angle in degrees
  60064. * @param target target angle in degrees
  60065. * @returns the delta
  60066. */
  60067. static DeltaAngle(current: number, target: number): number;
  60068. /**
  60069. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  60070. * @param tx value
  60071. * @param length length
  60072. * @returns The returned value will move back and forth between 0 and length
  60073. */
  60074. static PingPong(tx: number, length: number): number;
  60075. /**
  60076. * Interpolates between min and max with smoothing at the limits.
  60077. *
  60078. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  60079. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  60080. * @param from from
  60081. * @param to to
  60082. * @param tx value
  60083. * @returns the smooth stepped value
  60084. */
  60085. static SmoothStep(from: number, to: number, tx: number): number;
  60086. /**
  60087. * Moves a value current towards target.
  60088. *
  60089. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  60090. * Negative values of maxDelta pushes the value away from target.
  60091. * @param current current value
  60092. * @param target target value
  60093. * @param maxDelta max distance to move
  60094. * @returns resulting value
  60095. */
  60096. static MoveTowards(current: number, target: number, maxDelta: number): number;
  60097. /**
  60098. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60099. *
  60100. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  60101. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  60102. * @param current current value
  60103. * @param target target value
  60104. * @param maxDelta max distance to move
  60105. * @returns resulting angle
  60106. */
  60107. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  60108. /**
  60109. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  60110. * @param start start value
  60111. * @param end target value
  60112. * @param amount amount to lerp between
  60113. * @returns the lerped value
  60114. */
  60115. static Lerp(start: number, end: number, amount: number): number;
  60116. /**
  60117. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60118. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  60119. * @param start start value
  60120. * @param end target value
  60121. * @param amount amount to lerp between
  60122. * @returns the lerped value
  60123. */
  60124. static LerpAngle(start: number, end: number, amount: number): number;
  60125. /**
  60126. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  60127. * @param a start value
  60128. * @param b target value
  60129. * @param value value between a and b
  60130. * @returns the inverseLerp value
  60131. */
  60132. static InverseLerp(a: number, b: number, value: number): number;
  60133. /**
  60134. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  60135. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  60136. * @param value1 spline value
  60137. * @param tangent1 spline value
  60138. * @param value2 spline value
  60139. * @param tangent2 spline value
  60140. * @param amount input value
  60141. * @returns hermite result
  60142. */
  60143. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  60144. /**
  60145. * Returns a random float number between and min and max values
  60146. * @param min min value of random
  60147. * @param max max value of random
  60148. * @returns random value
  60149. */
  60150. static RandomRange(min: number, max: number): number;
  60151. /**
  60152. * This function returns percentage of a number in a given range.
  60153. *
  60154. * RangeToPercent(40,20,60) will return 0.5 (50%)
  60155. * RangeToPercent(34,0,100) will return 0.34 (34%)
  60156. * @param number to convert to percentage
  60157. * @param min min range
  60158. * @param max max range
  60159. * @returns the percentage
  60160. */
  60161. static RangeToPercent(number: number, min: number, max: number): number;
  60162. /**
  60163. * This function returns number that corresponds to the percentage in a given range.
  60164. *
  60165. * PercentToRange(0.34,0,100) will return 34.
  60166. * @param percent to convert to number
  60167. * @param min min range
  60168. * @param max max range
  60169. * @returns the number
  60170. */
  60171. static PercentToRange(percent: number, min: number, max: number): number;
  60172. /**
  60173. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  60174. * @param angle The angle to normalize in radian.
  60175. * @return The converted angle.
  60176. */
  60177. static NormalizeRadians(angle: number): number;
  60178. }
  60179. }
  60180. declare module BABYLON {
  60181. /**
  60182. * Constant used to convert a value to gamma space
  60183. * @ignorenaming
  60184. */
  60185. export const ToGammaSpace: number;
  60186. /**
  60187. * Constant used to convert a value to linear space
  60188. * @ignorenaming
  60189. */
  60190. export const ToLinearSpace = 2.2;
  60191. /**
  60192. * Constant used to define the minimal number value in Babylon.js
  60193. * @ignorenaming
  60194. */
  60195. let Epsilon: number;
  60196. /**
  60197. * Class used to hold a RBG color
  60198. */
  60199. export class Color3 {
  60200. /**
  60201. * Defines the red component (between 0 and 1, default is 0)
  60202. */
  60203. r: number;
  60204. /**
  60205. * Defines the green component (between 0 and 1, default is 0)
  60206. */
  60207. g: number;
  60208. /**
  60209. * Defines the blue component (between 0 and 1, default is 0)
  60210. */
  60211. b: number;
  60212. /**
  60213. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  60214. * @param r defines the red component (between 0 and 1, default is 0)
  60215. * @param g defines the green component (between 0 and 1, default is 0)
  60216. * @param b defines the blue component (between 0 and 1, default is 0)
  60217. */
  60218. constructor(
  60219. /**
  60220. * Defines the red component (between 0 and 1, default is 0)
  60221. */
  60222. r?: number,
  60223. /**
  60224. * Defines the green component (between 0 and 1, default is 0)
  60225. */
  60226. g?: number,
  60227. /**
  60228. * Defines the blue component (between 0 and 1, default is 0)
  60229. */
  60230. b?: number);
  60231. /**
  60232. * Creates a string with the Color3 current values
  60233. * @returns the string representation of the Color3 object
  60234. */
  60235. toString(): string;
  60236. /**
  60237. * Returns the string "Color3"
  60238. * @returns "Color3"
  60239. */
  60240. getClassName(): string;
  60241. /**
  60242. * Compute the Color3 hash code
  60243. * @returns an unique number that can be used to hash Color3 objects
  60244. */
  60245. getHashCode(): number;
  60246. /**
  60247. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  60248. * @param array defines the array where to store the r,g,b components
  60249. * @param index defines an optional index in the target array to define where to start storing values
  60250. * @returns the current Color3 object
  60251. */
  60252. toArray(array: FloatArray, index?: number): Color3;
  60253. /**
  60254. * Returns a new Color4 object from the current Color3 and the given alpha
  60255. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  60256. * @returns a new Color4 object
  60257. */
  60258. toColor4(alpha?: number): Color4;
  60259. /**
  60260. * Returns a new array populated with 3 numeric elements : red, green and blue values
  60261. * @returns the new array
  60262. */
  60263. asArray(): number[];
  60264. /**
  60265. * Returns the luminance value
  60266. * @returns a float value
  60267. */
  60268. toLuminance(): number;
  60269. /**
  60270. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  60271. * @param otherColor defines the second operand
  60272. * @returns the new Color3 object
  60273. */
  60274. multiply(otherColor: DeepImmutable<Color3>): Color3;
  60275. /**
  60276. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  60277. * @param otherColor defines the second operand
  60278. * @param result defines the Color3 object where to store the result
  60279. * @returns the current Color3
  60280. */
  60281. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60282. /**
  60283. * Determines equality between Color3 objects
  60284. * @param otherColor defines the second operand
  60285. * @returns true if the rgb values are equal to the given ones
  60286. */
  60287. equals(otherColor: DeepImmutable<Color3>): boolean;
  60288. /**
  60289. * Determines equality between the current Color3 object and a set of r,b,g values
  60290. * @param r defines the red component to check
  60291. * @param g defines the green component to check
  60292. * @param b defines the blue component to check
  60293. * @returns true if the rgb values are equal to the given ones
  60294. */
  60295. equalsFloats(r: number, g: number, b: number): boolean;
  60296. /**
  60297. * Multiplies in place each rgb value by scale
  60298. * @param scale defines the scaling factor
  60299. * @returns the updated Color3
  60300. */
  60301. scale(scale: number): Color3;
  60302. /**
  60303. * Multiplies the rgb values by scale and stores the result into "result"
  60304. * @param scale defines the scaling factor
  60305. * @param result defines the Color3 object where to store the result
  60306. * @returns the unmodified current Color3
  60307. */
  60308. scaleToRef(scale: number, result: Color3): Color3;
  60309. /**
  60310. * Scale the current Color3 values by a factor and add the result to a given Color3
  60311. * @param scale defines the scale factor
  60312. * @param result defines color to store the result into
  60313. * @returns the unmodified current Color3
  60314. */
  60315. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60316. /**
  60317. * Clamps the rgb values by the min and max values and stores the result into "result"
  60318. * @param min defines minimum clamping value (default is 0)
  60319. * @param max defines maximum clamping value (default is 1)
  60320. * @param result defines color to store the result into
  60321. * @returns the original Color3
  60322. */
  60323. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60324. /**
  60325. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60326. * @param otherColor defines the second operand
  60327. * @returns the new Color3
  60328. */
  60329. add(otherColor: DeepImmutable<Color3>): Color3;
  60330. /**
  60331. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60332. * @param otherColor defines the second operand
  60333. * @param result defines Color3 object to store the result into
  60334. * @returns the unmodified current Color3
  60335. */
  60336. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60337. /**
  60338. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60339. * @param otherColor defines the second operand
  60340. * @returns the new Color3
  60341. */
  60342. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60343. /**
  60344. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60345. * @param otherColor defines the second operand
  60346. * @param result defines Color3 object to store the result into
  60347. * @returns the unmodified current Color3
  60348. */
  60349. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60350. /**
  60351. * Copy the current object
  60352. * @returns a new Color3 copied the current one
  60353. */
  60354. clone(): Color3;
  60355. /**
  60356. * Copies the rgb values from the source in the current Color3
  60357. * @param source defines the source Color3 object
  60358. * @returns the updated Color3 object
  60359. */
  60360. copyFrom(source: DeepImmutable<Color3>): Color3;
  60361. /**
  60362. * Updates the Color3 rgb values from the given floats
  60363. * @param r defines the red component to read from
  60364. * @param g defines the green component to read from
  60365. * @param b defines the blue component to read from
  60366. * @returns the current Color3 object
  60367. */
  60368. copyFromFloats(r: number, g: number, b: number): Color3;
  60369. /**
  60370. * Updates the Color3 rgb values from the given floats
  60371. * @param r defines the red component to read from
  60372. * @param g defines the green component to read from
  60373. * @param b defines the blue component to read from
  60374. * @returns the current Color3 object
  60375. */
  60376. set(r: number, g: number, b: number): Color3;
  60377. /**
  60378. * Compute the Color3 hexadecimal code as a string
  60379. * @returns a string containing the hexadecimal representation of the Color3 object
  60380. */
  60381. toHexString(): string;
  60382. /**
  60383. * Computes a new Color3 converted from the current one to linear space
  60384. * @returns a new Color3 object
  60385. */
  60386. toLinearSpace(): Color3;
  60387. /**
  60388. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60389. * @param convertedColor defines the Color3 object where to store the linear space version
  60390. * @returns the unmodified Color3
  60391. */
  60392. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60393. /**
  60394. * Computes a new Color3 converted from the current one to gamma space
  60395. * @returns a new Color3 object
  60396. */
  60397. toGammaSpace(): Color3;
  60398. /**
  60399. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60400. * @param convertedColor defines the Color3 object where to store the gamma space version
  60401. * @returns the unmodified Color3
  60402. */
  60403. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60404. private static _BlackReadOnly;
  60405. /**
  60406. * Creates a new Color3 from the string containing valid hexadecimal values
  60407. * @param hex defines a string containing valid hexadecimal values
  60408. * @returns a new Color3 object
  60409. */
  60410. static FromHexString(hex: string): Color3;
  60411. /**
  60412. * Creates a new Color3 from the starting index of the given array
  60413. * @param array defines the source array
  60414. * @param offset defines an offset in the source array
  60415. * @returns a new Color3 object
  60416. */
  60417. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60418. /**
  60419. * Creates a new Color3 from integer values (< 256)
  60420. * @param r defines the red component to read from (value between 0 and 255)
  60421. * @param g defines the green component to read from (value between 0 and 255)
  60422. * @param b defines the blue component to read from (value between 0 and 255)
  60423. * @returns a new Color3 object
  60424. */
  60425. static FromInts(r: number, g: number, b: number): Color3;
  60426. /**
  60427. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60428. * @param start defines the start Color3 value
  60429. * @param end defines the end Color3 value
  60430. * @param amount defines the gradient value between start and end
  60431. * @returns a new Color3 object
  60432. */
  60433. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60434. /**
  60435. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60436. * @param left defines the start value
  60437. * @param right defines the end value
  60438. * @param amount defines the gradient factor
  60439. * @param result defines the Color3 object where to store the result
  60440. */
  60441. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60442. /**
  60443. * Returns a Color3 value containing a red color
  60444. * @returns a new Color3 object
  60445. */
  60446. static Red(): Color3;
  60447. /**
  60448. * Returns a Color3 value containing a green color
  60449. * @returns a new Color3 object
  60450. */
  60451. static Green(): Color3;
  60452. /**
  60453. * Returns a Color3 value containing a blue color
  60454. * @returns a new Color3 object
  60455. */
  60456. static Blue(): Color3;
  60457. /**
  60458. * Returns a Color3 value containing a black color
  60459. * @returns a new Color3 object
  60460. */
  60461. static Black(): Color3;
  60462. /**
  60463. * Gets a Color3 value containing a black color that must not be updated
  60464. */
  60465. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60466. /**
  60467. * Returns a Color3 value containing a white color
  60468. * @returns a new Color3 object
  60469. */
  60470. static White(): Color3;
  60471. /**
  60472. * Returns a Color3 value containing a purple color
  60473. * @returns a new Color3 object
  60474. */
  60475. static Purple(): Color3;
  60476. /**
  60477. * Returns a Color3 value containing a magenta color
  60478. * @returns a new Color3 object
  60479. */
  60480. static Magenta(): Color3;
  60481. /**
  60482. * Returns a Color3 value containing a yellow color
  60483. * @returns a new Color3 object
  60484. */
  60485. static Yellow(): Color3;
  60486. /**
  60487. * Returns a Color3 value containing a gray color
  60488. * @returns a new Color3 object
  60489. */
  60490. static Gray(): Color3;
  60491. /**
  60492. * Returns a Color3 value containing a teal color
  60493. * @returns a new Color3 object
  60494. */
  60495. static Teal(): Color3;
  60496. /**
  60497. * Returns a Color3 value containing a random color
  60498. * @returns a new Color3 object
  60499. */
  60500. static Random(): Color3;
  60501. }
  60502. /**
  60503. * Class used to hold a RBGA color
  60504. */
  60505. export class Color4 {
  60506. /**
  60507. * Defines the red component (between 0 and 1, default is 0)
  60508. */
  60509. r: number;
  60510. /**
  60511. * Defines the green component (between 0 and 1, default is 0)
  60512. */
  60513. g: number;
  60514. /**
  60515. * Defines the blue component (between 0 and 1, default is 0)
  60516. */
  60517. b: number;
  60518. /**
  60519. * Defines the alpha component (between 0 and 1, default is 1)
  60520. */
  60521. a: number;
  60522. /**
  60523. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60524. * @param r defines the red component (between 0 and 1, default is 0)
  60525. * @param g defines the green component (between 0 and 1, default is 0)
  60526. * @param b defines the blue component (between 0 and 1, default is 0)
  60527. * @param a defines the alpha component (between 0 and 1, default is 1)
  60528. */
  60529. constructor(
  60530. /**
  60531. * Defines the red component (between 0 and 1, default is 0)
  60532. */
  60533. r?: number,
  60534. /**
  60535. * Defines the green component (between 0 and 1, default is 0)
  60536. */
  60537. g?: number,
  60538. /**
  60539. * Defines the blue component (between 0 and 1, default is 0)
  60540. */
  60541. b?: number,
  60542. /**
  60543. * Defines the alpha component (between 0 and 1, default is 1)
  60544. */
  60545. a?: number);
  60546. /**
  60547. * Adds in place the given Color4 values to the current Color4 object
  60548. * @param right defines the second operand
  60549. * @returns the current updated Color4 object
  60550. */
  60551. addInPlace(right: DeepImmutable<Color4>): Color4;
  60552. /**
  60553. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60554. * @returns the new array
  60555. */
  60556. asArray(): number[];
  60557. /**
  60558. * Stores from the starting index in the given array the Color4 successive values
  60559. * @param array defines the array where to store the r,g,b components
  60560. * @param index defines an optional index in the target array to define where to start storing values
  60561. * @returns the current Color4 object
  60562. */
  60563. toArray(array: number[], index?: number): Color4;
  60564. /**
  60565. * Determines equality between Color4 objects
  60566. * @param otherColor defines the second operand
  60567. * @returns true if the rgba values are equal to the given ones
  60568. */
  60569. equals(otherColor: DeepImmutable<Color4>): boolean;
  60570. /**
  60571. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60572. * @param right defines the second operand
  60573. * @returns a new Color4 object
  60574. */
  60575. add(right: DeepImmutable<Color4>): Color4;
  60576. /**
  60577. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60578. * @param right defines the second operand
  60579. * @returns a new Color4 object
  60580. */
  60581. subtract(right: DeepImmutable<Color4>): Color4;
  60582. /**
  60583. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60584. * @param right defines the second operand
  60585. * @param result defines the Color4 object where to store the result
  60586. * @returns the current Color4 object
  60587. */
  60588. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60589. /**
  60590. * Creates a new Color4 with the current Color4 values multiplied by scale
  60591. * @param scale defines the scaling factor to apply
  60592. * @returns a new Color4 object
  60593. */
  60594. scale(scale: number): Color4;
  60595. /**
  60596. * Multiplies the current Color4 values by scale and stores the result in "result"
  60597. * @param scale defines the scaling factor to apply
  60598. * @param result defines the Color4 object where to store the result
  60599. * @returns the current unmodified Color4
  60600. */
  60601. scaleToRef(scale: number, result: Color4): Color4;
  60602. /**
  60603. * Scale the current Color4 values by a factor and add the result to a given Color4
  60604. * @param scale defines the scale factor
  60605. * @param result defines the Color4 object where to store the result
  60606. * @returns the unmodified current Color4
  60607. */
  60608. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60609. /**
  60610. * Clamps the rgb values by the min and max values and stores the result into "result"
  60611. * @param min defines minimum clamping value (default is 0)
  60612. * @param max defines maximum clamping value (default is 1)
  60613. * @param result defines color to store the result into.
  60614. * @returns the cuurent Color4
  60615. */
  60616. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60617. /**
  60618. * Multipy an Color4 value by another and return a new Color4 object
  60619. * @param color defines the Color4 value to multiply by
  60620. * @returns a new Color4 object
  60621. */
  60622. multiply(color: Color4): Color4;
  60623. /**
  60624. * Multipy a Color4 value by another and push the result in a reference value
  60625. * @param color defines the Color4 value to multiply by
  60626. * @param result defines the Color4 to fill the result in
  60627. * @returns the result Color4
  60628. */
  60629. multiplyToRef(color: Color4, result: Color4): Color4;
  60630. /**
  60631. * Creates a string with the Color4 current values
  60632. * @returns the string representation of the Color4 object
  60633. */
  60634. toString(): string;
  60635. /**
  60636. * Returns the string "Color4"
  60637. * @returns "Color4"
  60638. */
  60639. getClassName(): string;
  60640. /**
  60641. * Compute the Color4 hash code
  60642. * @returns an unique number that can be used to hash Color4 objects
  60643. */
  60644. getHashCode(): number;
  60645. /**
  60646. * Creates a new Color4 copied from the current one
  60647. * @returns a new Color4 object
  60648. */
  60649. clone(): Color4;
  60650. /**
  60651. * Copies the given Color4 values into the current one
  60652. * @param source defines the source Color4 object
  60653. * @returns the current updated Color4 object
  60654. */
  60655. copyFrom(source: Color4): Color4;
  60656. /**
  60657. * Copies the given float values into the current one
  60658. * @param r defines the red component to read from
  60659. * @param g defines the green component to read from
  60660. * @param b defines the blue component to read from
  60661. * @param a defines the alpha component to read from
  60662. * @returns the current updated Color4 object
  60663. */
  60664. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60665. /**
  60666. * Copies the given float values into the current one
  60667. * @param r defines the red component to read from
  60668. * @param g defines the green component to read from
  60669. * @param b defines the blue component to read from
  60670. * @param a defines the alpha component to read from
  60671. * @returns the current updated Color4 object
  60672. */
  60673. set(r: number, g: number, b: number, a: number): Color4;
  60674. /**
  60675. * Compute the Color4 hexadecimal code as a string
  60676. * @returns a string containing the hexadecimal representation of the Color4 object
  60677. */
  60678. toHexString(): string;
  60679. /**
  60680. * Computes a new Color4 converted from the current one to linear space
  60681. * @returns a new Color4 object
  60682. */
  60683. toLinearSpace(): Color4;
  60684. /**
  60685. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60686. * @param convertedColor defines the Color4 object where to store the linear space version
  60687. * @returns the unmodified Color4
  60688. */
  60689. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60690. /**
  60691. * Computes a new Color4 converted from the current one to gamma space
  60692. * @returns a new Color4 object
  60693. */
  60694. toGammaSpace(): Color4;
  60695. /**
  60696. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60697. * @param convertedColor defines the Color4 object where to store the gamma space version
  60698. * @returns the unmodified Color4
  60699. */
  60700. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60701. /**
  60702. * Creates a new Color4 from the string containing valid hexadecimal values
  60703. * @param hex defines a string containing valid hexadecimal values
  60704. * @returns a new Color4 object
  60705. */
  60706. static FromHexString(hex: string): Color4;
  60707. /**
  60708. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60709. * @param left defines the start value
  60710. * @param right defines the end value
  60711. * @param amount defines the gradient factor
  60712. * @returns a new Color4 object
  60713. */
  60714. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60715. /**
  60716. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60717. * @param left defines the start value
  60718. * @param right defines the end value
  60719. * @param amount defines the gradient factor
  60720. * @param result defines the Color4 object where to store data
  60721. */
  60722. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60723. /**
  60724. * Creates a new Color4 from a Color3 and an alpha value
  60725. * @param color3 defines the source Color3 to read from
  60726. * @param alpha defines the alpha component (1.0 by default)
  60727. * @returns a new Color4 object
  60728. */
  60729. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60730. /**
  60731. * Creates a new Color4 from the starting index element of the given array
  60732. * @param array defines the source array to read from
  60733. * @param offset defines the offset in the source array
  60734. * @returns a new Color4 object
  60735. */
  60736. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60737. /**
  60738. * Creates a new Color3 from integer values (< 256)
  60739. * @param r defines the red component to read from (value between 0 and 255)
  60740. * @param g defines the green component to read from (value between 0 and 255)
  60741. * @param b defines the blue component to read from (value between 0 and 255)
  60742. * @param a defines the alpha component to read from (value between 0 and 255)
  60743. * @returns a new Color3 object
  60744. */
  60745. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60746. /**
  60747. * Check the content of a given array and convert it to an array containing RGBA data
  60748. * If the original array was already containing count * 4 values then it is returned directly
  60749. * @param colors defines the array to check
  60750. * @param count defines the number of RGBA data to expect
  60751. * @returns an array containing count * 4 values (RGBA)
  60752. */
  60753. static CheckColors4(colors: number[], count: number): number[];
  60754. }
  60755. /**
  60756. * Class representing a vector containing 2 coordinates
  60757. */
  60758. export class Vector2 {
  60759. /** defines the first coordinate */
  60760. x: number;
  60761. /** defines the second coordinate */
  60762. y: number;
  60763. /**
  60764. * Creates a new Vector2 from the given x and y coordinates
  60765. * @param x defines the first coordinate
  60766. * @param y defines the second coordinate
  60767. */
  60768. constructor(
  60769. /** defines the first coordinate */
  60770. x?: number,
  60771. /** defines the second coordinate */
  60772. y?: number);
  60773. /**
  60774. * Gets a string with the Vector2 coordinates
  60775. * @returns a string with the Vector2 coordinates
  60776. */
  60777. toString(): string;
  60778. /**
  60779. * Gets class name
  60780. * @returns the string "Vector2"
  60781. */
  60782. getClassName(): string;
  60783. /**
  60784. * Gets current vector hash code
  60785. * @returns the Vector2 hash code as a number
  60786. */
  60787. getHashCode(): number;
  60788. /**
  60789. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60790. * @param array defines the source array
  60791. * @param index defines the offset in source array
  60792. * @returns the current Vector2
  60793. */
  60794. toArray(array: FloatArray, index?: number): Vector2;
  60795. /**
  60796. * Copy the current vector to an array
  60797. * @returns a new array with 2 elements: the Vector2 coordinates.
  60798. */
  60799. asArray(): number[];
  60800. /**
  60801. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60802. * @param source defines the source Vector2
  60803. * @returns the current updated Vector2
  60804. */
  60805. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60806. /**
  60807. * Sets the Vector2 coordinates with the given floats
  60808. * @param x defines the first coordinate
  60809. * @param y defines the second coordinate
  60810. * @returns the current updated Vector2
  60811. */
  60812. copyFromFloats(x: number, y: number): Vector2;
  60813. /**
  60814. * Sets the Vector2 coordinates with the given floats
  60815. * @param x defines the first coordinate
  60816. * @param y defines the second coordinate
  60817. * @returns the current updated Vector2
  60818. */
  60819. set(x: number, y: number): Vector2;
  60820. /**
  60821. * Add another vector with the current one
  60822. * @param otherVector defines the other vector
  60823. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60824. */
  60825. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60826. /**
  60827. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60828. * @param otherVector defines the other vector
  60829. * @param result defines the target vector
  60830. * @returns the unmodified current Vector2
  60831. */
  60832. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60833. /**
  60834. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60835. * @param otherVector defines the other vector
  60836. * @returns the current updated Vector2
  60837. */
  60838. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60839. /**
  60840. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60841. * @param otherVector defines the other vector
  60842. * @returns a new Vector2
  60843. */
  60844. addVector3(otherVector: Vector3): Vector2;
  60845. /**
  60846. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60847. * @param otherVector defines the other vector
  60848. * @returns a new Vector2
  60849. */
  60850. subtract(otherVector: Vector2): Vector2;
  60851. /**
  60852. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60853. * @param otherVector defines the other vector
  60854. * @param result defines the target vector
  60855. * @returns the unmodified current Vector2
  60856. */
  60857. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60858. /**
  60859. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60860. * @param otherVector defines the other vector
  60861. * @returns the current updated Vector2
  60862. */
  60863. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60864. /**
  60865. * Multiplies in place the current Vector2 coordinates by the given ones
  60866. * @param otherVector defines the other vector
  60867. * @returns the current updated Vector2
  60868. */
  60869. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60870. /**
  60871. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60872. * @param otherVector defines the other vector
  60873. * @returns a new Vector2
  60874. */
  60875. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60876. /**
  60877. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60878. * @param otherVector defines the other vector
  60879. * @param result defines the target vector
  60880. * @returns the unmodified current Vector2
  60881. */
  60882. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60883. /**
  60884. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60885. * @param x defines the first coordinate
  60886. * @param y defines the second coordinate
  60887. * @returns a new Vector2
  60888. */
  60889. multiplyByFloats(x: number, y: number): Vector2;
  60890. /**
  60891. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60892. * @param otherVector defines the other vector
  60893. * @returns a new Vector2
  60894. */
  60895. divide(otherVector: Vector2): Vector2;
  60896. /**
  60897. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60898. * @param otherVector defines the other vector
  60899. * @param result defines the target vector
  60900. * @returns the unmodified current Vector2
  60901. */
  60902. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60903. /**
  60904. * Divides the current Vector2 coordinates by the given ones
  60905. * @param otherVector defines the other vector
  60906. * @returns the current updated Vector2
  60907. */
  60908. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60909. /**
  60910. * Gets a new Vector2 with current Vector2 negated coordinates
  60911. * @returns a new Vector2
  60912. */
  60913. negate(): Vector2;
  60914. /**
  60915. * Multiply the Vector2 coordinates by scale
  60916. * @param scale defines the scaling factor
  60917. * @returns the current updated Vector2
  60918. */
  60919. scaleInPlace(scale: number): Vector2;
  60920. /**
  60921. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60922. * @param scale defines the scaling factor
  60923. * @returns a new Vector2
  60924. */
  60925. scale(scale: number): Vector2;
  60926. /**
  60927. * Scale the current Vector2 values by a factor to a given Vector2
  60928. * @param scale defines the scale factor
  60929. * @param result defines the Vector2 object where to store the result
  60930. * @returns the unmodified current Vector2
  60931. */
  60932. scaleToRef(scale: number, result: Vector2): Vector2;
  60933. /**
  60934. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60935. * @param scale defines the scale factor
  60936. * @param result defines the Vector2 object where to store the result
  60937. * @returns the unmodified current Vector2
  60938. */
  60939. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60940. /**
  60941. * Gets a boolean if two vectors are equals
  60942. * @param otherVector defines the other vector
  60943. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60944. */
  60945. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60946. /**
  60947. * Gets a boolean if two vectors are equals (using an epsilon value)
  60948. * @param otherVector defines the other vector
  60949. * @param epsilon defines the minimal distance to consider equality
  60950. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60951. */
  60952. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60953. /**
  60954. * Gets a new Vector2 from current Vector2 floored values
  60955. * @returns a new Vector2
  60956. */
  60957. floor(): Vector2;
  60958. /**
  60959. * Gets a new Vector2 from current Vector2 floored values
  60960. * @returns a new Vector2
  60961. */
  60962. fract(): Vector2;
  60963. /**
  60964. * Gets the length of the vector
  60965. * @returns the vector length (float)
  60966. */
  60967. length(): number;
  60968. /**
  60969. * Gets the vector squared length
  60970. * @returns the vector squared length (float)
  60971. */
  60972. lengthSquared(): number;
  60973. /**
  60974. * Normalize the vector
  60975. * @returns the current updated Vector2
  60976. */
  60977. normalize(): Vector2;
  60978. /**
  60979. * Gets a new Vector2 copied from the Vector2
  60980. * @returns a new Vector2
  60981. */
  60982. clone(): Vector2;
  60983. /**
  60984. * Gets a new Vector2(0, 0)
  60985. * @returns a new Vector2
  60986. */
  60987. static Zero(): Vector2;
  60988. /**
  60989. * Gets a new Vector2(1, 1)
  60990. * @returns a new Vector2
  60991. */
  60992. static One(): Vector2;
  60993. /**
  60994. * Gets a new Vector2 set from the given index element of the given array
  60995. * @param array defines the data source
  60996. * @param offset defines the offset in the data source
  60997. * @returns a new Vector2
  60998. */
  60999. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  61000. /**
  61001. * Sets "result" from the given index element of the given array
  61002. * @param array defines the data source
  61003. * @param offset defines the offset in the data source
  61004. * @param result defines the target vector
  61005. */
  61006. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  61007. /**
  61008. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  61009. * @param value1 defines 1st point of control
  61010. * @param value2 defines 2nd point of control
  61011. * @param value3 defines 3rd point of control
  61012. * @param value4 defines 4th point of control
  61013. * @param amount defines the interpolation factor
  61014. * @returns a new Vector2
  61015. */
  61016. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  61017. /**
  61018. * 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".
  61019. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  61020. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  61021. * @param value defines the value to clamp
  61022. * @param min defines the lower limit
  61023. * @param max defines the upper limit
  61024. * @returns a new Vector2
  61025. */
  61026. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  61027. /**
  61028. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  61029. * @param value1 defines the 1st control point
  61030. * @param tangent1 defines the outgoing tangent
  61031. * @param value2 defines the 2nd control point
  61032. * @param tangent2 defines the incoming tangent
  61033. * @param amount defines the interpolation factor
  61034. * @returns a new Vector2
  61035. */
  61036. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  61037. /**
  61038. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  61039. * @param start defines the start vector
  61040. * @param end defines the end vector
  61041. * @param amount defines the interpolation factor
  61042. * @returns a new Vector2
  61043. */
  61044. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  61045. /**
  61046. * Gets the dot product of the vector "left" and the vector "right"
  61047. * @param left defines first vector
  61048. * @param right defines second vector
  61049. * @returns the dot product (float)
  61050. */
  61051. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  61052. /**
  61053. * Returns a new Vector2 equal to the normalized given vector
  61054. * @param vector defines the vector to normalize
  61055. * @returns a new Vector2
  61056. */
  61057. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  61058. /**
  61059. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  61060. * @param left defines 1st vector
  61061. * @param right defines 2nd vector
  61062. * @returns a new Vector2
  61063. */
  61064. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61065. /**
  61066. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  61067. * @param left defines 1st vector
  61068. * @param right defines 2nd vector
  61069. * @returns a new Vector2
  61070. */
  61071. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61072. /**
  61073. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  61074. * @param vector defines the vector to transform
  61075. * @param transformation defines the matrix to apply
  61076. * @returns a new Vector2
  61077. */
  61078. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  61079. /**
  61080. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  61081. * @param vector defines the vector to transform
  61082. * @param transformation defines the matrix to apply
  61083. * @param result defines the target vector
  61084. */
  61085. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  61086. /**
  61087. * Determines if a given vector is included in a triangle
  61088. * @param p defines the vector to test
  61089. * @param p0 defines 1st triangle point
  61090. * @param p1 defines 2nd triangle point
  61091. * @param p2 defines 3rd triangle point
  61092. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  61093. */
  61094. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  61095. /**
  61096. * Gets the distance between the vectors "value1" and "value2"
  61097. * @param value1 defines first vector
  61098. * @param value2 defines second vector
  61099. * @returns the distance between vectors
  61100. */
  61101. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61102. /**
  61103. * Returns the squared distance between the vectors "value1" and "value2"
  61104. * @param value1 defines first vector
  61105. * @param value2 defines second vector
  61106. * @returns the squared distance between vectors
  61107. */
  61108. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61109. /**
  61110. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  61111. * @param value1 defines first vector
  61112. * @param value2 defines second vector
  61113. * @returns a new Vector2
  61114. */
  61115. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  61116. /**
  61117. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  61118. * @param p defines the middle point
  61119. * @param segA defines one point of the segment
  61120. * @param segB defines the other point of the segment
  61121. * @returns the shortest distance
  61122. */
  61123. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  61124. }
  61125. /**
  61126. * Classed used to store (x,y,z) vector representation
  61127. * A Vector3 is the main object used in 3D geometry
  61128. * It can represent etiher the coordinates of a point the space, either a direction
  61129. * Reminder: js uses a left handed forward facing system
  61130. */
  61131. export class Vector3 {
  61132. /**
  61133. * Defines the first coordinates (on X axis)
  61134. */
  61135. x: number;
  61136. /**
  61137. * Defines the second coordinates (on Y axis)
  61138. */
  61139. y: number;
  61140. /**
  61141. * Defines the third coordinates (on Z axis)
  61142. */
  61143. z: number;
  61144. private static _UpReadOnly;
  61145. /**
  61146. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  61147. * @param x defines the first coordinates (on X axis)
  61148. * @param y defines the second coordinates (on Y axis)
  61149. * @param z defines the third coordinates (on Z axis)
  61150. */
  61151. constructor(
  61152. /**
  61153. * Defines the first coordinates (on X axis)
  61154. */
  61155. x?: number,
  61156. /**
  61157. * Defines the second coordinates (on Y axis)
  61158. */
  61159. y?: number,
  61160. /**
  61161. * Defines the third coordinates (on Z axis)
  61162. */
  61163. z?: number);
  61164. /**
  61165. * Creates a string representation of the Vector3
  61166. * @returns a string with the Vector3 coordinates.
  61167. */
  61168. toString(): string;
  61169. /**
  61170. * Gets the class name
  61171. * @returns the string "Vector3"
  61172. */
  61173. getClassName(): string;
  61174. /**
  61175. * Creates the Vector3 hash code
  61176. * @returns a number which tends to be unique between Vector3 instances
  61177. */
  61178. getHashCode(): number;
  61179. /**
  61180. * Creates an array containing three elements : the coordinates of the Vector3
  61181. * @returns a new array of numbers
  61182. */
  61183. asArray(): number[];
  61184. /**
  61185. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  61186. * @param array defines the destination array
  61187. * @param index defines the offset in the destination array
  61188. * @returns the current Vector3
  61189. */
  61190. toArray(array: FloatArray, index?: number): Vector3;
  61191. /**
  61192. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  61193. * @returns a new Quaternion object, computed from the Vector3 coordinates
  61194. */
  61195. toQuaternion(): Quaternion;
  61196. /**
  61197. * Adds the given vector to the current Vector3
  61198. * @param otherVector defines the second operand
  61199. * @returns the current updated Vector3
  61200. */
  61201. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61202. /**
  61203. * Adds the given coordinates to the current Vector3
  61204. * @param x defines the x coordinate of the operand
  61205. * @param y defines the y coordinate of the operand
  61206. * @param z defines the z coordinate of the operand
  61207. * @returns the current updated Vector3
  61208. */
  61209. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61210. /**
  61211. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  61212. * @param otherVector defines the second operand
  61213. * @returns the resulting Vector3
  61214. */
  61215. add(otherVector: DeepImmutable<Vector3>): Vector3;
  61216. /**
  61217. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  61218. * @param otherVector defines the second operand
  61219. * @param result defines the Vector3 object where to store the result
  61220. * @returns the current Vector3
  61221. */
  61222. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61223. /**
  61224. * Subtract the given vector from the current Vector3
  61225. * @param otherVector defines the second operand
  61226. * @returns the current updated Vector3
  61227. */
  61228. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61229. /**
  61230. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  61231. * @param otherVector defines the second operand
  61232. * @returns the resulting Vector3
  61233. */
  61234. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  61235. /**
  61236. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  61237. * @param otherVector defines the second operand
  61238. * @param result defines the Vector3 object where to store the result
  61239. * @returns the current Vector3
  61240. */
  61241. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61242. /**
  61243. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  61244. * @param x defines the x coordinate of the operand
  61245. * @param y defines the y coordinate of the operand
  61246. * @param z defines the z coordinate of the operand
  61247. * @returns the resulting Vector3
  61248. */
  61249. subtractFromFloats(x: number, y: number, z: number): Vector3;
  61250. /**
  61251. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  61252. * @param x defines the x coordinate of the operand
  61253. * @param y defines the y coordinate of the operand
  61254. * @param z defines the z coordinate of the operand
  61255. * @param result defines the Vector3 object where to store the result
  61256. * @returns the current Vector3
  61257. */
  61258. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  61259. /**
  61260. * Gets a new Vector3 set with the current Vector3 negated coordinates
  61261. * @returns a new Vector3
  61262. */
  61263. negate(): Vector3;
  61264. /**
  61265. * Multiplies the Vector3 coordinates by the float "scale"
  61266. * @param scale defines the multiplier factor
  61267. * @returns the current updated Vector3
  61268. */
  61269. scaleInPlace(scale: number): Vector3;
  61270. /**
  61271. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  61272. * @param scale defines the multiplier factor
  61273. * @returns a new Vector3
  61274. */
  61275. scale(scale: number): Vector3;
  61276. /**
  61277. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  61278. * @param scale defines the multiplier factor
  61279. * @param result defines the Vector3 object where to store the result
  61280. * @returns the current Vector3
  61281. */
  61282. scaleToRef(scale: number, result: Vector3): Vector3;
  61283. /**
  61284. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  61285. * @param scale defines the scale factor
  61286. * @param result defines the Vector3 object where to store the result
  61287. * @returns the unmodified current Vector3
  61288. */
  61289. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61290. /**
  61291. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61292. * @param otherVector defines the second operand
  61293. * @returns true if both vectors are equals
  61294. */
  61295. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61296. /**
  61297. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61298. * @param otherVector defines the second operand
  61299. * @param epsilon defines the minimal distance to define values as equals
  61300. * @returns true if both vectors are distant less than epsilon
  61301. */
  61302. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61303. /**
  61304. * Returns true if the current Vector3 coordinates equals the given floats
  61305. * @param x defines the x coordinate of the operand
  61306. * @param y defines the y coordinate of the operand
  61307. * @param z defines the z coordinate of the operand
  61308. * @returns true if both vectors are equals
  61309. */
  61310. equalsToFloats(x: number, y: number, z: number): boolean;
  61311. /**
  61312. * Multiplies the current Vector3 coordinates by the given ones
  61313. * @param otherVector defines the second operand
  61314. * @returns the current updated Vector3
  61315. */
  61316. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61317. /**
  61318. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61319. * @param otherVector defines the second operand
  61320. * @returns the new Vector3
  61321. */
  61322. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61323. /**
  61324. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61325. * @param otherVector defines the second operand
  61326. * @param result defines the Vector3 object where to store the result
  61327. * @returns the current Vector3
  61328. */
  61329. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61330. /**
  61331. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  61332. * @param x defines the x coordinate of the operand
  61333. * @param y defines the y coordinate of the operand
  61334. * @param z defines the z coordinate of the operand
  61335. * @returns the new Vector3
  61336. */
  61337. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61338. /**
  61339. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61340. * @param otherVector defines the second operand
  61341. * @returns the new Vector3
  61342. */
  61343. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61344. /**
  61345. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  61346. * @param otherVector defines the second operand
  61347. * @param result defines the Vector3 object where to store the result
  61348. * @returns the current Vector3
  61349. */
  61350. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61351. /**
  61352. * Divides the current Vector3 coordinates by the given ones.
  61353. * @param otherVector defines the second operand
  61354. * @returns the current updated Vector3
  61355. */
  61356. divideInPlace(otherVector: Vector3): Vector3;
  61357. /**
  61358. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61359. * @param other defines the second operand
  61360. * @returns the current updated Vector3
  61361. */
  61362. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61363. /**
  61364. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61365. * @param other defines the second operand
  61366. * @returns the current updated Vector3
  61367. */
  61368. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61369. /**
  61370. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61371. * @param x defines the x coordinate of the operand
  61372. * @param y defines the y coordinate of the operand
  61373. * @param z defines the z coordinate of the operand
  61374. * @returns the current updated Vector3
  61375. */
  61376. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61377. /**
  61378. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61379. * @param x defines the x coordinate of the operand
  61380. * @param y defines the y coordinate of the operand
  61381. * @param z defines the z coordinate of the operand
  61382. * @returns the current updated Vector3
  61383. */
  61384. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61385. /**
  61386. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61387. * Check if is non uniform within a certain amount of decimal places to account for this
  61388. * @param epsilon the amount the values can differ
  61389. * @returns if the the vector is non uniform to a certain number of decimal places
  61390. */
  61391. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61392. /**
  61393. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61394. */
  61395. readonly isNonUniform: boolean;
  61396. /**
  61397. * Gets a new Vector3 from current Vector3 floored values
  61398. * @returns a new Vector3
  61399. */
  61400. floor(): Vector3;
  61401. /**
  61402. * Gets a new Vector3 from current Vector3 floored values
  61403. * @returns a new Vector3
  61404. */
  61405. fract(): Vector3;
  61406. /**
  61407. * Gets the length of the Vector3
  61408. * @returns the length of the Vecto3
  61409. */
  61410. length(): number;
  61411. /**
  61412. * Gets the squared length of the Vector3
  61413. * @returns squared length of the Vector3
  61414. */
  61415. lengthSquared(): number;
  61416. /**
  61417. * Normalize the current Vector3.
  61418. * Please note that this is an in place operation.
  61419. * @returns the current updated Vector3
  61420. */
  61421. normalize(): Vector3;
  61422. /**
  61423. * Reorders the x y z properties of the vector in place
  61424. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61425. * @returns the current updated vector
  61426. */
  61427. reorderInPlace(order: string): this;
  61428. /**
  61429. * Rotates the vector around 0,0,0 by a quaternion
  61430. * @param quaternion the rotation quaternion
  61431. * @param result vector to store the result
  61432. * @returns the resulting vector
  61433. */
  61434. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61435. /**
  61436. * Rotates a vector around a given point
  61437. * @param quaternion the rotation quaternion
  61438. * @param point the point to rotate around
  61439. * @param result vector to store the result
  61440. * @returns the resulting vector
  61441. */
  61442. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61443. /**
  61444. * Normalize the current Vector3 with the given input length.
  61445. * Please note that this is an in place operation.
  61446. * @param len the length of the vector
  61447. * @returns the current updated Vector3
  61448. */
  61449. normalizeFromLength(len: number): Vector3;
  61450. /**
  61451. * Normalize the current Vector3 to a new vector
  61452. * @returns the new Vector3
  61453. */
  61454. normalizeToNew(): Vector3;
  61455. /**
  61456. * Normalize the current Vector3 to the reference
  61457. * @param reference define the Vector3 to update
  61458. * @returns the updated Vector3
  61459. */
  61460. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61461. /**
  61462. * Creates a new Vector3 copied from the current Vector3
  61463. * @returns the new Vector3
  61464. */
  61465. clone(): Vector3;
  61466. /**
  61467. * Copies the given vector coordinates to the current Vector3 ones
  61468. * @param source defines the source Vector3
  61469. * @returns the current updated Vector3
  61470. */
  61471. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61472. /**
  61473. * Copies the given floats to the current Vector3 coordinates
  61474. * @param x defines the x coordinate of the operand
  61475. * @param y defines the y coordinate of the operand
  61476. * @param z defines the z coordinate of the operand
  61477. * @returns the current updated Vector3
  61478. */
  61479. copyFromFloats(x: number, y: number, z: number): Vector3;
  61480. /**
  61481. * Copies the given floats to the current Vector3 coordinates
  61482. * @param x defines the x coordinate of the operand
  61483. * @param y defines the y coordinate of the operand
  61484. * @param z defines the z coordinate of the operand
  61485. * @returns the current updated Vector3
  61486. */
  61487. set(x: number, y: number, z: number): Vector3;
  61488. /**
  61489. * Copies the given float to the current Vector3 coordinates
  61490. * @param v defines the x, y and z coordinates of the operand
  61491. * @returns the current updated Vector3
  61492. */
  61493. setAll(v: number): Vector3;
  61494. /**
  61495. * Get the clip factor between two vectors
  61496. * @param vector0 defines the first operand
  61497. * @param vector1 defines the second operand
  61498. * @param axis defines the axis to use
  61499. * @param size defines the size along the axis
  61500. * @returns the clip factor
  61501. */
  61502. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61503. /**
  61504. * Get angle between two vectors
  61505. * @param vector0 angle between vector0 and vector1
  61506. * @param vector1 angle between vector0 and vector1
  61507. * @param normal direction of the normal
  61508. * @return the angle between vector0 and vector1
  61509. */
  61510. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61511. /**
  61512. * Returns a new Vector3 set from the index "offset" of the given array
  61513. * @param array defines the source array
  61514. * @param offset defines the offset in the source array
  61515. * @returns the new Vector3
  61516. */
  61517. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61518. /**
  61519. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61520. * This function is deprecated. Use FromArray instead
  61521. * @param array defines the source array
  61522. * @param offset defines the offset in the source array
  61523. * @returns the new Vector3
  61524. */
  61525. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61526. /**
  61527. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61528. * @param array defines the source array
  61529. * @param offset defines the offset in the source array
  61530. * @param result defines the Vector3 where to store the result
  61531. */
  61532. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61533. /**
  61534. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61535. * This function is deprecated. Use FromArrayToRef instead.
  61536. * @param array defines the source array
  61537. * @param offset defines the offset in the source array
  61538. * @param result defines the Vector3 where to store the result
  61539. */
  61540. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61541. /**
  61542. * Sets the given vector "result" with the given floats.
  61543. * @param x defines the x coordinate of the source
  61544. * @param y defines the y coordinate of the source
  61545. * @param z defines the z coordinate of the source
  61546. * @param result defines the Vector3 where to store the result
  61547. */
  61548. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61549. /**
  61550. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61551. * @returns a new empty Vector3
  61552. */
  61553. static Zero(): Vector3;
  61554. /**
  61555. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61556. * @returns a new unit Vector3
  61557. */
  61558. static One(): Vector3;
  61559. /**
  61560. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61561. * @returns a new up Vector3
  61562. */
  61563. static Up(): Vector3;
  61564. /**
  61565. * Gets a up Vector3 that must not be updated
  61566. */
  61567. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61568. /**
  61569. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61570. * @returns a new down Vector3
  61571. */
  61572. static Down(): Vector3;
  61573. /**
  61574. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61575. * @returns a new forward Vector3
  61576. */
  61577. static Forward(): Vector3;
  61578. /**
  61579. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61580. * @returns a new forward Vector3
  61581. */
  61582. static Backward(): Vector3;
  61583. /**
  61584. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61585. * @returns a new right Vector3
  61586. */
  61587. static Right(): Vector3;
  61588. /**
  61589. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61590. * @returns a new left Vector3
  61591. */
  61592. static Left(): Vector3;
  61593. /**
  61594. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61595. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61596. * @param vector defines the Vector3 to transform
  61597. * @param transformation defines the transformation matrix
  61598. * @returns the transformed Vector3
  61599. */
  61600. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61601. /**
  61602. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61603. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61604. * @param vector defines the Vector3 to transform
  61605. * @param transformation defines the transformation matrix
  61606. * @param result defines the Vector3 where to store the result
  61607. */
  61608. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61609. /**
  61610. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61611. * This method computes tranformed coordinates only, not transformed direction vectors
  61612. * @param x define the x coordinate of the source vector
  61613. * @param y define the y coordinate of the source vector
  61614. * @param z define the z coordinate of the source vector
  61615. * @param transformation defines the transformation matrix
  61616. * @param result defines the Vector3 where to store the result
  61617. */
  61618. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61619. /**
  61620. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61621. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61622. * @param vector defines the Vector3 to transform
  61623. * @param transformation defines the transformation matrix
  61624. * @returns the new Vector3
  61625. */
  61626. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61627. /**
  61628. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61629. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61630. * @param vector defines the Vector3 to transform
  61631. * @param transformation defines the transformation matrix
  61632. * @param result defines the Vector3 where to store the result
  61633. */
  61634. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61635. /**
  61636. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61637. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61638. * @param x define the x coordinate of the source vector
  61639. * @param y define the y coordinate of the source vector
  61640. * @param z define the z coordinate of the source vector
  61641. * @param transformation defines the transformation matrix
  61642. * @param result defines the Vector3 where to store the result
  61643. */
  61644. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61645. /**
  61646. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61647. * @param value1 defines the first control point
  61648. * @param value2 defines the second control point
  61649. * @param value3 defines the third control point
  61650. * @param value4 defines the fourth control point
  61651. * @param amount defines the amount on the spline to use
  61652. * @returns the new Vector3
  61653. */
  61654. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61655. /**
  61656. * 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"
  61657. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61658. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61659. * @param value defines the current value
  61660. * @param min defines the lower range value
  61661. * @param max defines the upper range value
  61662. * @returns the new Vector3
  61663. */
  61664. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61665. /**
  61666. * 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"
  61667. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61668. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61669. * @param value defines the current value
  61670. * @param min defines the lower range value
  61671. * @param max defines the upper range value
  61672. * @param result defines the Vector3 where to store the result
  61673. */
  61674. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61675. /**
  61676. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61677. * @param value1 defines the first control point
  61678. * @param tangent1 defines the first tangent vector
  61679. * @param value2 defines the second control point
  61680. * @param tangent2 defines the second tangent vector
  61681. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61682. * @returns the new Vector3
  61683. */
  61684. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61685. /**
  61686. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61687. * @param start defines the start value
  61688. * @param end defines the end value
  61689. * @param amount max defines amount between both (between 0 and 1)
  61690. * @returns the new Vector3
  61691. */
  61692. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61693. /**
  61694. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61695. * @param start defines the start value
  61696. * @param end defines the end value
  61697. * @param amount max defines amount between both (between 0 and 1)
  61698. * @param result defines the Vector3 where to store the result
  61699. */
  61700. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61701. /**
  61702. * Returns the dot product (float) between the vectors "left" and "right"
  61703. * @param left defines the left operand
  61704. * @param right defines the right operand
  61705. * @returns the dot product
  61706. */
  61707. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61708. /**
  61709. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61710. * The cross product is then orthogonal to both "left" and "right"
  61711. * @param left defines the left operand
  61712. * @param right defines the right operand
  61713. * @returns the cross product
  61714. */
  61715. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61716. /**
  61717. * Sets the given vector "result" with the cross product of "left" and "right"
  61718. * The cross product is then orthogonal to both "left" and "right"
  61719. * @param left defines the left operand
  61720. * @param right defines the right operand
  61721. * @param result defines the Vector3 where to store the result
  61722. */
  61723. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61724. /**
  61725. * Returns a new Vector3 as the normalization of the given vector
  61726. * @param vector defines the Vector3 to normalize
  61727. * @returns the new Vector3
  61728. */
  61729. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61730. /**
  61731. * Sets the given vector "result" with the normalization of the given first vector
  61732. * @param vector defines the Vector3 to normalize
  61733. * @param result defines the Vector3 where to store the result
  61734. */
  61735. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61736. /**
  61737. * Project a Vector3 onto screen space
  61738. * @param vector defines the Vector3 to project
  61739. * @param world defines the world matrix to use
  61740. * @param transform defines the transform (view x projection) matrix to use
  61741. * @param viewport defines the screen viewport to use
  61742. * @returns the new Vector3
  61743. */
  61744. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61745. /** @hidden */
  61746. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61747. /**
  61748. * Unproject from screen space to object space
  61749. * @param source defines the screen space Vector3 to use
  61750. * @param viewportWidth defines the current width of the viewport
  61751. * @param viewportHeight defines the current height of the viewport
  61752. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61753. * @param transform defines the transform (view x projection) matrix to use
  61754. * @returns the new Vector3
  61755. */
  61756. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61757. /**
  61758. * Unproject from screen space to object space
  61759. * @param source defines the screen space Vector3 to use
  61760. * @param viewportWidth defines the current width of the viewport
  61761. * @param viewportHeight defines the current height of the viewport
  61762. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61763. * @param view defines the view matrix to use
  61764. * @param projection defines the projection matrix to use
  61765. * @returns the new Vector3
  61766. */
  61767. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61768. /**
  61769. * Unproject from screen space to object space
  61770. * @param source defines the screen space Vector3 to use
  61771. * @param viewportWidth defines the current width of the viewport
  61772. * @param viewportHeight defines the current height of the viewport
  61773. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61774. * @param view defines the view matrix to use
  61775. * @param projection defines the projection matrix to use
  61776. * @param result defines the Vector3 where to store the result
  61777. */
  61778. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61779. /**
  61780. * Unproject from screen space to object space
  61781. * @param sourceX defines the screen space x coordinate to use
  61782. * @param sourceY defines the screen space y coordinate to use
  61783. * @param sourceZ defines the screen space z coordinate to use
  61784. * @param viewportWidth defines the current width of the viewport
  61785. * @param viewportHeight defines the current height of the viewport
  61786. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61787. * @param view defines the view matrix to use
  61788. * @param projection defines the projection matrix to use
  61789. * @param result defines the Vector3 where to store the result
  61790. */
  61791. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61792. /**
  61793. * Gets the minimal coordinate values between two Vector3
  61794. * @param left defines the first operand
  61795. * @param right defines the second operand
  61796. * @returns the new Vector3
  61797. */
  61798. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61799. /**
  61800. * Gets the maximal coordinate values between two Vector3
  61801. * @param left defines the first operand
  61802. * @param right defines the second operand
  61803. * @returns the new Vector3
  61804. */
  61805. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61806. /**
  61807. * Returns the distance between the vectors "value1" and "value2"
  61808. * @param value1 defines the first operand
  61809. * @param value2 defines the second operand
  61810. * @returns the distance
  61811. */
  61812. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61813. /**
  61814. * Returns the squared distance between the vectors "value1" and "value2"
  61815. * @param value1 defines the first operand
  61816. * @param value2 defines the second operand
  61817. * @returns the squared distance
  61818. */
  61819. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61820. /**
  61821. * Returns a new Vector3 located at the center between "value1" and "value2"
  61822. * @param value1 defines the first operand
  61823. * @param value2 defines the second operand
  61824. * @returns the new Vector3
  61825. */
  61826. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61827. /**
  61828. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61829. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61830. * to something in order to rotate it from its local system to the given target system
  61831. * Note: axis1, axis2 and axis3 are normalized during this operation
  61832. * @param axis1 defines the first axis
  61833. * @param axis2 defines the second axis
  61834. * @param axis3 defines the third axis
  61835. * @returns a new Vector3
  61836. */
  61837. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61838. /**
  61839. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61840. * @param axis1 defines the first axis
  61841. * @param axis2 defines the second axis
  61842. * @param axis3 defines the third axis
  61843. * @param ref defines the Vector3 where to store the result
  61844. */
  61845. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61846. }
  61847. /**
  61848. * Vector4 class created for EulerAngle class conversion to Quaternion
  61849. */
  61850. export class Vector4 {
  61851. /** x value of the vector */
  61852. x: number;
  61853. /** y value of the vector */
  61854. y: number;
  61855. /** z value of the vector */
  61856. z: number;
  61857. /** w value of the vector */
  61858. w: number;
  61859. /**
  61860. * Creates a Vector4 object from the given floats.
  61861. * @param x x value of the vector
  61862. * @param y y value of the vector
  61863. * @param z z value of the vector
  61864. * @param w w value of the vector
  61865. */
  61866. constructor(
  61867. /** x value of the vector */
  61868. x: number,
  61869. /** y value of the vector */
  61870. y: number,
  61871. /** z value of the vector */
  61872. z: number,
  61873. /** w value of the vector */
  61874. w: number);
  61875. /**
  61876. * Returns the string with the Vector4 coordinates.
  61877. * @returns a string containing all the vector values
  61878. */
  61879. toString(): string;
  61880. /**
  61881. * Returns the string "Vector4".
  61882. * @returns "Vector4"
  61883. */
  61884. getClassName(): string;
  61885. /**
  61886. * Returns the Vector4 hash code.
  61887. * @returns a unique hash code
  61888. */
  61889. getHashCode(): number;
  61890. /**
  61891. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61892. * @returns the resulting array
  61893. */
  61894. asArray(): number[];
  61895. /**
  61896. * Populates the given array from the given index with the Vector4 coordinates.
  61897. * @param array array to populate
  61898. * @param index index of the array to start at (default: 0)
  61899. * @returns the Vector4.
  61900. */
  61901. toArray(array: FloatArray, index?: number): Vector4;
  61902. /**
  61903. * Adds the given vector to the current Vector4.
  61904. * @param otherVector the vector to add
  61905. * @returns the updated Vector4.
  61906. */
  61907. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61908. /**
  61909. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61910. * @param otherVector the vector to add
  61911. * @returns the resulting vector
  61912. */
  61913. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61914. /**
  61915. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61916. * @param otherVector the vector to add
  61917. * @param result the vector to store the result
  61918. * @returns the current Vector4.
  61919. */
  61920. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61921. /**
  61922. * Subtract in place the given vector from the current Vector4.
  61923. * @param otherVector the vector to subtract
  61924. * @returns the updated Vector4.
  61925. */
  61926. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61927. /**
  61928. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61929. * @param otherVector the vector to add
  61930. * @returns the new vector with the result
  61931. */
  61932. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61933. /**
  61934. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61935. * @param otherVector the vector to subtract
  61936. * @param result the vector to store the result
  61937. * @returns the current Vector4.
  61938. */
  61939. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61940. /**
  61941. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61942. */
  61943. /**
  61944. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61945. * @param x value to subtract
  61946. * @param y value to subtract
  61947. * @param z value to subtract
  61948. * @param w value to subtract
  61949. * @returns new vector containing the result
  61950. */
  61951. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61952. /**
  61953. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61954. * @param x value to subtract
  61955. * @param y value to subtract
  61956. * @param z value to subtract
  61957. * @param w value to subtract
  61958. * @param result the vector to store the result in
  61959. * @returns the current Vector4.
  61960. */
  61961. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61962. /**
  61963. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61964. * @returns a new vector with the negated values
  61965. */
  61966. negate(): Vector4;
  61967. /**
  61968. * Multiplies the current Vector4 coordinates by scale (float).
  61969. * @param scale the number to scale with
  61970. * @returns the updated Vector4.
  61971. */
  61972. scaleInPlace(scale: number): Vector4;
  61973. /**
  61974. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61975. * @param scale the number to scale with
  61976. * @returns a new vector with the result
  61977. */
  61978. scale(scale: number): Vector4;
  61979. /**
  61980. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61981. * @param scale the number to scale with
  61982. * @param result a vector to store the result in
  61983. * @returns the current Vector4.
  61984. */
  61985. scaleToRef(scale: number, result: Vector4): Vector4;
  61986. /**
  61987. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61988. * @param scale defines the scale factor
  61989. * @param result defines the Vector4 object where to store the result
  61990. * @returns the unmodified current Vector4
  61991. */
  61992. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61993. /**
  61994. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61995. * @param otherVector the vector to compare against
  61996. * @returns true if they are equal
  61997. */
  61998. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61999. /**
  62000. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  62001. * @param otherVector vector to compare against
  62002. * @param epsilon (Default: very small number)
  62003. * @returns true if they are equal
  62004. */
  62005. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  62006. /**
  62007. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  62008. * @param x x value to compare against
  62009. * @param y y value to compare against
  62010. * @param z z value to compare against
  62011. * @param w w value to compare against
  62012. * @returns true if equal
  62013. */
  62014. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  62015. /**
  62016. * Multiplies in place the current Vector4 by the given one.
  62017. * @param otherVector vector to multiple with
  62018. * @returns the updated Vector4.
  62019. */
  62020. multiplyInPlace(otherVector: Vector4): Vector4;
  62021. /**
  62022. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  62023. * @param otherVector vector to multiple with
  62024. * @returns resulting new vector
  62025. */
  62026. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  62027. /**
  62028. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  62029. * @param otherVector vector to multiple with
  62030. * @param result vector to store the result
  62031. * @returns the current Vector4.
  62032. */
  62033. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62034. /**
  62035. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  62036. * @param x x value multiply with
  62037. * @param y y value multiply with
  62038. * @param z z value multiply with
  62039. * @param w w value multiply with
  62040. * @returns resulting new vector
  62041. */
  62042. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  62043. /**
  62044. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  62045. * @param otherVector vector to devide with
  62046. * @returns resulting new vector
  62047. */
  62048. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  62049. /**
  62050. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  62051. * @param otherVector vector to devide with
  62052. * @param result vector to store the result
  62053. * @returns the current Vector4.
  62054. */
  62055. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62056. /**
  62057. * Divides the current Vector3 coordinates by the given ones.
  62058. * @param otherVector vector to devide with
  62059. * @returns the updated Vector3.
  62060. */
  62061. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62062. /**
  62063. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  62064. * @param other defines the second operand
  62065. * @returns the current updated Vector4
  62066. */
  62067. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62068. /**
  62069. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  62070. * @param other defines the second operand
  62071. * @returns the current updated Vector4
  62072. */
  62073. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62074. /**
  62075. * Gets a new Vector4 from current Vector4 floored values
  62076. * @returns a new Vector4
  62077. */
  62078. floor(): Vector4;
  62079. /**
  62080. * Gets a new Vector4 from current Vector3 floored values
  62081. * @returns a new Vector4
  62082. */
  62083. fract(): Vector4;
  62084. /**
  62085. * Returns the Vector4 length (float).
  62086. * @returns the length
  62087. */
  62088. length(): number;
  62089. /**
  62090. * Returns the Vector4 squared length (float).
  62091. * @returns the length squared
  62092. */
  62093. lengthSquared(): number;
  62094. /**
  62095. * Normalizes in place the Vector4.
  62096. * @returns the updated Vector4.
  62097. */
  62098. normalize(): Vector4;
  62099. /**
  62100. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  62101. * @returns this converted to a new vector3
  62102. */
  62103. toVector3(): Vector3;
  62104. /**
  62105. * Returns a new Vector4 copied from the current one.
  62106. * @returns the new cloned vector
  62107. */
  62108. clone(): Vector4;
  62109. /**
  62110. * Updates the current Vector4 with the given one coordinates.
  62111. * @param source the source vector to copy from
  62112. * @returns the updated Vector4.
  62113. */
  62114. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  62115. /**
  62116. * Updates the current Vector4 coordinates with the given floats.
  62117. * @param x float to copy from
  62118. * @param y float to copy from
  62119. * @param z float to copy from
  62120. * @param w float to copy from
  62121. * @returns the updated Vector4.
  62122. */
  62123. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62124. /**
  62125. * Updates the current Vector4 coordinates with the given floats.
  62126. * @param x float to set from
  62127. * @param y float to set from
  62128. * @param z float to set from
  62129. * @param w float to set from
  62130. * @returns the updated Vector4.
  62131. */
  62132. set(x: number, y: number, z: number, w: number): Vector4;
  62133. /**
  62134. * Copies the given float to the current Vector3 coordinates
  62135. * @param v defines the x, y, z and w coordinates of the operand
  62136. * @returns the current updated Vector3
  62137. */
  62138. setAll(v: number): Vector4;
  62139. /**
  62140. * Returns a new Vector4 set from the starting index of the given array.
  62141. * @param array the array to pull values from
  62142. * @param offset the offset into the array to start at
  62143. * @returns the new vector
  62144. */
  62145. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  62146. /**
  62147. * Updates the given vector "result" from the starting index of the given array.
  62148. * @param array the array to pull values from
  62149. * @param offset the offset into the array to start at
  62150. * @param result the vector to store the result in
  62151. */
  62152. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  62153. /**
  62154. * Updates the given vector "result" from the starting index of the given Float32Array.
  62155. * @param array the array to pull values from
  62156. * @param offset the offset into the array to start at
  62157. * @param result the vector to store the result in
  62158. */
  62159. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  62160. /**
  62161. * Updates the given vector "result" coordinates from the given floats.
  62162. * @param x float to set from
  62163. * @param y float to set from
  62164. * @param z float to set from
  62165. * @param w float to set from
  62166. * @param result the vector to the floats in
  62167. */
  62168. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  62169. /**
  62170. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  62171. * @returns the new vector
  62172. */
  62173. static Zero(): Vector4;
  62174. /**
  62175. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  62176. * @returns the new vector
  62177. */
  62178. static One(): Vector4;
  62179. /**
  62180. * Returns a new normalized Vector4 from the given one.
  62181. * @param vector the vector to normalize
  62182. * @returns the vector
  62183. */
  62184. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  62185. /**
  62186. * Updates the given vector "result" from the normalization of the given one.
  62187. * @param vector the vector to normalize
  62188. * @param result the vector to store the result in
  62189. */
  62190. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  62191. /**
  62192. * Returns a vector with the minimum values from the left and right vectors
  62193. * @param left left vector to minimize
  62194. * @param right right vector to minimize
  62195. * @returns a new vector with the minimum of the left and right vector values
  62196. */
  62197. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62198. /**
  62199. * Returns a vector with the maximum values from the left and right vectors
  62200. * @param left left vector to maximize
  62201. * @param right right vector to maximize
  62202. * @returns a new vector with the maximum of the left and right vector values
  62203. */
  62204. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62205. /**
  62206. * Returns the distance (float) between the vectors "value1" and "value2".
  62207. * @param value1 value to calulate the distance between
  62208. * @param value2 value to calulate the distance between
  62209. * @return the distance between the two vectors
  62210. */
  62211. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62212. /**
  62213. * Returns the squared distance (float) between the vectors "value1" and "value2".
  62214. * @param value1 value to calulate the distance between
  62215. * @param value2 value to calulate the distance between
  62216. * @return the distance between the two vectors squared
  62217. */
  62218. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62219. /**
  62220. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  62221. * @param value1 value to calulate the center between
  62222. * @param value2 value to calulate the center between
  62223. * @return the center between the two vectors
  62224. */
  62225. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  62226. /**
  62227. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  62228. * This methods computes transformed normalized direction vectors only.
  62229. * @param vector the vector to transform
  62230. * @param transformation the transformation matrix to apply
  62231. * @returns the new vector
  62232. */
  62233. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  62234. /**
  62235. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  62236. * This methods computes transformed normalized direction vectors only.
  62237. * @param vector the vector to transform
  62238. * @param transformation the transformation matrix to apply
  62239. * @param result the vector to store the result in
  62240. */
  62241. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62242. /**
  62243. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  62244. * This methods computes transformed normalized direction vectors only.
  62245. * @param x value to transform
  62246. * @param y value to transform
  62247. * @param z value to transform
  62248. * @param w value to transform
  62249. * @param transformation the transformation matrix to apply
  62250. * @param result the vector to store the results in
  62251. */
  62252. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62253. /**
  62254. * Creates a new Vector4 from a Vector3
  62255. * @param source defines the source data
  62256. * @param w defines the 4th component (default is 0)
  62257. * @returns a new Vector4
  62258. */
  62259. static FromVector3(source: Vector3, w?: number): Vector4;
  62260. }
  62261. /**
  62262. * Interface for the size containing width and height
  62263. */
  62264. export interface ISize {
  62265. /**
  62266. * Width
  62267. */
  62268. width: number;
  62269. /**
  62270. * Heighht
  62271. */
  62272. height: number;
  62273. }
  62274. /**
  62275. * Size containing widht and height
  62276. */
  62277. export class Size implements ISize {
  62278. /**
  62279. * Width
  62280. */
  62281. width: number;
  62282. /**
  62283. * Height
  62284. */
  62285. height: number;
  62286. /**
  62287. * Creates a Size object from the given width and height (floats).
  62288. * @param width width of the new size
  62289. * @param height height of the new size
  62290. */
  62291. constructor(width: number, height: number);
  62292. /**
  62293. * Returns a string with the Size width and height
  62294. * @returns a string with the Size width and height
  62295. */
  62296. toString(): string;
  62297. /**
  62298. * "Size"
  62299. * @returns the string "Size"
  62300. */
  62301. getClassName(): string;
  62302. /**
  62303. * Returns the Size hash code.
  62304. * @returns a hash code for a unique width and height
  62305. */
  62306. getHashCode(): number;
  62307. /**
  62308. * Updates the current size from the given one.
  62309. * @param src the given size
  62310. */
  62311. copyFrom(src: Size): void;
  62312. /**
  62313. * Updates in place the current Size from the given floats.
  62314. * @param width width of the new size
  62315. * @param height height of the new size
  62316. * @returns the updated Size.
  62317. */
  62318. copyFromFloats(width: number, height: number): Size;
  62319. /**
  62320. * Updates in place the current Size from the given floats.
  62321. * @param width width to set
  62322. * @param height height to set
  62323. * @returns the updated Size.
  62324. */
  62325. set(width: number, height: number): Size;
  62326. /**
  62327. * Multiplies the width and height by numbers
  62328. * @param w factor to multiple the width by
  62329. * @param h factor to multiple the height by
  62330. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62331. */
  62332. multiplyByFloats(w: number, h: number): Size;
  62333. /**
  62334. * Clones the size
  62335. * @returns a new Size copied from the given one.
  62336. */
  62337. clone(): Size;
  62338. /**
  62339. * True if the current Size and the given one width and height are strictly equal.
  62340. * @param other the other size to compare against
  62341. * @returns True if the current Size and the given one width and height are strictly equal.
  62342. */
  62343. equals(other: Size): boolean;
  62344. /**
  62345. * The surface of the Size : width * height (float).
  62346. */
  62347. readonly surface: number;
  62348. /**
  62349. * Create a new size of zero
  62350. * @returns a new Size set to (0.0, 0.0)
  62351. */
  62352. static Zero(): Size;
  62353. /**
  62354. * Sums the width and height of two sizes
  62355. * @param otherSize size to add to this size
  62356. * @returns a new Size set as the addition result of the current Size and the given one.
  62357. */
  62358. add(otherSize: Size): Size;
  62359. /**
  62360. * Subtracts the width and height of two
  62361. * @param otherSize size to subtract to this size
  62362. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62363. */
  62364. subtract(otherSize: Size): Size;
  62365. /**
  62366. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62367. * @param start starting size to lerp between
  62368. * @param end end size to lerp between
  62369. * @param amount amount to lerp between the start and end values
  62370. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62371. */
  62372. static Lerp(start: Size, end: Size, amount: number): Size;
  62373. }
  62374. /**
  62375. * Class used to store quaternion data
  62376. * @see https://en.wikipedia.org/wiki/Quaternion
  62377. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62378. */
  62379. export class Quaternion {
  62380. /** defines the first component (0 by default) */
  62381. x: number;
  62382. /** defines the second component (0 by default) */
  62383. y: number;
  62384. /** defines the third component (0 by default) */
  62385. z: number;
  62386. /** defines the fourth component (1.0 by default) */
  62387. w: number;
  62388. /**
  62389. * Creates a new Quaternion from the given floats
  62390. * @param x defines the first component (0 by default)
  62391. * @param y defines the second component (0 by default)
  62392. * @param z defines the third component (0 by default)
  62393. * @param w defines the fourth component (1.0 by default)
  62394. */
  62395. constructor(
  62396. /** defines the first component (0 by default) */
  62397. x?: number,
  62398. /** defines the second component (0 by default) */
  62399. y?: number,
  62400. /** defines the third component (0 by default) */
  62401. z?: number,
  62402. /** defines the fourth component (1.0 by default) */
  62403. w?: number);
  62404. /**
  62405. * Gets a string representation for the current quaternion
  62406. * @returns a string with the Quaternion coordinates
  62407. */
  62408. toString(): string;
  62409. /**
  62410. * Gets the class name of the quaternion
  62411. * @returns the string "Quaternion"
  62412. */
  62413. getClassName(): string;
  62414. /**
  62415. * Gets a hash code for this quaternion
  62416. * @returns the quaternion hash code
  62417. */
  62418. getHashCode(): number;
  62419. /**
  62420. * Copy the quaternion to an array
  62421. * @returns a new array populated with 4 elements from the quaternion coordinates
  62422. */
  62423. asArray(): number[];
  62424. /**
  62425. * Check if two quaternions are equals
  62426. * @param otherQuaternion defines the second operand
  62427. * @return true if the current quaternion and the given one coordinates are strictly equals
  62428. */
  62429. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62430. /**
  62431. * Clone the current quaternion
  62432. * @returns a new quaternion copied from the current one
  62433. */
  62434. clone(): Quaternion;
  62435. /**
  62436. * Copy a quaternion to the current one
  62437. * @param other defines the other quaternion
  62438. * @returns the updated current quaternion
  62439. */
  62440. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62441. /**
  62442. * Updates the current quaternion with the given float coordinates
  62443. * @param x defines the x coordinate
  62444. * @param y defines the y coordinate
  62445. * @param z defines the z coordinate
  62446. * @param w defines the w coordinate
  62447. * @returns the updated current quaternion
  62448. */
  62449. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62450. /**
  62451. * Updates the current quaternion from the given float coordinates
  62452. * @param x defines the x coordinate
  62453. * @param y defines the y coordinate
  62454. * @param z defines the z coordinate
  62455. * @param w defines the w coordinate
  62456. * @returns the updated current quaternion
  62457. */
  62458. set(x: number, y: number, z: number, w: number): Quaternion;
  62459. /**
  62460. * Adds two quaternions
  62461. * @param other defines the second operand
  62462. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62463. */
  62464. add(other: DeepImmutable<Quaternion>): Quaternion;
  62465. /**
  62466. * Add a quaternion to the current one
  62467. * @param other defines the quaternion to add
  62468. * @returns the current quaternion
  62469. */
  62470. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62471. /**
  62472. * Subtract two quaternions
  62473. * @param other defines the second operand
  62474. * @returns a new quaternion as the subtraction result of the given one from the current one
  62475. */
  62476. subtract(other: Quaternion): Quaternion;
  62477. /**
  62478. * Multiplies the current quaternion by a scale factor
  62479. * @param value defines the scale factor
  62480. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62481. */
  62482. scale(value: number): Quaternion;
  62483. /**
  62484. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62485. * @param scale defines the scale factor
  62486. * @param result defines the Quaternion object where to store the result
  62487. * @returns the unmodified current quaternion
  62488. */
  62489. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62490. /**
  62491. * Multiplies in place the current quaternion by a scale factor
  62492. * @param value defines the scale factor
  62493. * @returns the current modified quaternion
  62494. */
  62495. scaleInPlace(value: number): Quaternion;
  62496. /**
  62497. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62498. * @param scale defines the scale factor
  62499. * @param result defines the Quaternion object where to store the result
  62500. * @returns the unmodified current quaternion
  62501. */
  62502. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62503. /**
  62504. * Multiplies two quaternions
  62505. * @param q1 defines the second operand
  62506. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62507. */
  62508. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62509. /**
  62510. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62511. * @param q1 defines the second operand
  62512. * @param result defines the target quaternion
  62513. * @returns the current quaternion
  62514. */
  62515. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62516. /**
  62517. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62518. * @param q1 defines the second operand
  62519. * @returns the currentupdated quaternion
  62520. */
  62521. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62522. /**
  62523. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62524. * @param ref defines the target quaternion
  62525. * @returns the current quaternion
  62526. */
  62527. conjugateToRef(ref: Quaternion): Quaternion;
  62528. /**
  62529. * Conjugates in place (1-q) the current quaternion
  62530. * @returns the current updated quaternion
  62531. */
  62532. conjugateInPlace(): Quaternion;
  62533. /**
  62534. * Conjugates in place (1-q) the current quaternion
  62535. * @returns a new quaternion
  62536. */
  62537. conjugate(): Quaternion;
  62538. /**
  62539. * Gets length of current quaternion
  62540. * @returns the quaternion length (float)
  62541. */
  62542. length(): number;
  62543. /**
  62544. * Normalize in place the current quaternion
  62545. * @returns the current updated quaternion
  62546. */
  62547. normalize(): Quaternion;
  62548. /**
  62549. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62550. * @param order is a reserved parameter and is ignore for now
  62551. * @returns a new Vector3 containing the Euler angles
  62552. */
  62553. toEulerAngles(order?: string): Vector3;
  62554. /**
  62555. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62556. * @param result defines the vector which will be filled with the Euler angles
  62557. * @param order is a reserved parameter and is ignore for now
  62558. * @returns the current unchanged quaternion
  62559. */
  62560. toEulerAnglesToRef(result: Vector3): Quaternion;
  62561. /**
  62562. * Updates the given rotation matrix with the current quaternion values
  62563. * @param result defines the target matrix
  62564. * @returns the current unchanged quaternion
  62565. */
  62566. toRotationMatrix(result: Matrix): Quaternion;
  62567. /**
  62568. * Updates the current quaternion from the given rotation matrix values
  62569. * @param matrix defines the source matrix
  62570. * @returns the current updated quaternion
  62571. */
  62572. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62573. /**
  62574. * Creates a new quaternion from a rotation matrix
  62575. * @param matrix defines the source matrix
  62576. * @returns a new quaternion created from the given rotation matrix values
  62577. */
  62578. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62579. /**
  62580. * Updates the given quaternion with the given rotation matrix values
  62581. * @param matrix defines the source matrix
  62582. * @param result defines the target quaternion
  62583. */
  62584. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62585. /**
  62586. * Returns the dot product (float) between the quaternions "left" and "right"
  62587. * @param left defines the left operand
  62588. * @param right defines the right operand
  62589. * @returns the dot product
  62590. */
  62591. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62592. /**
  62593. * Checks if the two quaternions are close to each other
  62594. * @param quat0 defines the first quaternion to check
  62595. * @param quat1 defines the second quaternion to check
  62596. * @returns true if the two quaternions are close to each other
  62597. */
  62598. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62599. /**
  62600. * Creates an empty quaternion
  62601. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62602. */
  62603. static Zero(): Quaternion;
  62604. /**
  62605. * Inverse a given quaternion
  62606. * @param q defines the source quaternion
  62607. * @returns a new quaternion as the inverted current quaternion
  62608. */
  62609. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62610. /**
  62611. * Inverse a given quaternion
  62612. * @param q defines the source quaternion
  62613. * @param result the quaternion the result will be stored in
  62614. * @returns the result quaternion
  62615. */
  62616. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62617. /**
  62618. * Creates an identity quaternion
  62619. * @returns the identity quaternion
  62620. */
  62621. static Identity(): Quaternion;
  62622. /**
  62623. * Gets a boolean indicating if the given quaternion is identity
  62624. * @param quaternion defines the quaternion to check
  62625. * @returns true if the quaternion is identity
  62626. */
  62627. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62628. /**
  62629. * Creates a quaternion from a rotation around an axis
  62630. * @param axis defines the axis to use
  62631. * @param angle defines the angle to use
  62632. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62633. */
  62634. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62635. /**
  62636. * Creates a rotation around an axis and stores it into the given quaternion
  62637. * @param axis defines the axis to use
  62638. * @param angle defines the angle to use
  62639. * @param result defines the target quaternion
  62640. * @returns the target quaternion
  62641. */
  62642. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62643. /**
  62644. * Creates a new quaternion from data stored into an array
  62645. * @param array defines the data source
  62646. * @param offset defines the offset in the source array where the data starts
  62647. * @returns a new quaternion
  62648. */
  62649. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62650. /**
  62651. * Create a quaternion from Euler rotation angles
  62652. * @param x Pitch
  62653. * @param y Yaw
  62654. * @param z Roll
  62655. * @returns the new Quaternion
  62656. */
  62657. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62658. /**
  62659. * Updates a quaternion from Euler rotation angles
  62660. * @param x Pitch
  62661. * @param y Yaw
  62662. * @param z Roll
  62663. * @param result the quaternion to store the result
  62664. * @returns the updated quaternion
  62665. */
  62666. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62667. /**
  62668. * Create a quaternion from Euler rotation vector
  62669. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62670. * @returns the new Quaternion
  62671. */
  62672. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62673. /**
  62674. * Updates a quaternion from Euler rotation vector
  62675. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62676. * @param result the quaternion to store the result
  62677. * @returns the updated quaternion
  62678. */
  62679. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62680. /**
  62681. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62682. * @param yaw defines the rotation around Y axis
  62683. * @param pitch defines the rotation around X axis
  62684. * @param roll defines the rotation around Z axis
  62685. * @returns the new quaternion
  62686. */
  62687. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62688. /**
  62689. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62690. * @param yaw defines the rotation around Y axis
  62691. * @param pitch defines the rotation around X axis
  62692. * @param roll defines the rotation around Z axis
  62693. * @param result defines the target quaternion
  62694. */
  62695. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62696. /**
  62697. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62698. * @param alpha defines the rotation around first axis
  62699. * @param beta defines the rotation around second axis
  62700. * @param gamma defines the rotation around third axis
  62701. * @returns the new quaternion
  62702. */
  62703. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62704. /**
  62705. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62706. * @param alpha defines the rotation around first axis
  62707. * @param beta defines the rotation around second axis
  62708. * @param gamma defines the rotation around third axis
  62709. * @param result defines the target quaternion
  62710. */
  62711. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62712. /**
  62713. * 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)
  62714. * @param axis1 defines the first axis
  62715. * @param axis2 defines the second axis
  62716. * @param axis3 defines the third axis
  62717. * @returns the new quaternion
  62718. */
  62719. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62720. /**
  62721. * 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
  62722. * @param axis1 defines the first axis
  62723. * @param axis2 defines the second axis
  62724. * @param axis3 defines the third axis
  62725. * @param ref defines the target quaternion
  62726. */
  62727. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62728. /**
  62729. * Interpolates between two quaternions
  62730. * @param left defines first quaternion
  62731. * @param right defines second quaternion
  62732. * @param amount defines the gradient to use
  62733. * @returns the new interpolated quaternion
  62734. */
  62735. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62736. /**
  62737. * Interpolates between two quaternions and stores it into a target quaternion
  62738. * @param left defines first quaternion
  62739. * @param right defines second quaternion
  62740. * @param amount defines the gradient to use
  62741. * @param result defines the target quaternion
  62742. */
  62743. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62744. /**
  62745. * Interpolate between two quaternions using Hermite interpolation
  62746. * @param value1 defines first quaternion
  62747. * @param tangent1 defines the incoming tangent
  62748. * @param value2 defines second quaternion
  62749. * @param tangent2 defines the outgoing tangent
  62750. * @param amount defines the target quaternion
  62751. * @returns the new interpolated quaternion
  62752. */
  62753. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62754. }
  62755. /**
  62756. * Class used to store matrix data (4x4)
  62757. */
  62758. export class Matrix {
  62759. private static _updateFlagSeed;
  62760. private static _identityReadOnly;
  62761. private _isIdentity;
  62762. private _isIdentityDirty;
  62763. private _isIdentity3x2;
  62764. private _isIdentity3x2Dirty;
  62765. /**
  62766. * Gets the update flag of the matrix which is an unique number for the matrix.
  62767. * It will be incremented every time the matrix data change.
  62768. * You can use it to speed the comparison between two versions of the same matrix.
  62769. */
  62770. updateFlag: number;
  62771. private readonly _m;
  62772. /**
  62773. * Gets the internal data of the matrix
  62774. */
  62775. readonly m: DeepImmutable<Float32Array>;
  62776. /** @hidden */
  62777. _markAsUpdated(): void;
  62778. /** @hidden */
  62779. private _updateIdentityStatus;
  62780. /**
  62781. * Creates an empty matrix (filled with zeros)
  62782. */
  62783. constructor();
  62784. /**
  62785. * Check if the current matrix is identity
  62786. * @returns true is the matrix is the identity matrix
  62787. */
  62788. isIdentity(): boolean;
  62789. /**
  62790. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62791. * @returns true is the matrix is the identity matrix
  62792. */
  62793. isIdentityAs3x2(): boolean;
  62794. /**
  62795. * Gets the determinant of the matrix
  62796. * @returns the matrix determinant
  62797. */
  62798. determinant(): number;
  62799. /**
  62800. * Returns the matrix as a Float32Array
  62801. * @returns the matrix underlying array
  62802. */
  62803. toArray(): DeepImmutable<Float32Array>;
  62804. /**
  62805. * Returns the matrix as a Float32Array
  62806. * @returns the matrix underlying array.
  62807. */
  62808. asArray(): DeepImmutable<Float32Array>;
  62809. /**
  62810. * Inverts the current matrix in place
  62811. * @returns the current inverted matrix
  62812. */
  62813. invert(): Matrix;
  62814. /**
  62815. * Sets all the matrix elements to zero
  62816. * @returns the current matrix
  62817. */
  62818. reset(): Matrix;
  62819. /**
  62820. * Adds the current matrix with a second one
  62821. * @param other defines the matrix to add
  62822. * @returns a new matrix as the addition of the current matrix and the given one
  62823. */
  62824. add(other: DeepImmutable<Matrix>): Matrix;
  62825. /**
  62826. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62827. * @param other defines the matrix to add
  62828. * @param result defines the target matrix
  62829. * @returns the current matrix
  62830. */
  62831. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62832. /**
  62833. * Adds in place the given matrix to the current matrix
  62834. * @param other defines the second operand
  62835. * @returns the current updated matrix
  62836. */
  62837. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62838. /**
  62839. * Sets the given matrix to the current inverted Matrix
  62840. * @param other defines the target matrix
  62841. * @returns the unmodified current matrix
  62842. */
  62843. invertToRef(other: Matrix): Matrix;
  62844. /**
  62845. * add a value at the specified position in the current Matrix
  62846. * @param index the index of the value within the matrix. between 0 and 15.
  62847. * @param value the value to be added
  62848. * @returns the current updated matrix
  62849. */
  62850. addAtIndex(index: number, value: number): Matrix;
  62851. /**
  62852. * mutiply the specified position in the current Matrix by a value
  62853. * @param index the index of the value within the matrix. between 0 and 15.
  62854. * @param value the value to be added
  62855. * @returns the current updated matrix
  62856. */
  62857. multiplyAtIndex(index: number, value: number): Matrix;
  62858. /**
  62859. * Inserts the translation vector (using 3 floats) in the current matrix
  62860. * @param x defines the 1st component of the translation
  62861. * @param y defines the 2nd component of the translation
  62862. * @param z defines the 3rd component of the translation
  62863. * @returns the current updated matrix
  62864. */
  62865. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62866. /**
  62867. * Adds the translation vector (using 3 floats) in the current matrix
  62868. * @param x defines the 1st component of the translation
  62869. * @param y defines the 2nd component of the translation
  62870. * @param z defines the 3rd component of the translation
  62871. * @returns the current updated matrix
  62872. */
  62873. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62874. /**
  62875. * Inserts the translation vector in the current matrix
  62876. * @param vector3 defines the translation to insert
  62877. * @returns the current updated matrix
  62878. */
  62879. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62880. /**
  62881. * Gets the translation value of the current matrix
  62882. * @returns a new Vector3 as the extracted translation from the matrix
  62883. */
  62884. getTranslation(): Vector3;
  62885. /**
  62886. * Fill a Vector3 with the extracted translation from the matrix
  62887. * @param result defines the Vector3 where to store the translation
  62888. * @returns the current matrix
  62889. */
  62890. getTranslationToRef(result: Vector3): Matrix;
  62891. /**
  62892. * Remove rotation and scaling part from the matrix
  62893. * @returns the updated matrix
  62894. */
  62895. removeRotationAndScaling(): Matrix;
  62896. /**
  62897. * Multiply two matrices
  62898. * @param other defines the second operand
  62899. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62900. */
  62901. multiply(other: DeepImmutable<Matrix>): Matrix;
  62902. /**
  62903. * Copy the current matrix from the given one
  62904. * @param other defines the source matrix
  62905. * @returns the current updated matrix
  62906. */
  62907. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62908. /**
  62909. * Populates the given array from the starting index with the current matrix values
  62910. * @param array defines the target array
  62911. * @param offset defines the offset in the target array where to start storing values
  62912. * @returns the current matrix
  62913. */
  62914. copyToArray(array: Float32Array, offset?: number): Matrix;
  62915. /**
  62916. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62917. * @param other defines the second operand
  62918. * @param result defines the matrix where to store the multiplication
  62919. * @returns the current matrix
  62920. */
  62921. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62922. /**
  62923. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62924. * @param other defines the second operand
  62925. * @param result defines the array where to store the multiplication
  62926. * @param offset defines the offset in the target array where to start storing values
  62927. * @returns the current matrix
  62928. */
  62929. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62930. /**
  62931. * Check equality between this matrix and a second one
  62932. * @param value defines the second matrix to compare
  62933. * @returns true is the current matrix and the given one values are strictly equal
  62934. */
  62935. equals(value: DeepImmutable<Matrix>): boolean;
  62936. /**
  62937. * Clone the current matrix
  62938. * @returns a new matrix from the current matrix
  62939. */
  62940. clone(): Matrix;
  62941. /**
  62942. * Returns the name of the current matrix class
  62943. * @returns the string "Matrix"
  62944. */
  62945. getClassName(): string;
  62946. /**
  62947. * Gets the hash code of the current matrix
  62948. * @returns the hash code
  62949. */
  62950. getHashCode(): number;
  62951. /**
  62952. * Decomposes the current Matrix into a translation, rotation and scaling components
  62953. * @param scale defines the scale vector3 given as a reference to update
  62954. * @param rotation defines the rotation quaternion given as a reference to update
  62955. * @param translation defines the translation vector3 given as a reference to update
  62956. * @returns true if operation was successful
  62957. */
  62958. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62959. /**
  62960. * Gets specific row of the matrix
  62961. * @param index defines the number of the row to get
  62962. * @returns the index-th row of the current matrix as a new Vector4
  62963. */
  62964. getRow(index: number): Nullable<Vector4>;
  62965. /**
  62966. * Sets the index-th row of the current matrix to the vector4 values
  62967. * @param index defines the number of the row to set
  62968. * @param row defines the target vector4
  62969. * @returns the updated current matrix
  62970. */
  62971. setRow(index: number, row: Vector4): Matrix;
  62972. /**
  62973. * Compute the transpose of the matrix
  62974. * @returns the new transposed matrix
  62975. */
  62976. transpose(): Matrix;
  62977. /**
  62978. * Compute the transpose of the matrix and store it in a given matrix
  62979. * @param result defines the target matrix
  62980. * @returns the current matrix
  62981. */
  62982. transposeToRef(result: Matrix): Matrix;
  62983. /**
  62984. * Sets the index-th row of the current matrix with the given 4 x float values
  62985. * @param index defines the row index
  62986. * @param x defines the x component to set
  62987. * @param y defines the y component to set
  62988. * @param z defines the z component to set
  62989. * @param w defines the w component to set
  62990. * @returns the updated current matrix
  62991. */
  62992. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62993. /**
  62994. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62995. * @param scale defines the scale factor
  62996. * @returns a new matrix
  62997. */
  62998. scale(scale: number): Matrix;
  62999. /**
  63000. * Scale the current matrix values by a factor to a given result matrix
  63001. * @param scale defines the scale factor
  63002. * @param result defines the matrix to store the result
  63003. * @returns the current matrix
  63004. */
  63005. scaleToRef(scale: number, result: Matrix): Matrix;
  63006. /**
  63007. * Scale the current matrix values by a factor and add the result to a given matrix
  63008. * @param scale defines the scale factor
  63009. * @param result defines the Matrix to store the result
  63010. * @returns the current matrix
  63011. */
  63012. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  63013. /**
  63014. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  63015. * @param ref matrix to store the result
  63016. */
  63017. toNormalMatrix(ref: Matrix): void;
  63018. /**
  63019. * Gets only rotation part of the current matrix
  63020. * @returns a new matrix sets to the extracted rotation matrix from the current one
  63021. */
  63022. getRotationMatrix(): Matrix;
  63023. /**
  63024. * Extracts the rotation matrix from the current one and sets it as the given "result"
  63025. * @param result defines the target matrix to store data to
  63026. * @returns the current matrix
  63027. */
  63028. getRotationMatrixToRef(result: Matrix): Matrix;
  63029. /**
  63030. * Toggles model matrix from being right handed to left handed in place and vice versa
  63031. */
  63032. toggleModelMatrixHandInPlace(): void;
  63033. /**
  63034. * Toggles projection matrix from being right handed to left handed in place and vice versa
  63035. */
  63036. toggleProjectionMatrixHandInPlace(): void;
  63037. /**
  63038. * Creates a matrix from an array
  63039. * @param array defines the source array
  63040. * @param offset defines an offset in the source array
  63041. * @returns a new Matrix set from the starting index of the given array
  63042. */
  63043. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  63044. /**
  63045. * Copy the content of an array into a given matrix
  63046. * @param array defines the source array
  63047. * @param offset defines an offset in the source array
  63048. * @param result defines the target matrix
  63049. */
  63050. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  63051. /**
  63052. * Stores an array into a matrix after having multiplied each component by a given factor
  63053. * @param array defines the source array
  63054. * @param offset defines the offset in the source array
  63055. * @param scale defines the scaling factor
  63056. * @param result defines the target matrix
  63057. */
  63058. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  63059. /**
  63060. * Gets an identity matrix that must not be updated
  63061. */
  63062. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  63063. /**
  63064. * Stores a list of values (16) inside a given matrix
  63065. * @param initialM11 defines 1st value of 1st row
  63066. * @param initialM12 defines 2nd value of 1st row
  63067. * @param initialM13 defines 3rd value of 1st row
  63068. * @param initialM14 defines 4th value of 1st row
  63069. * @param initialM21 defines 1st value of 2nd row
  63070. * @param initialM22 defines 2nd value of 2nd row
  63071. * @param initialM23 defines 3rd value of 2nd row
  63072. * @param initialM24 defines 4th value of 2nd row
  63073. * @param initialM31 defines 1st value of 3rd row
  63074. * @param initialM32 defines 2nd value of 3rd row
  63075. * @param initialM33 defines 3rd value of 3rd row
  63076. * @param initialM34 defines 4th value of 3rd row
  63077. * @param initialM41 defines 1st value of 4th row
  63078. * @param initialM42 defines 2nd value of 4th row
  63079. * @param initialM43 defines 3rd value of 4th row
  63080. * @param initialM44 defines 4th value of 4th row
  63081. * @param result defines the target matrix
  63082. */
  63083. 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;
  63084. /**
  63085. * Creates new matrix from a list of values (16)
  63086. * @param initialM11 defines 1st value of 1st row
  63087. * @param initialM12 defines 2nd value of 1st row
  63088. * @param initialM13 defines 3rd value of 1st row
  63089. * @param initialM14 defines 4th value of 1st row
  63090. * @param initialM21 defines 1st value of 2nd row
  63091. * @param initialM22 defines 2nd value of 2nd row
  63092. * @param initialM23 defines 3rd value of 2nd row
  63093. * @param initialM24 defines 4th value of 2nd row
  63094. * @param initialM31 defines 1st value of 3rd row
  63095. * @param initialM32 defines 2nd value of 3rd row
  63096. * @param initialM33 defines 3rd value of 3rd row
  63097. * @param initialM34 defines 4th value of 3rd row
  63098. * @param initialM41 defines 1st value of 4th row
  63099. * @param initialM42 defines 2nd value of 4th row
  63100. * @param initialM43 defines 3rd value of 4th row
  63101. * @param initialM44 defines 4th value of 4th row
  63102. * @returns the new matrix
  63103. */
  63104. 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;
  63105. /**
  63106. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63107. * @param scale defines the scale vector3
  63108. * @param rotation defines the rotation quaternion
  63109. * @param translation defines the translation vector3
  63110. * @returns a new matrix
  63111. */
  63112. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  63113. /**
  63114. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63115. * @param scale defines the scale vector3
  63116. * @param rotation defines the rotation quaternion
  63117. * @param translation defines the translation vector3
  63118. * @param result defines the target matrix
  63119. */
  63120. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  63121. /**
  63122. * Creates a new identity matrix
  63123. * @returns a new identity matrix
  63124. */
  63125. static Identity(): Matrix;
  63126. /**
  63127. * Creates a new identity matrix and stores the result in a given matrix
  63128. * @param result defines the target matrix
  63129. */
  63130. static IdentityToRef(result: Matrix): void;
  63131. /**
  63132. * Creates a new zero matrix
  63133. * @returns a new zero matrix
  63134. */
  63135. static Zero(): Matrix;
  63136. /**
  63137. * Creates a new rotation matrix for "angle" radians around the X axis
  63138. * @param angle defines the angle (in radians) to use
  63139. * @return the new matrix
  63140. */
  63141. static RotationX(angle: number): Matrix;
  63142. /**
  63143. * Creates a new matrix as the invert of a given matrix
  63144. * @param source defines the source matrix
  63145. * @returns the new matrix
  63146. */
  63147. static Invert(source: DeepImmutable<Matrix>): Matrix;
  63148. /**
  63149. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  63150. * @param angle defines the angle (in radians) to use
  63151. * @param result defines the target matrix
  63152. */
  63153. static RotationXToRef(angle: number, result: Matrix): void;
  63154. /**
  63155. * Creates a new rotation matrix for "angle" radians around the Y axis
  63156. * @param angle defines the angle (in radians) to use
  63157. * @return the new matrix
  63158. */
  63159. static RotationY(angle: number): Matrix;
  63160. /**
  63161. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  63162. * @param angle defines the angle (in radians) to use
  63163. * @param result defines the target matrix
  63164. */
  63165. static RotationYToRef(angle: number, result: Matrix): void;
  63166. /**
  63167. * Creates a new rotation matrix for "angle" radians around the Z axis
  63168. * @param angle defines the angle (in radians) to use
  63169. * @return the new matrix
  63170. */
  63171. static RotationZ(angle: number): Matrix;
  63172. /**
  63173. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  63174. * @param angle defines the angle (in radians) to use
  63175. * @param result defines the target matrix
  63176. */
  63177. static RotationZToRef(angle: number, result: Matrix): void;
  63178. /**
  63179. * Creates a new rotation matrix for "angle" radians around the given axis
  63180. * @param axis defines the axis to use
  63181. * @param angle defines the angle (in radians) to use
  63182. * @return the new matrix
  63183. */
  63184. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  63185. /**
  63186. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  63187. * @param axis defines the axis to use
  63188. * @param angle defines the angle (in radians) to use
  63189. * @param result defines the target matrix
  63190. */
  63191. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  63192. /**
  63193. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  63194. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  63195. * @param from defines the vector to align
  63196. * @param to defines the vector to align to
  63197. * @param result defines the target matrix
  63198. */
  63199. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  63200. /**
  63201. * Creates a rotation matrix
  63202. * @param yaw defines the yaw angle in radians (Y axis)
  63203. * @param pitch defines the pitch angle in radians (X axis)
  63204. * @param roll defines the roll angle in radians (X axis)
  63205. * @returns the new rotation matrix
  63206. */
  63207. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  63208. /**
  63209. * Creates a rotation matrix and stores it in a given matrix
  63210. * @param yaw defines the yaw angle in radians (Y axis)
  63211. * @param pitch defines the pitch angle in radians (X axis)
  63212. * @param roll defines the roll angle in radians (X axis)
  63213. * @param result defines the target matrix
  63214. */
  63215. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  63216. /**
  63217. * Creates a scaling matrix
  63218. * @param x defines the scale factor on X axis
  63219. * @param y defines the scale factor on Y axis
  63220. * @param z defines the scale factor on Z axis
  63221. * @returns the new matrix
  63222. */
  63223. static Scaling(x: number, y: number, z: number): Matrix;
  63224. /**
  63225. * Creates a scaling matrix and stores it in a given matrix
  63226. * @param x defines the scale factor on X axis
  63227. * @param y defines the scale factor on Y axis
  63228. * @param z defines the scale factor on Z axis
  63229. * @param result defines the target matrix
  63230. */
  63231. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  63232. /**
  63233. * Creates a translation matrix
  63234. * @param x defines the translation on X axis
  63235. * @param y defines the translation on Y axis
  63236. * @param z defines the translationon Z axis
  63237. * @returns the new matrix
  63238. */
  63239. static Translation(x: number, y: number, z: number): Matrix;
  63240. /**
  63241. * Creates a translation matrix and stores it in a given matrix
  63242. * @param x defines the translation on X axis
  63243. * @param y defines the translation on Y axis
  63244. * @param z defines the translationon Z axis
  63245. * @param result defines the target matrix
  63246. */
  63247. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  63248. /**
  63249. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63250. * @param startValue defines the start value
  63251. * @param endValue defines the end value
  63252. * @param gradient defines the gradient factor
  63253. * @returns the new matrix
  63254. */
  63255. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63256. /**
  63257. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63258. * @param startValue defines the start value
  63259. * @param endValue defines the end value
  63260. * @param gradient defines the gradient factor
  63261. * @param result defines the Matrix object where to store data
  63262. */
  63263. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63264. /**
  63265. * Builds a new matrix whose values are computed by:
  63266. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63267. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63268. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63269. * @param startValue defines the first matrix
  63270. * @param endValue defines the second matrix
  63271. * @param gradient defines the gradient between the two matrices
  63272. * @returns the new matrix
  63273. */
  63274. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63275. /**
  63276. * Update a matrix to values which are computed by:
  63277. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63278. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63279. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63280. * @param startValue defines the first matrix
  63281. * @param endValue defines the second matrix
  63282. * @param gradient defines the gradient between the two matrices
  63283. * @param result defines the target matrix
  63284. */
  63285. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63286. /**
  63287. * 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"
  63288. * This function works in left handed mode
  63289. * @param eye defines the final position of the entity
  63290. * @param target defines where the entity should look at
  63291. * @param up defines the up vector for the entity
  63292. * @returns the new matrix
  63293. */
  63294. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63295. /**
  63296. * 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".
  63297. * This function works in left handed mode
  63298. * @param eye defines the final position of the entity
  63299. * @param target defines where the entity should look at
  63300. * @param up defines the up vector for the entity
  63301. * @param result defines the target matrix
  63302. */
  63303. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63304. /**
  63305. * 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"
  63306. * This function works in right handed mode
  63307. * @param eye defines the final position of the entity
  63308. * @param target defines where the entity should look at
  63309. * @param up defines the up vector for the entity
  63310. * @returns the new matrix
  63311. */
  63312. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63313. /**
  63314. * 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".
  63315. * This function works in right handed mode
  63316. * @param eye defines the final position of the entity
  63317. * @param target defines where the entity should look at
  63318. * @param up defines the up vector for the entity
  63319. * @param result defines the target matrix
  63320. */
  63321. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63322. /**
  63323. * Create a left-handed orthographic projection matrix
  63324. * @param width defines the viewport width
  63325. * @param height defines the viewport height
  63326. * @param znear defines the near clip plane
  63327. * @param zfar defines the far clip plane
  63328. * @returns a new matrix as a left-handed orthographic projection matrix
  63329. */
  63330. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63331. /**
  63332. * Store a left-handed orthographic projection to a given matrix
  63333. * @param width defines the viewport width
  63334. * @param height defines the viewport height
  63335. * @param znear defines the near clip plane
  63336. * @param zfar defines the far clip plane
  63337. * @param result defines the target matrix
  63338. */
  63339. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63340. /**
  63341. * Create a left-handed orthographic projection matrix
  63342. * @param left defines the viewport left coordinate
  63343. * @param right defines the viewport right coordinate
  63344. * @param bottom defines the viewport bottom coordinate
  63345. * @param top defines the viewport top coordinate
  63346. * @param znear defines the near clip plane
  63347. * @param zfar defines the far clip plane
  63348. * @returns a new matrix as a left-handed orthographic projection matrix
  63349. */
  63350. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63351. /**
  63352. * Stores a left-handed orthographic projection into a given matrix
  63353. * @param left defines the viewport left coordinate
  63354. * @param right defines the viewport right coordinate
  63355. * @param bottom defines the viewport bottom coordinate
  63356. * @param top defines the viewport top coordinate
  63357. * @param znear defines the near clip plane
  63358. * @param zfar defines the far clip plane
  63359. * @param result defines the target matrix
  63360. */
  63361. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63362. /**
  63363. * Creates a right-handed orthographic projection matrix
  63364. * @param left defines the viewport left coordinate
  63365. * @param right defines the viewport right coordinate
  63366. * @param bottom defines the viewport bottom coordinate
  63367. * @param top defines the viewport top coordinate
  63368. * @param znear defines the near clip plane
  63369. * @param zfar defines the far clip plane
  63370. * @returns a new matrix as a right-handed orthographic projection matrix
  63371. */
  63372. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63373. /**
  63374. * Stores a right-handed orthographic projection into a given matrix
  63375. * @param left defines the viewport left coordinate
  63376. * @param right defines the viewport right coordinate
  63377. * @param bottom defines the viewport bottom coordinate
  63378. * @param top defines the viewport top coordinate
  63379. * @param znear defines the near clip plane
  63380. * @param zfar defines the far clip plane
  63381. * @param result defines the target matrix
  63382. */
  63383. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63384. /**
  63385. * Creates a left-handed perspective projection matrix
  63386. * @param width defines the viewport width
  63387. * @param height defines the viewport height
  63388. * @param znear defines the near clip plane
  63389. * @param zfar defines the far clip plane
  63390. * @returns a new matrix as a left-handed perspective projection matrix
  63391. */
  63392. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63393. /**
  63394. * Creates a left-handed perspective projection matrix
  63395. * @param fov defines the horizontal field of view
  63396. * @param aspect defines the aspect ratio
  63397. * @param znear defines the near clip plane
  63398. * @param zfar defines the far clip plane
  63399. * @returns a new matrix as a left-handed perspective projection matrix
  63400. */
  63401. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63402. /**
  63403. * Stores a left-handed perspective projection into a given matrix
  63404. * @param fov defines the horizontal field of view
  63405. * @param aspect defines the aspect ratio
  63406. * @param znear defines the near clip plane
  63407. * @param zfar defines the far clip plane
  63408. * @param result defines the target matrix
  63409. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63410. */
  63411. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63412. /**
  63413. * Creates a right-handed perspective projection matrix
  63414. * @param fov defines the horizontal field of view
  63415. * @param aspect defines the aspect ratio
  63416. * @param znear defines the near clip plane
  63417. * @param zfar defines the far clip plane
  63418. * @returns a new matrix as a right-handed perspective projection matrix
  63419. */
  63420. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63421. /**
  63422. * Stores a right-handed perspective projection into a given matrix
  63423. * @param fov defines the horizontal field of view
  63424. * @param aspect defines the aspect ratio
  63425. * @param znear defines the near clip plane
  63426. * @param zfar defines the far clip plane
  63427. * @param result defines the target matrix
  63428. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63429. */
  63430. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63431. /**
  63432. * Stores a perspective projection for WebVR info a given matrix
  63433. * @param fov defines the field of view
  63434. * @param znear defines the near clip plane
  63435. * @param zfar defines the far clip plane
  63436. * @param result defines the target matrix
  63437. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63438. */
  63439. static PerspectiveFovWebVRToRef(fov: {
  63440. upDegrees: number;
  63441. downDegrees: number;
  63442. leftDegrees: number;
  63443. rightDegrees: number;
  63444. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63445. /**
  63446. * Computes a complete transformation matrix
  63447. * @param viewport defines the viewport to use
  63448. * @param world defines the world matrix
  63449. * @param view defines the view matrix
  63450. * @param projection defines the projection matrix
  63451. * @param zmin defines the near clip plane
  63452. * @param zmax defines the far clip plane
  63453. * @returns the transformation matrix
  63454. */
  63455. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63456. /**
  63457. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63458. * @param matrix defines the matrix to use
  63459. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63460. */
  63461. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63462. /**
  63463. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63464. * @param matrix defines the matrix to use
  63465. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63466. */
  63467. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63468. /**
  63469. * Compute the transpose of a given matrix
  63470. * @param matrix defines the matrix to transpose
  63471. * @returns the new matrix
  63472. */
  63473. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63474. /**
  63475. * Compute the transpose of a matrix and store it in a target matrix
  63476. * @param matrix defines the matrix to transpose
  63477. * @param result defines the target matrix
  63478. */
  63479. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63480. /**
  63481. * Computes a reflection matrix from a plane
  63482. * @param plane defines the reflection plane
  63483. * @returns a new matrix
  63484. */
  63485. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63486. /**
  63487. * Computes a reflection matrix from a plane
  63488. * @param plane defines the reflection plane
  63489. * @param result defines the target matrix
  63490. */
  63491. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63492. /**
  63493. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63494. * @param xaxis defines the value of the 1st axis
  63495. * @param yaxis defines the value of the 2nd axis
  63496. * @param zaxis defines the value of the 3rd axis
  63497. * @param result defines the target matrix
  63498. */
  63499. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63500. /**
  63501. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63502. * @param quat defines the quaternion to use
  63503. * @param result defines the target matrix
  63504. */
  63505. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63506. }
  63507. /**
  63508. * Represens a plane by the equation ax + by + cz + d = 0
  63509. */
  63510. export class Plane {
  63511. /**
  63512. * Normal of the plane (a,b,c)
  63513. */
  63514. normal: Vector3;
  63515. /**
  63516. * d component of the plane
  63517. */
  63518. d: number;
  63519. /**
  63520. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63521. * @param a a component of the plane
  63522. * @param b b component of the plane
  63523. * @param c c component of the plane
  63524. * @param d d component of the plane
  63525. */
  63526. constructor(a: number, b: number, c: number, d: number);
  63527. /**
  63528. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63529. */
  63530. asArray(): number[];
  63531. /**
  63532. * @returns a new plane copied from the current Plane.
  63533. */
  63534. clone(): Plane;
  63535. /**
  63536. * @returns the string "Plane".
  63537. */
  63538. getClassName(): string;
  63539. /**
  63540. * @returns the Plane hash code.
  63541. */
  63542. getHashCode(): number;
  63543. /**
  63544. * Normalize the current Plane in place.
  63545. * @returns the updated Plane.
  63546. */
  63547. normalize(): Plane;
  63548. /**
  63549. * Applies a transformation the plane and returns the result
  63550. * @param transformation the transformation matrix to be applied to the plane
  63551. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63552. */
  63553. transform(transformation: DeepImmutable<Matrix>): Plane;
  63554. /**
  63555. * Calcualtte the dot product between the point and the plane normal
  63556. * @param point point to calculate the dot product with
  63557. * @returns the dot product (float) of the point coordinates and the plane normal.
  63558. */
  63559. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63560. /**
  63561. * Updates the current Plane from the plane defined by the three given points.
  63562. * @param point1 one of the points used to contruct the plane
  63563. * @param point2 one of the points used to contruct the plane
  63564. * @param point3 one of the points used to contruct the plane
  63565. * @returns the updated Plane.
  63566. */
  63567. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63568. /**
  63569. * Checks if the plane is facing a given direction
  63570. * @param direction the direction to check if the plane is facing
  63571. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63572. * @returns True is the vector "direction" is the same side than the plane normal.
  63573. */
  63574. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63575. /**
  63576. * Calculates the distance to a point
  63577. * @param point point to calculate distance to
  63578. * @returns the signed distance (float) from the given point to the Plane.
  63579. */
  63580. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63581. /**
  63582. * Creates a plane from an array
  63583. * @param array the array to create a plane from
  63584. * @returns a new Plane from the given array.
  63585. */
  63586. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63587. /**
  63588. * Creates a plane from three points
  63589. * @param point1 point used to create the plane
  63590. * @param point2 point used to create the plane
  63591. * @param point3 point used to create the plane
  63592. * @returns a new Plane defined by the three given points.
  63593. */
  63594. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63595. /**
  63596. * Creates a plane from an origin point and a normal
  63597. * @param origin origin of the plane to be constructed
  63598. * @param normal normal of the plane to be constructed
  63599. * @returns a new Plane the normal vector to this plane at the given origin point.
  63600. * Note : the vector "normal" is updated because normalized.
  63601. */
  63602. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63603. /**
  63604. * Calculates the distance from a plane and a point
  63605. * @param origin origin of the plane to be constructed
  63606. * @param normal normal of the plane to be constructed
  63607. * @param point point to calculate distance to
  63608. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63609. */
  63610. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63611. }
  63612. /**
  63613. * Class used to represent a viewport on screen
  63614. */
  63615. export class Viewport {
  63616. /** viewport left coordinate */
  63617. x: number;
  63618. /** viewport top coordinate */
  63619. y: number;
  63620. /**viewport width */
  63621. width: number;
  63622. /** viewport height */
  63623. height: number;
  63624. /**
  63625. * Creates a Viewport object located at (x, y) and sized (width, height)
  63626. * @param x defines viewport left coordinate
  63627. * @param y defines viewport top coordinate
  63628. * @param width defines the viewport width
  63629. * @param height defines the viewport height
  63630. */
  63631. constructor(
  63632. /** viewport left coordinate */
  63633. x: number,
  63634. /** viewport top coordinate */
  63635. y: number,
  63636. /**viewport width */
  63637. width: number,
  63638. /** viewport height */
  63639. height: number);
  63640. /**
  63641. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63642. * @param renderWidth defines the rendering width
  63643. * @param renderHeight defines the rendering height
  63644. * @returns a new Viewport
  63645. */
  63646. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63647. /**
  63648. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63649. * @param renderWidth defines the rendering width
  63650. * @param renderHeight defines the rendering height
  63651. * @param ref defines the target viewport
  63652. * @returns the current viewport
  63653. */
  63654. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63655. /**
  63656. * Returns a new Viewport copied from the current one
  63657. * @returns a new Viewport
  63658. */
  63659. clone(): Viewport;
  63660. }
  63661. /**
  63662. * Reprasents a camera frustum
  63663. */
  63664. export class Frustum {
  63665. /**
  63666. * Gets the planes representing the frustum
  63667. * @param transform matrix to be applied to the returned planes
  63668. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63669. */
  63670. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63671. /**
  63672. * Gets the near frustum plane transformed by the transform matrix
  63673. * @param transform transformation matrix to be applied to the resulting frustum plane
  63674. * @param frustumPlane the resuling frustum plane
  63675. */
  63676. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63677. /**
  63678. * Gets the far frustum plane transformed by the transform matrix
  63679. * @param transform transformation matrix to be applied to the resulting frustum plane
  63680. * @param frustumPlane the resuling frustum plane
  63681. */
  63682. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63683. /**
  63684. * Gets the left frustum plane transformed by the transform matrix
  63685. * @param transform transformation matrix to be applied to the resulting frustum plane
  63686. * @param frustumPlane the resuling frustum plane
  63687. */
  63688. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63689. /**
  63690. * Gets the right frustum plane transformed by the transform matrix
  63691. * @param transform transformation matrix to be applied to the resulting frustum plane
  63692. * @param frustumPlane the resuling frustum plane
  63693. */
  63694. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63695. /**
  63696. * Gets the top frustum plane transformed by the transform matrix
  63697. * @param transform transformation matrix to be applied to the resulting frustum plane
  63698. * @param frustumPlane the resuling frustum plane
  63699. */
  63700. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63701. /**
  63702. * Gets the bottom frustum plane transformed by the transform matrix
  63703. * @param transform transformation matrix to be applied to the resulting frustum plane
  63704. * @param frustumPlane the resuling frustum plane
  63705. */
  63706. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63707. /**
  63708. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63709. * @param transform transformation matrix to be applied to the resulting frustum planes
  63710. * @param frustumPlanes the resuling frustum planes
  63711. */
  63712. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63713. }
  63714. /** Defines supported spaces */
  63715. export enum Space {
  63716. /** Local (object) space */
  63717. LOCAL = 0,
  63718. /** World space */
  63719. WORLD = 1,
  63720. /** Bone space */
  63721. BONE = 2
  63722. }
  63723. /** Defines the 3 main axes */
  63724. export class Axis {
  63725. /** X axis */
  63726. static X: Vector3;
  63727. /** Y axis */
  63728. static Y: Vector3;
  63729. /** Z axis */
  63730. static Z: Vector3;
  63731. }
  63732. /** Class used to represent a Bezier curve */
  63733. export class BezierCurve {
  63734. /**
  63735. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63736. * @param t defines the time
  63737. * @param x1 defines the left coordinate on X axis
  63738. * @param y1 defines the left coordinate on Y axis
  63739. * @param x2 defines the right coordinate on X axis
  63740. * @param y2 defines the right coordinate on Y axis
  63741. * @returns the interpolated value
  63742. */
  63743. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63744. }
  63745. /**
  63746. * Defines potential orientation for back face culling
  63747. */
  63748. export enum Orientation {
  63749. /**
  63750. * Clockwise
  63751. */
  63752. CW = 0,
  63753. /** Counter clockwise */
  63754. CCW = 1
  63755. }
  63756. /**
  63757. * Defines angle representation
  63758. */
  63759. export class Angle {
  63760. private _radians;
  63761. /**
  63762. * Creates an Angle object of "radians" radians (float).
  63763. * @param radians the angle in radians
  63764. */
  63765. constructor(radians: number);
  63766. /**
  63767. * Get value in degrees
  63768. * @returns the Angle value in degrees (float)
  63769. */
  63770. degrees(): number;
  63771. /**
  63772. * Get value in radians
  63773. * @returns the Angle value in radians (float)
  63774. */
  63775. radians(): number;
  63776. /**
  63777. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63778. * @param a defines first vector
  63779. * @param b defines second vector
  63780. * @returns a new Angle
  63781. */
  63782. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63783. /**
  63784. * Gets a new Angle object from the given float in radians
  63785. * @param radians defines the angle value in radians
  63786. * @returns a new Angle
  63787. */
  63788. static FromRadians(radians: number): Angle;
  63789. /**
  63790. * Gets a new Angle object from the given float in degrees
  63791. * @param degrees defines the angle value in degrees
  63792. * @returns a new Angle
  63793. */
  63794. static FromDegrees(degrees: number): Angle;
  63795. }
  63796. /**
  63797. * This represents an arc in a 2d space.
  63798. */
  63799. export class Arc2 {
  63800. /** Defines the start point of the arc */
  63801. startPoint: Vector2;
  63802. /** Defines the mid point of the arc */
  63803. midPoint: Vector2;
  63804. /** Defines the end point of the arc */
  63805. endPoint: Vector2;
  63806. /**
  63807. * Defines the center point of the arc.
  63808. */
  63809. centerPoint: Vector2;
  63810. /**
  63811. * Defines the radius of the arc.
  63812. */
  63813. radius: number;
  63814. /**
  63815. * Defines the angle of the arc (from mid point to end point).
  63816. */
  63817. angle: Angle;
  63818. /**
  63819. * Defines the start angle of the arc (from start point to middle point).
  63820. */
  63821. startAngle: Angle;
  63822. /**
  63823. * Defines the orientation of the arc (clock wise/counter clock wise).
  63824. */
  63825. orientation: Orientation;
  63826. /**
  63827. * Creates an Arc object from the three given points : start, middle and end.
  63828. * @param startPoint Defines the start point of the arc
  63829. * @param midPoint Defines the midlle point of the arc
  63830. * @param endPoint Defines the end point of the arc
  63831. */
  63832. constructor(
  63833. /** Defines the start point of the arc */
  63834. startPoint: Vector2,
  63835. /** Defines the mid point of the arc */
  63836. midPoint: Vector2,
  63837. /** Defines the end point of the arc */
  63838. endPoint: Vector2);
  63839. }
  63840. /**
  63841. * Represents a 2D path made up of multiple 2D points
  63842. */
  63843. export class Path2 {
  63844. private _points;
  63845. private _length;
  63846. /**
  63847. * If the path start and end point are the same
  63848. */
  63849. closed: boolean;
  63850. /**
  63851. * Creates a Path2 object from the starting 2D coordinates x and y.
  63852. * @param x the starting points x value
  63853. * @param y the starting points y value
  63854. */
  63855. constructor(x: number, y: number);
  63856. /**
  63857. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63858. * @param x the added points x value
  63859. * @param y the added points y value
  63860. * @returns the updated Path2.
  63861. */
  63862. addLineTo(x: number, y: number): Path2;
  63863. /**
  63864. * 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.
  63865. * @param midX middle point x value
  63866. * @param midY middle point y value
  63867. * @param endX end point x value
  63868. * @param endY end point y value
  63869. * @param numberOfSegments (default: 36)
  63870. * @returns the updated Path2.
  63871. */
  63872. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63873. /**
  63874. * Closes the Path2.
  63875. * @returns the Path2.
  63876. */
  63877. close(): Path2;
  63878. /**
  63879. * Gets the sum of the distance between each sequential point in the path
  63880. * @returns the Path2 total length (float).
  63881. */
  63882. length(): number;
  63883. /**
  63884. * Gets the points which construct the path
  63885. * @returns the Path2 internal array of points.
  63886. */
  63887. getPoints(): Vector2[];
  63888. /**
  63889. * Retreives the point at the distance aways from the starting point
  63890. * @param normalizedLengthPosition the length along the path to retreive the point from
  63891. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63892. */
  63893. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63894. /**
  63895. * Creates a new path starting from an x and y position
  63896. * @param x starting x value
  63897. * @param y starting y value
  63898. * @returns a new Path2 starting at the coordinates (x, y).
  63899. */
  63900. static StartingAt(x: number, y: number): Path2;
  63901. }
  63902. /**
  63903. * Represents a 3D path made up of multiple 3D points
  63904. */
  63905. export class Path3D {
  63906. /**
  63907. * an array of Vector3, the curve axis of the Path3D
  63908. */
  63909. path: Vector3[];
  63910. private _curve;
  63911. private _distances;
  63912. private _tangents;
  63913. private _normals;
  63914. private _binormals;
  63915. private _raw;
  63916. /**
  63917. * new Path3D(path, normal, raw)
  63918. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63919. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63920. * @param path an array of Vector3, the curve axis of the Path3D
  63921. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63922. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63923. */
  63924. constructor(
  63925. /**
  63926. * an array of Vector3, the curve axis of the Path3D
  63927. */
  63928. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63929. /**
  63930. * Returns the Path3D array of successive Vector3 designing its curve.
  63931. * @returns the Path3D array of successive Vector3 designing its curve.
  63932. */
  63933. getCurve(): Vector3[];
  63934. /**
  63935. * Returns an array populated with tangent vectors on each Path3D curve point.
  63936. * @returns an array populated with tangent vectors on each Path3D curve point.
  63937. */
  63938. getTangents(): Vector3[];
  63939. /**
  63940. * Returns an array populated with normal vectors on each Path3D curve point.
  63941. * @returns an array populated with normal vectors on each Path3D curve point.
  63942. */
  63943. getNormals(): Vector3[];
  63944. /**
  63945. * Returns an array populated with binormal vectors on each Path3D curve point.
  63946. * @returns an array populated with binormal vectors on each Path3D curve point.
  63947. */
  63948. getBinormals(): Vector3[];
  63949. /**
  63950. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63951. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63952. */
  63953. getDistances(): number[];
  63954. /**
  63955. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63956. * @param path path which all values are copied into the curves points
  63957. * @param firstNormal which should be projected onto the curve
  63958. * @returns the same object updated.
  63959. */
  63960. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63961. private _compute;
  63962. private _getFirstNonNullVector;
  63963. private _getLastNonNullVector;
  63964. private _normalVector;
  63965. }
  63966. /**
  63967. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63968. * A Curve3 is designed from a series of successive Vector3.
  63969. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63970. */
  63971. export class Curve3 {
  63972. private _points;
  63973. private _length;
  63974. /**
  63975. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63976. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63977. * @param v1 (Vector3) the control point
  63978. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63979. * @param nbPoints (integer) the wanted number of points in the curve
  63980. * @returns the created Curve3
  63981. */
  63982. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63983. /**
  63984. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63985. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63986. * @param v1 (Vector3) the first control point
  63987. * @param v2 (Vector3) the second control point
  63988. * @param v3 (Vector3) the end point of the Cubic Bezier
  63989. * @param nbPoints (integer) the wanted number of points in the curve
  63990. * @returns the created Curve3
  63991. */
  63992. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63993. /**
  63994. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63995. * @param p1 (Vector3) the origin point of the Hermite Spline
  63996. * @param t1 (Vector3) the tangent vector at the origin point
  63997. * @param p2 (Vector3) the end point of the Hermite Spline
  63998. * @param t2 (Vector3) the tangent vector at the end point
  63999. * @param nbPoints (integer) the wanted number of points in the curve
  64000. * @returns the created Curve3
  64001. */
  64002. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64003. /**
  64004. * Returns a Curve3 object along a CatmullRom Spline curve :
  64005. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  64006. * @param nbPoints (integer) the wanted number of points between each curve control points
  64007. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  64008. * @returns the created Curve3
  64009. */
  64010. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  64011. /**
  64012. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  64013. * A Curve3 is designed from a series of successive Vector3.
  64014. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  64015. * @param points points which make up the curve
  64016. */
  64017. constructor(points: Vector3[]);
  64018. /**
  64019. * @returns the Curve3 stored array of successive Vector3
  64020. */
  64021. getPoints(): Vector3[];
  64022. /**
  64023. * @returns the computed length (float) of the curve.
  64024. */
  64025. length(): number;
  64026. /**
  64027. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  64028. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  64029. * curveA and curveB keep unchanged.
  64030. * @param curve the curve to continue from this curve
  64031. * @returns the newly constructed curve
  64032. */
  64033. continue(curve: DeepImmutable<Curve3>): Curve3;
  64034. private _computeLength;
  64035. }
  64036. /**
  64037. * Contains position and normal vectors for a vertex
  64038. */
  64039. export class PositionNormalVertex {
  64040. /** the position of the vertex (defaut: 0,0,0) */
  64041. position: Vector3;
  64042. /** the normal of the vertex (defaut: 0,1,0) */
  64043. normal: Vector3;
  64044. /**
  64045. * Creates a PositionNormalVertex
  64046. * @param position the position of the vertex (defaut: 0,0,0)
  64047. * @param normal the normal of the vertex (defaut: 0,1,0)
  64048. */
  64049. constructor(
  64050. /** the position of the vertex (defaut: 0,0,0) */
  64051. position?: Vector3,
  64052. /** the normal of the vertex (defaut: 0,1,0) */
  64053. normal?: Vector3);
  64054. /**
  64055. * Clones the PositionNormalVertex
  64056. * @returns the cloned PositionNormalVertex
  64057. */
  64058. clone(): PositionNormalVertex;
  64059. }
  64060. /**
  64061. * Contains position, normal and uv vectors for a vertex
  64062. */
  64063. export class PositionNormalTextureVertex {
  64064. /** the position of the vertex (defaut: 0,0,0) */
  64065. position: Vector3;
  64066. /** the normal of the vertex (defaut: 0,1,0) */
  64067. normal: Vector3;
  64068. /** the uv of the vertex (default: 0,0) */
  64069. uv: Vector2;
  64070. /**
  64071. * Creates a PositionNormalTextureVertex
  64072. * @param position the position of the vertex (defaut: 0,0,0)
  64073. * @param normal the normal of the vertex (defaut: 0,1,0)
  64074. * @param uv the uv of the vertex (default: 0,0)
  64075. */
  64076. constructor(
  64077. /** the position of the vertex (defaut: 0,0,0) */
  64078. position?: Vector3,
  64079. /** the normal of the vertex (defaut: 0,1,0) */
  64080. normal?: Vector3,
  64081. /** the uv of the vertex (default: 0,0) */
  64082. uv?: Vector2);
  64083. /**
  64084. * Clones the PositionNormalTextureVertex
  64085. * @returns the cloned PositionNormalTextureVertex
  64086. */
  64087. clone(): PositionNormalTextureVertex;
  64088. }
  64089. /**
  64090. * @hidden
  64091. */
  64092. export class Tmp {
  64093. static Color3: Color3[];
  64094. static Color4: Color4[];
  64095. static Vector2: Vector2[];
  64096. static Vector3: Vector3[];
  64097. static Vector4: Vector4[];
  64098. static Quaternion: Quaternion[];
  64099. static Matrix: Matrix[];
  64100. }
  64101. }
  64102. declare module BABYLON {
  64103. /**
  64104. * Class used to enable access to offline support
  64105. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64106. */
  64107. export interface IOfflineProvider {
  64108. /**
  64109. * Gets a boolean indicating if scene must be saved in the database
  64110. */
  64111. enableSceneOffline: boolean;
  64112. /**
  64113. * Gets a boolean indicating if textures must be saved in the database
  64114. */
  64115. enableTexturesOffline: boolean;
  64116. /**
  64117. * Open the offline support and make it available
  64118. * @param successCallback defines the callback to call on success
  64119. * @param errorCallback defines the callback to call on error
  64120. */
  64121. open(successCallback: () => void, errorCallback: () => void): void;
  64122. /**
  64123. * Loads an image from the offline support
  64124. * @param url defines the url to load from
  64125. * @param image defines the target DOM image
  64126. */
  64127. loadImage(url: string, image: HTMLImageElement): void;
  64128. /**
  64129. * Loads a file from offline support
  64130. * @param url defines the URL to load from
  64131. * @param sceneLoaded defines a callback to call on success
  64132. * @param progressCallBack defines a callback to call when progress changed
  64133. * @param errorCallback defines a callback to call on error
  64134. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64135. */
  64136. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64137. }
  64138. }
  64139. declare module BABYLON {
  64140. /**
  64141. * A class serves as a medium between the observable and its observers
  64142. */
  64143. export class EventState {
  64144. /**
  64145. * Create a new EventState
  64146. * @param mask defines the mask associated with this state
  64147. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64148. * @param target defines the original target of the state
  64149. * @param currentTarget defines the current target of the state
  64150. */
  64151. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64152. /**
  64153. * Initialize the current event state
  64154. * @param mask defines the mask associated with this state
  64155. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64156. * @param target defines the original target of the state
  64157. * @param currentTarget defines the current target of the state
  64158. * @returns the current event state
  64159. */
  64160. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64161. /**
  64162. * An Observer can set this property to true to prevent subsequent observers of being notified
  64163. */
  64164. skipNextObservers: boolean;
  64165. /**
  64166. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64167. */
  64168. mask: number;
  64169. /**
  64170. * The object that originally notified the event
  64171. */
  64172. target?: any;
  64173. /**
  64174. * The current object in the bubbling phase
  64175. */
  64176. currentTarget?: any;
  64177. /**
  64178. * This will be populated with the return value of the last function that was executed.
  64179. * If it is the first function in the callback chain it will be the event data.
  64180. */
  64181. lastReturnValue?: any;
  64182. }
  64183. /**
  64184. * Represent an Observer registered to a given Observable object.
  64185. */
  64186. export class Observer<T> {
  64187. /**
  64188. * Defines the callback to call when the observer is notified
  64189. */
  64190. callback: (eventData: T, eventState: EventState) => void;
  64191. /**
  64192. * Defines the mask of the observer (used to filter notifications)
  64193. */
  64194. mask: number;
  64195. /**
  64196. * Defines the current scope used to restore the JS context
  64197. */
  64198. scope: any;
  64199. /** @hidden */
  64200. _willBeUnregistered: boolean;
  64201. /**
  64202. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64203. */
  64204. unregisterOnNextCall: boolean;
  64205. /**
  64206. * Creates a new observer
  64207. * @param callback defines the callback to call when the observer is notified
  64208. * @param mask defines the mask of the observer (used to filter notifications)
  64209. * @param scope defines the current scope used to restore the JS context
  64210. */
  64211. constructor(
  64212. /**
  64213. * Defines the callback to call when the observer is notified
  64214. */
  64215. callback: (eventData: T, eventState: EventState) => void,
  64216. /**
  64217. * Defines the mask of the observer (used to filter notifications)
  64218. */
  64219. mask: number,
  64220. /**
  64221. * Defines the current scope used to restore the JS context
  64222. */
  64223. scope?: any);
  64224. }
  64225. /**
  64226. * Represent a list of observers registered to multiple Observables object.
  64227. */
  64228. export class MultiObserver<T> {
  64229. private _observers;
  64230. private _observables;
  64231. /**
  64232. * Release associated resources
  64233. */
  64234. dispose(): void;
  64235. /**
  64236. * Raise a callback when one of the observable will notify
  64237. * @param observables defines a list of observables to watch
  64238. * @param callback defines the callback to call on notification
  64239. * @param mask defines the mask used to filter notifications
  64240. * @param scope defines the current scope used to restore the JS context
  64241. * @returns the new MultiObserver
  64242. */
  64243. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64244. }
  64245. /**
  64246. * The Observable class is a simple implementation of the Observable pattern.
  64247. *
  64248. * 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.
  64249. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64250. * 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).
  64251. * 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.
  64252. */
  64253. export class Observable<T> {
  64254. private _observers;
  64255. private _eventState;
  64256. private _onObserverAdded;
  64257. /**
  64258. * Creates a new observable
  64259. * @param onObserverAdded defines a callback to call when a new observer is added
  64260. */
  64261. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64262. /**
  64263. * Create a new Observer with the specified callback
  64264. * @param callback the callback that will be executed for that Observer
  64265. * @param mask the mask used to filter observers
  64266. * @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.
  64267. * @param scope optional scope for the callback to be called from
  64268. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64269. * @returns the new observer created for the callback
  64270. */
  64271. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64272. /**
  64273. * Create a new Observer with the specified callback and unregisters after the next notification
  64274. * @param callback the callback that will be executed for that Observer
  64275. * @returns the new observer created for the callback
  64276. */
  64277. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64278. /**
  64279. * Remove an Observer from the Observable object
  64280. * @param observer the instance of the Observer to remove
  64281. * @returns false if it doesn't belong to this Observable
  64282. */
  64283. remove(observer: Nullable<Observer<T>>): boolean;
  64284. /**
  64285. * Remove a callback from the Observable object
  64286. * @param callback the callback to remove
  64287. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64288. * @returns false if it doesn't belong to this Observable
  64289. */
  64290. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64291. private _deferUnregister;
  64292. private _remove;
  64293. /**
  64294. * Moves the observable to the top of the observer list making it get called first when notified
  64295. * @param observer the observer to move
  64296. */
  64297. makeObserverTopPriority(observer: Observer<T>): void;
  64298. /**
  64299. * Moves the observable to the bottom of the observer list making it get called last when notified
  64300. * @param observer the observer to move
  64301. */
  64302. makeObserverBottomPriority(observer: Observer<T>): void;
  64303. /**
  64304. * Notify all Observers by calling their respective callback with the given data
  64305. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64306. * @param eventData defines the data to send to all observers
  64307. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64308. * @param target defines the original target of the state
  64309. * @param currentTarget defines the current target of the state
  64310. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64311. */
  64312. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64313. /**
  64314. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64315. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64316. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64317. * and it is crucial that all callbacks will be executed.
  64318. * The order of the callbacks is kept, callbacks are not executed parallel.
  64319. *
  64320. * @param eventData The data to be sent to each callback
  64321. * @param mask is used to filter observers defaults to -1
  64322. * @param target defines the callback target (see EventState)
  64323. * @param currentTarget defines he current object in the bubbling phase
  64324. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64325. */
  64326. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64327. /**
  64328. * Notify a specific observer
  64329. * @param observer defines the observer to notify
  64330. * @param eventData defines the data to be sent to each callback
  64331. * @param mask is used to filter observers defaults to -1
  64332. */
  64333. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64334. /**
  64335. * Gets a boolean indicating if the observable has at least one observer
  64336. * @returns true is the Observable has at least one Observer registered
  64337. */
  64338. hasObservers(): boolean;
  64339. /**
  64340. * Clear the list of observers
  64341. */
  64342. clear(): void;
  64343. /**
  64344. * Clone the current observable
  64345. * @returns a new observable
  64346. */
  64347. clone(): Observable<T>;
  64348. /**
  64349. * Does this observable handles observer registered with a given mask
  64350. * @param mask defines the mask to be tested
  64351. * @return whether or not one observer registered with the given mask is handeled
  64352. **/
  64353. hasSpecificMask(mask?: number): boolean;
  64354. }
  64355. }
  64356. declare module BABYLON {
  64357. /**
  64358. * Class used to help managing file picking and drag'n'drop
  64359. * File Storage
  64360. */
  64361. export class FilesInputStore {
  64362. /**
  64363. * List of files ready to be loaded
  64364. */
  64365. static FilesToLoad: {
  64366. [key: string]: File;
  64367. };
  64368. }
  64369. }
  64370. declare module BABYLON {
  64371. /** Defines the cross module used constants to avoid circular dependncies */
  64372. export class Constants {
  64373. /** Defines that alpha blending is disabled */
  64374. static readonly ALPHA_DISABLE: number;
  64375. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64376. static readonly ALPHA_ADD: number;
  64377. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64378. static readonly ALPHA_COMBINE: number;
  64379. /** Defines that alpha blending to DEST - SRC * DEST */
  64380. static readonly ALPHA_SUBTRACT: number;
  64381. /** Defines that alpha blending to SRC * DEST */
  64382. static readonly ALPHA_MULTIPLY: number;
  64383. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64384. static readonly ALPHA_MAXIMIZED: number;
  64385. /** Defines that alpha blending to SRC + DEST */
  64386. static readonly ALPHA_ONEONE: number;
  64387. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64388. static readonly ALPHA_PREMULTIPLIED: number;
  64389. /**
  64390. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64391. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64392. */
  64393. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64394. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64395. static readonly ALPHA_INTERPOLATE: number;
  64396. /**
  64397. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64398. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64399. */
  64400. static readonly ALPHA_SCREENMODE: number;
  64401. /** Defines that the ressource is not delayed*/
  64402. static readonly DELAYLOADSTATE_NONE: number;
  64403. /** Defines that the ressource was successfully delay loaded */
  64404. static readonly DELAYLOADSTATE_LOADED: number;
  64405. /** Defines that the ressource is currently delay loading */
  64406. static readonly DELAYLOADSTATE_LOADING: number;
  64407. /** Defines that the ressource is delayed and has not started loading */
  64408. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64409. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64410. static readonly NEVER: number;
  64411. /** 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 */
  64412. static readonly ALWAYS: number;
  64413. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64414. static readonly LESS: number;
  64415. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64416. static readonly EQUAL: number;
  64417. /** 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 */
  64418. static readonly LEQUAL: number;
  64419. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64420. static readonly GREATER: number;
  64421. /** 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 */
  64422. static readonly GEQUAL: number;
  64423. /** 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 */
  64424. static readonly NOTEQUAL: number;
  64425. /** Passed to stencilOperation to specify that stencil value must be kept */
  64426. static readonly KEEP: number;
  64427. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64428. static readonly REPLACE: number;
  64429. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64430. static readonly INCR: number;
  64431. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64432. static readonly DECR: number;
  64433. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64434. static readonly INVERT: number;
  64435. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64436. static readonly INCR_WRAP: number;
  64437. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64438. static readonly DECR_WRAP: number;
  64439. /** Texture is not repeating outside of 0..1 UVs */
  64440. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64441. /** Texture is repeating outside of 0..1 UVs */
  64442. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64443. /** Texture is repeating and mirrored */
  64444. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64445. /** ALPHA */
  64446. static readonly TEXTUREFORMAT_ALPHA: number;
  64447. /** LUMINANCE */
  64448. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64449. /** LUMINANCE_ALPHA */
  64450. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64451. /** RGB */
  64452. static readonly TEXTUREFORMAT_RGB: number;
  64453. /** RGBA */
  64454. static readonly TEXTUREFORMAT_RGBA: number;
  64455. /** RED */
  64456. static readonly TEXTUREFORMAT_RED: number;
  64457. /** RED (2nd reference) */
  64458. static readonly TEXTUREFORMAT_R: number;
  64459. /** RG */
  64460. static readonly TEXTUREFORMAT_RG: number;
  64461. /** RED_INTEGER */
  64462. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64463. /** RED_INTEGER (2nd reference) */
  64464. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64465. /** RG_INTEGER */
  64466. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64467. /** RGB_INTEGER */
  64468. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64469. /** RGBA_INTEGER */
  64470. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64471. /** UNSIGNED_BYTE */
  64472. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64473. /** UNSIGNED_BYTE (2nd reference) */
  64474. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64475. /** FLOAT */
  64476. static readonly TEXTURETYPE_FLOAT: number;
  64477. /** HALF_FLOAT */
  64478. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64479. /** BYTE */
  64480. static readonly TEXTURETYPE_BYTE: number;
  64481. /** SHORT */
  64482. static readonly TEXTURETYPE_SHORT: number;
  64483. /** UNSIGNED_SHORT */
  64484. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64485. /** INT */
  64486. static readonly TEXTURETYPE_INT: number;
  64487. /** UNSIGNED_INT */
  64488. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64489. /** UNSIGNED_SHORT_4_4_4_4 */
  64490. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64491. /** UNSIGNED_SHORT_5_5_5_1 */
  64492. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64493. /** UNSIGNED_SHORT_5_6_5 */
  64494. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64495. /** UNSIGNED_INT_2_10_10_10_REV */
  64496. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64497. /** UNSIGNED_INT_24_8 */
  64498. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64499. /** UNSIGNED_INT_10F_11F_11F_REV */
  64500. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64501. /** UNSIGNED_INT_5_9_9_9_REV */
  64502. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64503. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64504. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64505. /** nearest is mag = nearest and min = nearest and mip = linear */
  64506. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64507. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64508. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64509. /** Trilinear is mag = linear and min = linear and mip = linear */
  64510. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64511. /** nearest is mag = nearest and min = nearest and mip = linear */
  64512. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64513. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64514. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64515. /** Trilinear is mag = linear and min = linear and mip = linear */
  64516. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64517. /** mag = nearest and min = nearest and mip = nearest */
  64518. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64519. /** mag = nearest and min = linear and mip = nearest */
  64520. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64521. /** mag = nearest and min = linear and mip = linear */
  64522. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64523. /** mag = nearest and min = linear and mip = none */
  64524. static readonly TEXTURE_NEAREST_LINEAR: number;
  64525. /** mag = nearest and min = nearest and mip = none */
  64526. static readonly TEXTURE_NEAREST_NEAREST: number;
  64527. /** mag = linear and min = nearest and mip = nearest */
  64528. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64529. /** mag = linear and min = nearest and mip = linear */
  64530. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64531. /** mag = linear and min = linear and mip = none */
  64532. static readonly TEXTURE_LINEAR_LINEAR: number;
  64533. /** mag = linear and min = nearest and mip = none */
  64534. static readonly TEXTURE_LINEAR_NEAREST: number;
  64535. /** Explicit coordinates mode */
  64536. static readonly TEXTURE_EXPLICIT_MODE: number;
  64537. /** Spherical coordinates mode */
  64538. static readonly TEXTURE_SPHERICAL_MODE: number;
  64539. /** Planar coordinates mode */
  64540. static readonly TEXTURE_PLANAR_MODE: number;
  64541. /** Cubic coordinates mode */
  64542. static readonly TEXTURE_CUBIC_MODE: number;
  64543. /** Projection coordinates mode */
  64544. static readonly TEXTURE_PROJECTION_MODE: number;
  64545. /** Skybox coordinates mode */
  64546. static readonly TEXTURE_SKYBOX_MODE: number;
  64547. /** Inverse Cubic coordinates mode */
  64548. static readonly TEXTURE_INVCUBIC_MODE: number;
  64549. /** Equirectangular coordinates mode */
  64550. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64551. /** Equirectangular Fixed coordinates mode */
  64552. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64553. /** Equirectangular Fixed Mirrored coordinates mode */
  64554. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64555. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64556. static readonly SCALEMODE_FLOOR: number;
  64557. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64558. static readonly SCALEMODE_NEAREST: number;
  64559. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64560. static readonly SCALEMODE_CEILING: number;
  64561. /**
  64562. * The dirty texture flag value
  64563. */
  64564. static readonly MATERIAL_TextureDirtyFlag: number;
  64565. /**
  64566. * The dirty light flag value
  64567. */
  64568. static readonly MATERIAL_LightDirtyFlag: number;
  64569. /**
  64570. * The dirty fresnel flag value
  64571. */
  64572. static readonly MATERIAL_FresnelDirtyFlag: number;
  64573. /**
  64574. * The dirty attribute flag value
  64575. */
  64576. static readonly MATERIAL_AttributesDirtyFlag: number;
  64577. /**
  64578. * The dirty misc flag value
  64579. */
  64580. static readonly MATERIAL_MiscDirtyFlag: number;
  64581. /**
  64582. * The all dirty flag value
  64583. */
  64584. static readonly MATERIAL_AllDirtyFlag: number;
  64585. /**
  64586. * Returns the triangle fill mode
  64587. */
  64588. static readonly MATERIAL_TriangleFillMode: number;
  64589. /**
  64590. * Returns the wireframe mode
  64591. */
  64592. static readonly MATERIAL_WireFrameFillMode: number;
  64593. /**
  64594. * Returns the point fill mode
  64595. */
  64596. static readonly MATERIAL_PointFillMode: number;
  64597. /**
  64598. * Returns the point list draw mode
  64599. */
  64600. static readonly MATERIAL_PointListDrawMode: number;
  64601. /**
  64602. * Returns the line list draw mode
  64603. */
  64604. static readonly MATERIAL_LineListDrawMode: number;
  64605. /**
  64606. * Returns the line loop draw mode
  64607. */
  64608. static readonly MATERIAL_LineLoopDrawMode: number;
  64609. /**
  64610. * Returns the line strip draw mode
  64611. */
  64612. static readonly MATERIAL_LineStripDrawMode: number;
  64613. /**
  64614. * Returns the triangle strip draw mode
  64615. */
  64616. static readonly MATERIAL_TriangleStripDrawMode: number;
  64617. /**
  64618. * Returns the triangle fan draw mode
  64619. */
  64620. static readonly MATERIAL_TriangleFanDrawMode: number;
  64621. /**
  64622. * Stores the clock-wise side orientation
  64623. */
  64624. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64625. /**
  64626. * Stores the counter clock-wise side orientation
  64627. */
  64628. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64629. /**
  64630. * Nothing
  64631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64632. */
  64633. static readonly ACTION_NothingTrigger: number;
  64634. /**
  64635. * On pick
  64636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64637. */
  64638. static readonly ACTION_OnPickTrigger: number;
  64639. /**
  64640. * On left pick
  64641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64642. */
  64643. static readonly ACTION_OnLeftPickTrigger: number;
  64644. /**
  64645. * On right pick
  64646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64647. */
  64648. static readonly ACTION_OnRightPickTrigger: number;
  64649. /**
  64650. * On center pick
  64651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64652. */
  64653. static readonly ACTION_OnCenterPickTrigger: number;
  64654. /**
  64655. * On pick down
  64656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64657. */
  64658. static readonly ACTION_OnPickDownTrigger: number;
  64659. /**
  64660. * On double pick
  64661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64662. */
  64663. static readonly ACTION_OnDoublePickTrigger: number;
  64664. /**
  64665. * On pick up
  64666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64667. */
  64668. static readonly ACTION_OnPickUpTrigger: number;
  64669. /**
  64670. * On pick out.
  64671. * This trigger will only be raised if you also declared a OnPickDown
  64672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64673. */
  64674. static readonly ACTION_OnPickOutTrigger: number;
  64675. /**
  64676. * On long press
  64677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64678. */
  64679. static readonly ACTION_OnLongPressTrigger: number;
  64680. /**
  64681. * On pointer over
  64682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64683. */
  64684. static readonly ACTION_OnPointerOverTrigger: number;
  64685. /**
  64686. * On pointer out
  64687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64688. */
  64689. static readonly ACTION_OnPointerOutTrigger: number;
  64690. /**
  64691. * On every frame
  64692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64693. */
  64694. static readonly ACTION_OnEveryFrameTrigger: number;
  64695. /**
  64696. * On intersection enter
  64697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64698. */
  64699. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64700. /**
  64701. * On intersection exit
  64702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64703. */
  64704. static readonly ACTION_OnIntersectionExitTrigger: number;
  64705. /**
  64706. * On key down
  64707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64708. */
  64709. static readonly ACTION_OnKeyDownTrigger: number;
  64710. /**
  64711. * On key up
  64712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64713. */
  64714. static readonly ACTION_OnKeyUpTrigger: number;
  64715. /**
  64716. * Billboard mode will only apply to Y axis
  64717. */
  64718. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64719. /**
  64720. * Billboard mode will apply to all axes
  64721. */
  64722. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64723. /**
  64724. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64725. */
  64726. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64727. /**
  64728. * Gets or sets base Assets URL
  64729. */
  64730. static readonly PARTICLES_BaseAssetsUrl: string;
  64731. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64732. * Test order :
  64733. * Is the bounding sphere outside the frustum ?
  64734. * If not, are the bounding box vertices outside the frustum ?
  64735. * It not, then the cullable object is in the frustum.
  64736. */
  64737. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64738. /** Culling strategy : Bounding Sphere Only.
  64739. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64740. * It's also less accurate than the standard because some not visible objects can still be selected.
  64741. * Test : is the bounding sphere outside the frustum ?
  64742. * If not, then the cullable object is in the frustum.
  64743. */
  64744. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64745. /** Culling strategy : Optimistic Inclusion.
  64746. * This in an inclusion test first, then the standard exclusion test.
  64747. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64748. * 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.
  64749. * Anyway, it's as accurate as the standard strategy.
  64750. * Test :
  64751. * Is the cullable object bounding sphere center in the frustum ?
  64752. * If not, apply the default culling strategy.
  64753. */
  64754. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64755. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64756. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64757. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64758. * 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.
  64759. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64760. * Test :
  64761. * Is the cullable object bounding sphere center in the frustum ?
  64762. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64763. */
  64764. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64765. /**
  64766. * No logging while loading
  64767. */
  64768. static readonly SCENELOADER_NO_LOGGING: number;
  64769. /**
  64770. * Minimal logging while loading
  64771. */
  64772. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64773. /**
  64774. * Summary logging while loading
  64775. */
  64776. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64777. /**
  64778. * Detailled logging while loading
  64779. */
  64780. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64781. }
  64782. }
  64783. declare module BABYLON {
  64784. /**
  64785. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64786. * Babylon.js
  64787. */
  64788. export class DomManagement {
  64789. /**
  64790. * Checks if the window object exists
  64791. * @returns true if the window object exists
  64792. */
  64793. static IsWindowObjectExist(): boolean;
  64794. /**
  64795. * Extracts text content from a DOM element hierarchy
  64796. * @param element defines the root element
  64797. * @returns a string
  64798. */
  64799. static GetDOMTextContent(element: HTMLElement): string;
  64800. }
  64801. }
  64802. declare module BABYLON {
  64803. /**
  64804. * Logger used througouht the application to allow configuration of
  64805. * the log level required for the messages.
  64806. */
  64807. export class Logger {
  64808. /**
  64809. * No log
  64810. */
  64811. static readonly NoneLogLevel: number;
  64812. /**
  64813. * Only message logs
  64814. */
  64815. static readonly MessageLogLevel: number;
  64816. /**
  64817. * Only warning logs
  64818. */
  64819. static readonly WarningLogLevel: number;
  64820. /**
  64821. * Only error logs
  64822. */
  64823. static readonly ErrorLogLevel: number;
  64824. /**
  64825. * All logs
  64826. */
  64827. static readonly AllLogLevel: number;
  64828. private static _LogCache;
  64829. /**
  64830. * Gets a value indicating the number of loading errors
  64831. * @ignorenaming
  64832. */
  64833. static errorsCount: number;
  64834. /**
  64835. * Callback called when a new log is added
  64836. */
  64837. static OnNewCacheEntry: (entry: string) => void;
  64838. private static _AddLogEntry;
  64839. private static _FormatMessage;
  64840. private static _LogDisabled;
  64841. private static _LogEnabled;
  64842. private static _WarnDisabled;
  64843. private static _WarnEnabled;
  64844. private static _ErrorDisabled;
  64845. private static _ErrorEnabled;
  64846. /**
  64847. * Log a message to the console
  64848. */
  64849. static Log: (message: string) => void;
  64850. /**
  64851. * Write a warning message to the console
  64852. */
  64853. static Warn: (message: string) => void;
  64854. /**
  64855. * Write an error message to the console
  64856. */
  64857. static Error: (message: string) => void;
  64858. /**
  64859. * Gets current log cache (list of logs)
  64860. */
  64861. static readonly LogCache: string;
  64862. /**
  64863. * Clears the log cache
  64864. */
  64865. static ClearLogCache(): void;
  64866. /**
  64867. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64868. */
  64869. static LogLevels: number;
  64870. }
  64871. }
  64872. declare module BABYLON {
  64873. /** @hidden */
  64874. export class _TypeStore {
  64875. /** @hidden */
  64876. static RegisteredTypes: {
  64877. [key: string]: Object;
  64878. };
  64879. /** @hidden */
  64880. static GetClass(fqdn: string): any;
  64881. }
  64882. }
  64883. declare module BABYLON {
  64884. /**
  64885. * Class containing a set of static utilities functions for deep copy.
  64886. */
  64887. export class DeepCopier {
  64888. /**
  64889. * Tries to copy an object by duplicating every property
  64890. * @param source defines the source object
  64891. * @param destination defines the target object
  64892. * @param doNotCopyList defines a list of properties to avoid
  64893. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64894. */
  64895. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64896. }
  64897. }
  64898. declare module BABYLON {
  64899. /**
  64900. * Class containing a set of static utilities functions for precision date
  64901. */
  64902. export class PrecisionDate {
  64903. /**
  64904. * Gets either window.performance.now() if supported or Date.now() else
  64905. */
  64906. static readonly Now: number;
  64907. }
  64908. }
  64909. declare module BABYLON {
  64910. /** @hidden */
  64911. export class _DevTools {
  64912. static WarnImport(name: string): string;
  64913. }
  64914. }
  64915. declare module BABYLON {
  64916. /**
  64917. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64918. */
  64919. export class WebRequest {
  64920. private _xhr;
  64921. /**
  64922. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64923. * i.e. when loading files, where the server/service expects an Authorization header
  64924. */
  64925. static CustomRequestHeaders: {
  64926. [key: string]: string;
  64927. };
  64928. /**
  64929. * Add callback functions in this array to update all the requests before they get sent to the network
  64930. */
  64931. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64932. private _injectCustomRequestHeaders;
  64933. /**
  64934. * Gets or sets a function to be called when loading progress changes
  64935. */
  64936. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64937. /**
  64938. * Returns client's state
  64939. */
  64940. readonly readyState: number;
  64941. /**
  64942. * Returns client's status
  64943. */
  64944. readonly status: number;
  64945. /**
  64946. * Returns client's status as a text
  64947. */
  64948. readonly statusText: string;
  64949. /**
  64950. * Returns client's response
  64951. */
  64952. readonly response: any;
  64953. /**
  64954. * Returns client's response url
  64955. */
  64956. readonly responseURL: string;
  64957. /**
  64958. * Returns client's response as text
  64959. */
  64960. readonly responseText: string;
  64961. /**
  64962. * Gets or sets the expected response type
  64963. */
  64964. responseType: XMLHttpRequestResponseType;
  64965. /** @hidden */
  64966. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64967. /** @hidden */
  64968. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64969. /**
  64970. * Cancels any network activity
  64971. */
  64972. abort(): void;
  64973. /**
  64974. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64975. * @param body defines an optional request body
  64976. */
  64977. send(body?: Document | BodyInit | null): void;
  64978. /**
  64979. * Sets the request method, request URL
  64980. * @param method defines the method to use (GET, POST, etc..)
  64981. * @param url defines the url to connect with
  64982. */
  64983. open(method: string, url: string): void;
  64984. }
  64985. }
  64986. declare module BABYLON {
  64987. /**
  64988. * Class used to evalaute queries containing `and` and `or` operators
  64989. */
  64990. export class AndOrNotEvaluator {
  64991. /**
  64992. * Evaluate a query
  64993. * @param query defines the query to evaluate
  64994. * @param evaluateCallback defines the callback used to filter result
  64995. * @returns true if the query matches
  64996. */
  64997. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64998. private static _HandleParenthesisContent;
  64999. private static _SimplifyNegation;
  65000. }
  65001. }
  65002. declare module BABYLON {
  65003. /**
  65004. * Class used to store custom tags
  65005. */
  65006. export class Tags {
  65007. /**
  65008. * Adds support for tags on the given object
  65009. * @param obj defines the object to use
  65010. */
  65011. static EnableFor(obj: any): void;
  65012. /**
  65013. * Removes tags support
  65014. * @param obj defines the object to use
  65015. */
  65016. static DisableFor(obj: any): void;
  65017. /**
  65018. * Gets a boolean indicating if the given object has tags
  65019. * @param obj defines the object to use
  65020. * @returns a boolean
  65021. */
  65022. static HasTags(obj: any): boolean;
  65023. /**
  65024. * Gets the tags available on a given object
  65025. * @param obj defines the object to use
  65026. * @param asString defines if the tags must be returned as a string instead of an array of strings
  65027. * @returns the tags
  65028. */
  65029. static GetTags(obj: any, asString?: boolean): any;
  65030. /**
  65031. * Adds tags to an object
  65032. * @param obj defines the object to use
  65033. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  65034. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  65035. */
  65036. static AddTagsTo(obj: any, tagsString: string): void;
  65037. /**
  65038. * @hidden
  65039. */
  65040. static _AddTagTo(obj: any, tag: string): void;
  65041. /**
  65042. * Removes specific tags from a specific object
  65043. * @param obj defines the object to use
  65044. * @param tagsString defines the tags to remove
  65045. */
  65046. static RemoveTagsFrom(obj: any, tagsString: string): void;
  65047. /**
  65048. * @hidden
  65049. */
  65050. static _RemoveTagFrom(obj: any, tag: string): void;
  65051. /**
  65052. * Defines if tags hosted on an object match a given query
  65053. * @param obj defines the object to use
  65054. * @param tagsQuery defines the tag query
  65055. * @returns a boolean
  65056. */
  65057. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  65058. }
  65059. }
  65060. declare module BABYLON {
  65061. /**
  65062. * Manages the defines for the Material
  65063. */
  65064. export class MaterialDefines {
  65065. private _keys;
  65066. private _isDirty;
  65067. /** @hidden */
  65068. _renderId: number;
  65069. /** @hidden */
  65070. _areLightsDirty: boolean;
  65071. /** @hidden */
  65072. _areAttributesDirty: boolean;
  65073. /** @hidden */
  65074. _areTexturesDirty: boolean;
  65075. /** @hidden */
  65076. _areFresnelDirty: boolean;
  65077. /** @hidden */
  65078. _areMiscDirty: boolean;
  65079. /** @hidden */
  65080. _areImageProcessingDirty: boolean;
  65081. /** @hidden */
  65082. _normals: boolean;
  65083. /** @hidden */
  65084. _uvs: boolean;
  65085. /** @hidden */
  65086. _needNormals: boolean;
  65087. /** @hidden */
  65088. _needUVs: boolean;
  65089. /**
  65090. * Specifies if the material needs to be re-calculated
  65091. */
  65092. readonly isDirty: boolean;
  65093. /**
  65094. * Marks the material to indicate that it has been re-calculated
  65095. */
  65096. markAsProcessed(): void;
  65097. /**
  65098. * Marks the material to indicate that it needs to be re-calculated
  65099. */
  65100. markAsUnprocessed(): void;
  65101. /**
  65102. * Marks the material to indicate all of its defines need to be re-calculated
  65103. */
  65104. markAllAsDirty(): void;
  65105. /**
  65106. * Marks the material to indicate that image processing needs to be re-calculated
  65107. */
  65108. markAsImageProcessingDirty(): void;
  65109. /**
  65110. * Marks the material to indicate the lights need to be re-calculated
  65111. */
  65112. markAsLightDirty(): void;
  65113. /**
  65114. * Marks the attribute state as changed
  65115. */
  65116. markAsAttributesDirty(): void;
  65117. /**
  65118. * Marks the texture state as changed
  65119. */
  65120. markAsTexturesDirty(): void;
  65121. /**
  65122. * Marks the fresnel state as changed
  65123. */
  65124. markAsFresnelDirty(): void;
  65125. /**
  65126. * Marks the misc state as changed
  65127. */
  65128. markAsMiscDirty(): void;
  65129. /**
  65130. * Rebuilds the material defines
  65131. */
  65132. rebuild(): void;
  65133. /**
  65134. * Specifies if two material defines are equal
  65135. * @param other - A material define instance to compare to
  65136. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65137. */
  65138. isEqual(other: MaterialDefines): boolean;
  65139. /**
  65140. * Clones this instance's defines to another instance
  65141. * @param other - material defines to clone values to
  65142. */
  65143. cloneTo(other: MaterialDefines): void;
  65144. /**
  65145. * Resets the material define values
  65146. */
  65147. reset(): void;
  65148. /**
  65149. * Converts the material define values to a string
  65150. * @returns - String of material define information
  65151. */
  65152. toString(): string;
  65153. }
  65154. }
  65155. declare module BABYLON {
  65156. /**
  65157. * Class used to store and describe the pipeline context associated with an effect
  65158. */
  65159. export interface IPipelineContext {
  65160. /**
  65161. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  65162. */
  65163. isAsync: boolean;
  65164. /**
  65165. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  65166. */
  65167. isReady: boolean;
  65168. /** @hidden */
  65169. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  65170. }
  65171. }
  65172. declare module BABYLON {
  65173. /**
  65174. * Class used to store gfx data (like WebGLBuffer)
  65175. */
  65176. export class DataBuffer {
  65177. /**
  65178. * Gets or sets the number of objects referencing this buffer
  65179. */
  65180. references: number;
  65181. /** Gets or sets the size of the underlying buffer */
  65182. capacity: number;
  65183. /**
  65184. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65185. */
  65186. is32Bits: boolean;
  65187. /**
  65188. * Gets the underlying buffer
  65189. */
  65190. readonly underlyingResource: any;
  65191. }
  65192. }
  65193. declare module BABYLON {
  65194. /**
  65195. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65196. */
  65197. export class PerformanceMonitor {
  65198. private _enabled;
  65199. private _rollingFrameTime;
  65200. private _lastFrameTimeMs;
  65201. /**
  65202. * constructor
  65203. * @param frameSampleSize The number of samples required to saturate the sliding window
  65204. */
  65205. constructor(frameSampleSize?: number);
  65206. /**
  65207. * Samples current frame
  65208. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65209. */
  65210. sampleFrame(timeMs?: number): void;
  65211. /**
  65212. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65213. */
  65214. readonly averageFrameTime: number;
  65215. /**
  65216. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65217. */
  65218. readonly averageFrameTimeVariance: number;
  65219. /**
  65220. * Returns the frame time of the most recent frame
  65221. */
  65222. readonly instantaneousFrameTime: number;
  65223. /**
  65224. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65225. */
  65226. readonly averageFPS: number;
  65227. /**
  65228. * Returns the average framerate in frames per second using the most recent frame time
  65229. */
  65230. readonly instantaneousFPS: number;
  65231. /**
  65232. * Returns true if enough samples have been taken to completely fill the sliding window
  65233. */
  65234. readonly isSaturated: boolean;
  65235. /**
  65236. * Enables contributions to the sliding window sample set
  65237. */
  65238. enable(): void;
  65239. /**
  65240. * Disables contributions to the sliding window sample set
  65241. * Samples will not be interpolated over the disabled period
  65242. */
  65243. disable(): void;
  65244. /**
  65245. * Returns true if sampling is enabled
  65246. */
  65247. readonly isEnabled: boolean;
  65248. /**
  65249. * Resets performance monitor
  65250. */
  65251. reset(): void;
  65252. }
  65253. /**
  65254. * RollingAverage
  65255. *
  65256. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65257. */
  65258. export class RollingAverage {
  65259. /**
  65260. * Current average
  65261. */
  65262. average: number;
  65263. /**
  65264. * Current variance
  65265. */
  65266. variance: number;
  65267. protected _samples: Array<number>;
  65268. protected _sampleCount: number;
  65269. protected _pos: number;
  65270. protected _m2: number;
  65271. /**
  65272. * constructor
  65273. * @param length The number of samples required to saturate the sliding window
  65274. */
  65275. constructor(length: number);
  65276. /**
  65277. * Adds a sample to the sample set
  65278. * @param v The sample value
  65279. */
  65280. add(v: number): void;
  65281. /**
  65282. * Returns previously added values or null if outside of history or outside the sliding window domain
  65283. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65284. * @return Value previously recorded with add() or null if outside of range
  65285. */
  65286. history(i: number): number;
  65287. /**
  65288. * Returns true if enough samples have been taken to completely fill the sliding window
  65289. * @return true if sample-set saturated
  65290. */
  65291. isSaturated(): boolean;
  65292. /**
  65293. * Resets the rolling average (equivalent to 0 samples taken so far)
  65294. */
  65295. reset(): void;
  65296. /**
  65297. * Wraps a value around the sample range boundaries
  65298. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65299. * @return Wrapped position in sample range
  65300. */
  65301. protected _wrapPosition(i: number): number;
  65302. }
  65303. }
  65304. declare module BABYLON {
  65305. /**
  65306. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65307. * The underlying implementation relies on an associative array to ensure the best performances.
  65308. * The value can be anything including 'null' but except 'undefined'
  65309. */
  65310. export class StringDictionary<T> {
  65311. /**
  65312. * This will clear this dictionary and copy the content from the 'source' one.
  65313. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65314. * @param source the dictionary to take the content from and copy to this dictionary
  65315. */
  65316. copyFrom(source: StringDictionary<T>): void;
  65317. /**
  65318. * Get a value based from its key
  65319. * @param key the given key to get the matching value from
  65320. * @return the value if found, otherwise undefined is returned
  65321. */
  65322. get(key: string): T | undefined;
  65323. /**
  65324. * Get a value from its key or add it if it doesn't exist.
  65325. * This method will ensure you that a given key/data will be present in the dictionary.
  65326. * @param key the given key to get the matching value from
  65327. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65328. * The factory will only be invoked if there's no data for the given key.
  65329. * @return the value corresponding to the key.
  65330. */
  65331. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65332. /**
  65333. * Get a value from its key if present in the dictionary otherwise add it
  65334. * @param key the key to get the value from
  65335. * @param val if there's no such key/value pair in the dictionary add it with this value
  65336. * @return the value corresponding to the key
  65337. */
  65338. getOrAdd(key: string, val: T): T;
  65339. /**
  65340. * Check if there's a given key in the dictionary
  65341. * @param key the key to check for
  65342. * @return true if the key is present, false otherwise
  65343. */
  65344. contains(key: string): boolean;
  65345. /**
  65346. * Add a new key and its corresponding value
  65347. * @param key the key to add
  65348. * @param value the value corresponding to the key
  65349. * @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
  65350. */
  65351. add(key: string, value: T): boolean;
  65352. /**
  65353. * Update a specific value associated to a key
  65354. * @param key defines the key to use
  65355. * @param value defines the value to store
  65356. * @returns true if the value was updated (or false if the key was not found)
  65357. */
  65358. set(key: string, value: T): boolean;
  65359. /**
  65360. * Get the element of the given key and remove it from the dictionary
  65361. * @param key defines the key to search
  65362. * @returns the value associated with the key or null if not found
  65363. */
  65364. getAndRemove(key: string): Nullable<T>;
  65365. /**
  65366. * Remove a key/value from the dictionary.
  65367. * @param key the key to remove
  65368. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65369. */
  65370. remove(key: string): boolean;
  65371. /**
  65372. * Clear the whole content of the dictionary
  65373. */
  65374. clear(): void;
  65375. /**
  65376. * Gets the current count
  65377. */
  65378. readonly count: number;
  65379. /**
  65380. * Execute a callback on each key/val of the dictionary.
  65381. * Note that you can remove any element in this dictionary in the callback implementation
  65382. * @param callback the callback to execute on a given key/value pair
  65383. */
  65384. forEach(callback: (key: string, val: T) => void): void;
  65385. /**
  65386. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65387. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65388. * Note that you can remove any element in this dictionary in the callback implementation
  65389. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65390. * @returns the first item
  65391. */
  65392. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65393. private _count;
  65394. private _data;
  65395. }
  65396. }
  65397. declare module BABYLON {
  65398. /**
  65399. * Helper class that provides a small promise polyfill
  65400. */
  65401. export class PromisePolyfill {
  65402. /**
  65403. * Static function used to check if the polyfill is required
  65404. * If this is the case then the function will inject the polyfill to window.Promise
  65405. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65406. */
  65407. static Apply(force?: boolean): void;
  65408. }
  65409. }
  65410. declare module BABYLON {
  65411. /**
  65412. * Class used to store data that will be store in GPU memory
  65413. */
  65414. export class Buffer {
  65415. private _engine;
  65416. private _buffer;
  65417. /** @hidden */
  65418. _data: Nullable<DataArray>;
  65419. private _updatable;
  65420. private _instanced;
  65421. /**
  65422. * Gets the byte stride.
  65423. */
  65424. readonly byteStride: number;
  65425. /**
  65426. * Constructor
  65427. * @param engine the engine
  65428. * @param data the data to use for this buffer
  65429. * @param updatable whether the data is updatable
  65430. * @param stride the stride (optional)
  65431. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65432. * @param instanced whether the buffer is instanced (optional)
  65433. * @param useBytes set to true if the stride in in bytes (optional)
  65434. */
  65435. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65436. /**
  65437. * Create a new VertexBuffer based on the current buffer
  65438. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65439. * @param offset defines offset in the buffer (0 by default)
  65440. * @param size defines the size in floats of attributes (position is 3 for instance)
  65441. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65442. * @param instanced defines if the vertex buffer contains indexed data
  65443. * @param useBytes defines if the offset and stride are in bytes
  65444. * @returns the new vertex buffer
  65445. */
  65446. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65447. /**
  65448. * Gets a boolean indicating if the Buffer is updatable?
  65449. * @returns true if the buffer is updatable
  65450. */
  65451. isUpdatable(): boolean;
  65452. /**
  65453. * Gets current buffer's data
  65454. * @returns a DataArray or null
  65455. */
  65456. getData(): Nullable<DataArray>;
  65457. /**
  65458. * Gets underlying native buffer
  65459. * @returns underlying native buffer
  65460. */
  65461. getBuffer(): Nullable<DataBuffer>;
  65462. /**
  65463. * Gets the stride in float32 units (i.e. byte stride / 4).
  65464. * May not be an integer if the byte stride is not divisible by 4.
  65465. * DEPRECATED. Use byteStride instead.
  65466. * @returns the stride in float32 units
  65467. */
  65468. getStrideSize(): number;
  65469. /**
  65470. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65471. * @param data defines the data to store
  65472. */
  65473. create(data?: Nullable<DataArray>): void;
  65474. /** @hidden */
  65475. _rebuild(): void;
  65476. /**
  65477. * Update current buffer data
  65478. * @param data defines the data to store
  65479. */
  65480. update(data: DataArray): void;
  65481. /**
  65482. * Updates the data directly.
  65483. * @param data the new data
  65484. * @param offset the new offset
  65485. * @param vertexCount the vertex count (optional)
  65486. * @param useBytes set to true if the offset is in bytes
  65487. */
  65488. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65489. /**
  65490. * Release all resources
  65491. */
  65492. dispose(): void;
  65493. }
  65494. /**
  65495. * Specialized buffer used to store vertex data
  65496. */
  65497. export class VertexBuffer {
  65498. /** @hidden */
  65499. _buffer: Buffer;
  65500. private _kind;
  65501. private _size;
  65502. private _ownsBuffer;
  65503. private _instanced;
  65504. private _instanceDivisor;
  65505. /**
  65506. * The byte type.
  65507. */
  65508. static readonly BYTE: number;
  65509. /**
  65510. * The unsigned byte type.
  65511. */
  65512. static readonly UNSIGNED_BYTE: number;
  65513. /**
  65514. * The short type.
  65515. */
  65516. static readonly SHORT: number;
  65517. /**
  65518. * The unsigned short type.
  65519. */
  65520. static readonly UNSIGNED_SHORT: number;
  65521. /**
  65522. * The integer type.
  65523. */
  65524. static readonly INT: number;
  65525. /**
  65526. * The unsigned integer type.
  65527. */
  65528. static readonly UNSIGNED_INT: number;
  65529. /**
  65530. * The float type.
  65531. */
  65532. static readonly FLOAT: number;
  65533. /**
  65534. * Gets or sets the instance divisor when in instanced mode
  65535. */
  65536. instanceDivisor: number;
  65537. /**
  65538. * Gets the byte stride.
  65539. */
  65540. readonly byteStride: number;
  65541. /**
  65542. * Gets the byte offset.
  65543. */
  65544. readonly byteOffset: number;
  65545. /**
  65546. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65547. */
  65548. readonly normalized: boolean;
  65549. /**
  65550. * Gets the data type of each component in the array.
  65551. */
  65552. readonly type: number;
  65553. /**
  65554. * Constructor
  65555. * @param engine the engine
  65556. * @param data the data to use for this vertex buffer
  65557. * @param kind the vertex buffer kind
  65558. * @param updatable whether the data is updatable
  65559. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65560. * @param stride the stride (optional)
  65561. * @param instanced whether the buffer is instanced (optional)
  65562. * @param offset the offset of the data (optional)
  65563. * @param size the number of components (optional)
  65564. * @param type the type of the component (optional)
  65565. * @param normalized whether the data contains normalized data (optional)
  65566. * @param useBytes set to true if stride and offset are in bytes (optional)
  65567. */
  65568. 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);
  65569. /** @hidden */
  65570. _rebuild(): void;
  65571. /**
  65572. * Returns the kind of the VertexBuffer (string)
  65573. * @returns a string
  65574. */
  65575. getKind(): string;
  65576. /**
  65577. * Gets a boolean indicating if the VertexBuffer is updatable?
  65578. * @returns true if the buffer is updatable
  65579. */
  65580. isUpdatable(): boolean;
  65581. /**
  65582. * Gets current buffer's data
  65583. * @returns a DataArray or null
  65584. */
  65585. getData(): Nullable<DataArray>;
  65586. /**
  65587. * Gets underlying native buffer
  65588. * @returns underlying native buffer
  65589. */
  65590. getBuffer(): Nullable<DataBuffer>;
  65591. /**
  65592. * Gets the stride in float32 units (i.e. byte stride / 4).
  65593. * May not be an integer if the byte stride is not divisible by 4.
  65594. * DEPRECATED. Use byteStride instead.
  65595. * @returns the stride in float32 units
  65596. */
  65597. getStrideSize(): number;
  65598. /**
  65599. * Returns the offset as a multiple of the type byte length.
  65600. * DEPRECATED. Use byteOffset instead.
  65601. * @returns the offset in bytes
  65602. */
  65603. getOffset(): number;
  65604. /**
  65605. * Returns the number of components per vertex attribute (integer)
  65606. * @returns the size in float
  65607. */
  65608. getSize(): number;
  65609. /**
  65610. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65611. * @returns true if this buffer is instanced
  65612. */
  65613. getIsInstanced(): boolean;
  65614. /**
  65615. * Returns the instancing divisor, zero for non-instanced (integer).
  65616. * @returns a number
  65617. */
  65618. getInstanceDivisor(): number;
  65619. /**
  65620. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65621. * @param data defines the data to store
  65622. */
  65623. create(data?: DataArray): void;
  65624. /**
  65625. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65626. * This function will create a new buffer if the current one is not updatable
  65627. * @param data defines the data to store
  65628. */
  65629. update(data: DataArray): void;
  65630. /**
  65631. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65632. * Returns the directly updated WebGLBuffer.
  65633. * @param data the new data
  65634. * @param offset the new offset
  65635. * @param useBytes set to true if the offset is in bytes
  65636. */
  65637. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65638. /**
  65639. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65640. */
  65641. dispose(): void;
  65642. /**
  65643. * Enumerates each value of this vertex buffer as numbers.
  65644. * @param count the number of values to enumerate
  65645. * @param callback the callback function called for each value
  65646. */
  65647. forEach(count: number, callback: (value: number, index: number) => void): void;
  65648. /**
  65649. * Positions
  65650. */
  65651. static readonly PositionKind: string;
  65652. /**
  65653. * Normals
  65654. */
  65655. static readonly NormalKind: string;
  65656. /**
  65657. * Tangents
  65658. */
  65659. static readonly TangentKind: string;
  65660. /**
  65661. * Texture coordinates
  65662. */
  65663. static readonly UVKind: string;
  65664. /**
  65665. * Texture coordinates 2
  65666. */
  65667. static readonly UV2Kind: string;
  65668. /**
  65669. * Texture coordinates 3
  65670. */
  65671. static readonly UV3Kind: string;
  65672. /**
  65673. * Texture coordinates 4
  65674. */
  65675. static readonly UV4Kind: string;
  65676. /**
  65677. * Texture coordinates 5
  65678. */
  65679. static readonly UV5Kind: string;
  65680. /**
  65681. * Texture coordinates 6
  65682. */
  65683. static readonly UV6Kind: string;
  65684. /**
  65685. * Colors
  65686. */
  65687. static readonly ColorKind: string;
  65688. /**
  65689. * Matrix indices (for bones)
  65690. */
  65691. static readonly MatricesIndicesKind: string;
  65692. /**
  65693. * Matrix weights (for bones)
  65694. */
  65695. static readonly MatricesWeightsKind: string;
  65696. /**
  65697. * Additional matrix indices (for bones)
  65698. */
  65699. static readonly MatricesIndicesExtraKind: string;
  65700. /**
  65701. * Additional matrix weights (for bones)
  65702. */
  65703. static readonly MatricesWeightsExtraKind: string;
  65704. /**
  65705. * Deduces the stride given a kind.
  65706. * @param kind The kind string to deduce
  65707. * @returns The deduced stride
  65708. */
  65709. static DeduceStride(kind: string): number;
  65710. /**
  65711. * Gets the byte length of the given type.
  65712. * @param type the type
  65713. * @returns the number of bytes
  65714. */
  65715. static GetTypeByteLength(type: number): number;
  65716. /**
  65717. * Enumerates each value of the given parameters as numbers.
  65718. * @param data the data to enumerate
  65719. * @param byteOffset the byte offset of the data
  65720. * @param byteStride the byte stride of the data
  65721. * @param componentCount the number of components per element
  65722. * @param componentType the type of the component
  65723. * @param count the total number of components
  65724. * @param normalized whether the data is normalized
  65725. * @param callback the callback function called for each value
  65726. */
  65727. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65728. private static _GetFloatValue;
  65729. }
  65730. }
  65731. declare module BABYLON {
  65732. /**
  65733. * Class representing spherical harmonics coefficients to the 3rd degree
  65734. */
  65735. export class SphericalHarmonics {
  65736. /**
  65737. * Defines whether or not the harmonics have been prescaled for rendering.
  65738. */
  65739. preScaled: boolean;
  65740. /**
  65741. * The l0,0 coefficients of the spherical harmonics
  65742. */
  65743. l00: Vector3;
  65744. /**
  65745. * The l1,-1 coefficients of the spherical harmonics
  65746. */
  65747. l1_1: Vector3;
  65748. /**
  65749. * The l1,0 coefficients of the spherical harmonics
  65750. */
  65751. l10: Vector3;
  65752. /**
  65753. * The l1,1 coefficients of the spherical harmonics
  65754. */
  65755. l11: Vector3;
  65756. /**
  65757. * The l2,-2 coefficients of the spherical harmonics
  65758. */
  65759. l2_2: Vector3;
  65760. /**
  65761. * The l2,-1 coefficients of the spherical harmonics
  65762. */
  65763. l2_1: Vector3;
  65764. /**
  65765. * The l2,0 coefficients of the spherical harmonics
  65766. */
  65767. l20: Vector3;
  65768. /**
  65769. * The l2,1 coefficients of the spherical harmonics
  65770. */
  65771. l21: Vector3;
  65772. /**
  65773. * The l2,2 coefficients of the spherical harmonics
  65774. */
  65775. l22: Vector3;
  65776. /**
  65777. * Adds a light to the spherical harmonics
  65778. * @param direction the direction of the light
  65779. * @param color the color of the light
  65780. * @param deltaSolidAngle the delta solid angle of the light
  65781. */
  65782. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65783. /**
  65784. * Scales the spherical harmonics by the given amount
  65785. * @param scale the amount to scale
  65786. */
  65787. scaleInPlace(scale: number): void;
  65788. /**
  65789. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65790. *
  65791. * ```
  65792. * E_lm = A_l * L_lm
  65793. * ```
  65794. *
  65795. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65796. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65797. * the scaling factors are given in equation 9.
  65798. */
  65799. convertIncidentRadianceToIrradiance(): void;
  65800. /**
  65801. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65802. *
  65803. * ```
  65804. * L = (1/pi) * E * rho
  65805. * ```
  65806. *
  65807. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65808. */
  65809. convertIrradianceToLambertianRadiance(): void;
  65810. /**
  65811. * Integrates the reconstruction coefficients directly in to the SH preventing further
  65812. * required operations at run time.
  65813. *
  65814. * This is simply done by scaling back the SH with Ylm constants parameter.
  65815. * The trigonometric part being applied by the shader at run time.
  65816. */
  65817. preScaleForRendering(): void;
  65818. /**
  65819. * Constructs a spherical harmonics from an array.
  65820. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65821. * @returns the spherical harmonics
  65822. */
  65823. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65824. /**
  65825. * Gets the spherical harmonics from polynomial
  65826. * @param polynomial the spherical polynomial
  65827. * @returns the spherical harmonics
  65828. */
  65829. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65830. }
  65831. /**
  65832. * Class representing spherical polynomial coefficients to the 3rd degree
  65833. */
  65834. export class SphericalPolynomial {
  65835. private _harmonics;
  65836. /**
  65837. * The spherical harmonics used to create the polynomials.
  65838. */
  65839. readonly preScaledHarmonics: SphericalHarmonics;
  65840. /**
  65841. * The x coefficients of the spherical polynomial
  65842. */
  65843. x: Vector3;
  65844. /**
  65845. * The y coefficients of the spherical polynomial
  65846. */
  65847. y: Vector3;
  65848. /**
  65849. * The z coefficients of the spherical polynomial
  65850. */
  65851. z: Vector3;
  65852. /**
  65853. * The xx coefficients of the spherical polynomial
  65854. */
  65855. xx: Vector3;
  65856. /**
  65857. * The yy coefficients of the spherical polynomial
  65858. */
  65859. yy: Vector3;
  65860. /**
  65861. * The zz coefficients of the spherical polynomial
  65862. */
  65863. zz: Vector3;
  65864. /**
  65865. * The xy coefficients of the spherical polynomial
  65866. */
  65867. xy: Vector3;
  65868. /**
  65869. * The yz coefficients of the spherical polynomial
  65870. */
  65871. yz: Vector3;
  65872. /**
  65873. * The zx coefficients of the spherical polynomial
  65874. */
  65875. zx: Vector3;
  65876. /**
  65877. * Adds an ambient color to the spherical polynomial
  65878. * @param color the color to add
  65879. */
  65880. addAmbient(color: Color3): void;
  65881. /**
  65882. * Scales the spherical polynomial by the given amount
  65883. * @param scale the amount to scale
  65884. */
  65885. scaleInPlace(scale: number): void;
  65886. /**
  65887. * Gets the spherical polynomial from harmonics
  65888. * @param harmonics the spherical harmonics
  65889. * @returns the spherical polynomial
  65890. */
  65891. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65892. /**
  65893. * Constructs a spherical polynomial from an array.
  65894. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65895. * @returns the spherical polynomial
  65896. */
  65897. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65898. }
  65899. }
  65900. declare module BABYLON {
  65901. /**
  65902. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65903. */
  65904. export interface CubeMapInfo {
  65905. /**
  65906. * The pixel array for the front face.
  65907. * This is stored in format, left to right, up to down format.
  65908. */
  65909. front: Nullable<ArrayBufferView>;
  65910. /**
  65911. * The pixel array for the back face.
  65912. * This is stored in format, left to right, up to down format.
  65913. */
  65914. back: Nullable<ArrayBufferView>;
  65915. /**
  65916. * The pixel array for the left face.
  65917. * This is stored in format, left to right, up to down format.
  65918. */
  65919. left: Nullable<ArrayBufferView>;
  65920. /**
  65921. * The pixel array for the right face.
  65922. * This is stored in format, left to right, up to down format.
  65923. */
  65924. right: Nullable<ArrayBufferView>;
  65925. /**
  65926. * The pixel array for the up face.
  65927. * This is stored in format, left to right, up to down format.
  65928. */
  65929. up: Nullable<ArrayBufferView>;
  65930. /**
  65931. * The pixel array for the down face.
  65932. * This is stored in format, left to right, up to down format.
  65933. */
  65934. down: Nullable<ArrayBufferView>;
  65935. /**
  65936. * The size of the cubemap stored.
  65937. *
  65938. * Each faces will be size * size pixels.
  65939. */
  65940. size: number;
  65941. /**
  65942. * The format of the texture.
  65943. *
  65944. * RGBA, RGB.
  65945. */
  65946. format: number;
  65947. /**
  65948. * The type of the texture data.
  65949. *
  65950. * UNSIGNED_INT, FLOAT.
  65951. */
  65952. type: number;
  65953. /**
  65954. * Specifies whether the texture is in gamma space.
  65955. */
  65956. gammaSpace: boolean;
  65957. }
  65958. /**
  65959. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65960. */
  65961. export class PanoramaToCubeMapTools {
  65962. private static FACE_FRONT;
  65963. private static FACE_BACK;
  65964. private static FACE_RIGHT;
  65965. private static FACE_LEFT;
  65966. private static FACE_DOWN;
  65967. private static FACE_UP;
  65968. /**
  65969. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65970. *
  65971. * @param float32Array The source data.
  65972. * @param inputWidth The width of the input panorama.
  65973. * @param inputHeight The height of the input panorama.
  65974. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65975. * @return The cubemap data
  65976. */
  65977. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65978. private static CreateCubemapTexture;
  65979. private static CalcProjectionSpherical;
  65980. }
  65981. }
  65982. declare module BABYLON {
  65983. /**
  65984. * Helper class dealing with the extraction of spherical polynomial dataArray
  65985. * from a cube map.
  65986. */
  65987. export class CubeMapToSphericalPolynomialTools {
  65988. private static FileFaces;
  65989. /**
  65990. * Converts a texture to the according Spherical Polynomial data.
  65991. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65992. *
  65993. * @param texture The texture to extract the information from.
  65994. * @return The Spherical Polynomial data.
  65995. */
  65996. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65997. /**
  65998. * Converts a cubemap to the according Spherical Polynomial data.
  65999. * This extracts the first 3 orders only as they are the only one used in the lighting.
  66000. *
  66001. * @param cubeInfo The Cube map to extract the information from.
  66002. * @return The Spherical Polynomial data.
  66003. */
  66004. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  66005. }
  66006. }
  66007. declare module BABYLON {
  66008. /**
  66009. * The engine store class is responsible to hold all the instances of Engine and Scene created
  66010. * during the life time of the application.
  66011. */
  66012. export class EngineStore {
  66013. /** Gets the list of created engines */
  66014. static Instances: Engine[];
  66015. /**
  66016. * Gets the latest created engine
  66017. */
  66018. static readonly LastCreatedEngine: Nullable<Engine>;
  66019. /**
  66020. * Gets the latest created scene
  66021. */
  66022. static readonly LastCreatedScene: Nullable<Scene>;
  66023. }
  66024. }
  66025. declare module BABYLON {
  66026. /**
  66027. * Define options used to create a render target texture
  66028. */
  66029. export class RenderTargetCreationOptions {
  66030. /**
  66031. * Specifies is mipmaps must be generated
  66032. */
  66033. generateMipMaps?: boolean;
  66034. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  66035. generateDepthBuffer?: boolean;
  66036. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  66037. generateStencilBuffer?: boolean;
  66038. /** Defines texture type (int by default) */
  66039. type?: number;
  66040. /** Defines sampling mode (trilinear by default) */
  66041. samplingMode?: number;
  66042. /** Defines format (RGBA by default) */
  66043. format?: number;
  66044. }
  66045. }
  66046. declare module BABYLON {
  66047. /**
  66048. * @hidden
  66049. **/
  66050. export class _AlphaState {
  66051. private _isAlphaBlendDirty;
  66052. private _isBlendFunctionParametersDirty;
  66053. private _isBlendEquationParametersDirty;
  66054. private _isBlendConstantsDirty;
  66055. private _alphaBlend;
  66056. private _blendFunctionParameters;
  66057. private _blendEquationParameters;
  66058. private _blendConstants;
  66059. /**
  66060. * Initializes the state.
  66061. */
  66062. constructor();
  66063. readonly isDirty: boolean;
  66064. alphaBlend: boolean;
  66065. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  66066. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  66067. setAlphaEquationParameters(rgb: number, alpha: number): void;
  66068. reset(): void;
  66069. apply(gl: WebGLRenderingContext): void;
  66070. }
  66071. }
  66072. declare module BABYLON {
  66073. /**
  66074. * @hidden
  66075. **/
  66076. export class _DepthCullingState {
  66077. private _isDepthTestDirty;
  66078. private _isDepthMaskDirty;
  66079. private _isDepthFuncDirty;
  66080. private _isCullFaceDirty;
  66081. private _isCullDirty;
  66082. private _isZOffsetDirty;
  66083. private _isFrontFaceDirty;
  66084. private _depthTest;
  66085. private _depthMask;
  66086. private _depthFunc;
  66087. private _cull;
  66088. private _cullFace;
  66089. private _zOffset;
  66090. private _frontFace;
  66091. /**
  66092. * Initializes the state.
  66093. */
  66094. constructor();
  66095. readonly isDirty: boolean;
  66096. zOffset: number;
  66097. cullFace: Nullable<number>;
  66098. cull: Nullable<boolean>;
  66099. depthFunc: Nullable<number>;
  66100. depthMask: boolean;
  66101. depthTest: boolean;
  66102. frontFace: Nullable<number>;
  66103. reset(): void;
  66104. apply(gl: WebGLRenderingContext): void;
  66105. }
  66106. }
  66107. declare module BABYLON {
  66108. /**
  66109. * @hidden
  66110. **/
  66111. export class _StencilState {
  66112. /** 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 */
  66113. static readonly ALWAYS: number;
  66114. /** Passed to stencilOperation to specify that stencil value must be kept */
  66115. static readonly KEEP: number;
  66116. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66117. static readonly REPLACE: number;
  66118. private _isStencilTestDirty;
  66119. private _isStencilMaskDirty;
  66120. private _isStencilFuncDirty;
  66121. private _isStencilOpDirty;
  66122. private _stencilTest;
  66123. private _stencilMask;
  66124. private _stencilFunc;
  66125. private _stencilFuncRef;
  66126. private _stencilFuncMask;
  66127. private _stencilOpStencilFail;
  66128. private _stencilOpDepthFail;
  66129. private _stencilOpStencilDepthPass;
  66130. readonly isDirty: boolean;
  66131. stencilFunc: number;
  66132. stencilFuncRef: number;
  66133. stencilFuncMask: number;
  66134. stencilOpStencilFail: number;
  66135. stencilOpDepthFail: number;
  66136. stencilOpStencilDepthPass: number;
  66137. stencilMask: number;
  66138. stencilTest: boolean;
  66139. constructor();
  66140. reset(): void;
  66141. apply(gl: WebGLRenderingContext): void;
  66142. }
  66143. }
  66144. declare module BABYLON {
  66145. /**
  66146. * @hidden
  66147. **/
  66148. export class _TimeToken {
  66149. _startTimeQuery: Nullable<WebGLQuery>;
  66150. _endTimeQuery: Nullable<WebGLQuery>;
  66151. _timeElapsedQuery: Nullable<WebGLQuery>;
  66152. _timeElapsedQueryEnded: boolean;
  66153. }
  66154. }
  66155. declare module BABYLON {
  66156. /**
  66157. * Class used to store data associated with WebGL texture data for the engine
  66158. * This class should not be used directly
  66159. */
  66160. export class InternalTexture {
  66161. /** hidden */
  66162. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  66163. /**
  66164. * The source of the texture data is unknown
  66165. */
  66166. static DATASOURCE_UNKNOWN: number;
  66167. /**
  66168. * Texture data comes from an URL
  66169. */
  66170. static DATASOURCE_URL: number;
  66171. /**
  66172. * Texture data is only used for temporary storage
  66173. */
  66174. static DATASOURCE_TEMP: number;
  66175. /**
  66176. * Texture data comes from raw data (ArrayBuffer)
  66177. */
  66178. static DATASOURCE_RAW: number;
  66179. /**
  66180. * Texture content is dynamic (video or dynamic texture)
  66181. */
  66182. static DATASOURCE_DYNAMIC: number;
  66183. /**
  66184. * Texture content is generated by rendering to it
  66185. */
  66186. static DATASOURCE_RENDERTARGET: number;
  66187. /**
  66188. * Texture content is part of a multi render target process
  66189. */
  66190. static DATASOURCE_MULTIRENDERTARGET: number;
  66191. /**
  66192. * Texture data comes from a cube data file
  66193. */
  66194. static DATASOURCE_CUBE: number;
  66195. /**
  66196. * Texture data comes from a raw cube data
  66197. */
  66198. static DATASOURCE_CUBERAW: number;
  66199. /**
  66200. * Texture data come from a prefiltered cube data file
  66201. */
  66202. static DATASOURCE_CUBEPREFILTERED: number;
  66203. /**
  66204. * Texture content is raw 3D data
  66205. */
  66206. static DATASOURCE_RAW3D: number;
  66207. /**
  66208. * Texture content is a depth texture
  66209. */
  66210. static DATASOURCE_DEPTHTEXTURE: number;
  66211. /**
  66212. * Texture data comes from a raw cube data encoded with RGBD
  66213. */
  66214. static DATASOURCE_CUBERAW_RGBD: number;
  66215. /**
  66216. * Defines if the texture is ready
  66217. */
  66218. isReady: boolean;
  66219. /**
  66220. * Defines if the texture is a cube texture
  66221. */
  66222. isCube: boolean;
  66223. /**
  66224. * Defines if the texture contains 3D data
  66225. */
  66226. is3D: boolean;
  66227. /**
  66228. * Defines if the texture contains multiview data
  66229. */
  66230. isMultiview: boolean;
  66231. /**
  66232. * Gets the URL used to load this texture
  66233. */
  66234. url: string;
  66235. /**
  66236. * Gets the sampling mode of the texture
  66237. */
  66238. samplingMode: number;
  66239. /**
  66240. * Gets a boolean indicating if the texture needs mipmaps generation
  66241. */
  66242. generateMipMaps: boolean;
  66243. /**
  66244. * Gets the number of samples used by the texture (WebGL2+ only)
  66245. */
  66246. samples: number;
  66247. /**
  66248. * Gets the type of the texture (int, float...)
  66249. */
  66250. type: number;
  66251. /**
  66252. * Gets the format of the texture (RGB, RGBA...)
  66253. */
  66254. format: number;
  66255. /**
  66256. * Observable called when the texture is loaded
  66257. */
  66258. onLoadedObservable: Observable<InternalTexture>;
  66259. /**
  66260. * Gets the width of the texture
  66261. */
  66262. width: number;
  66263. /**
  66264. * Gets the height of the texture
  66265. */
  66266. height: number;
  66267. /**
  66268. * Gets the depth of the texture
  66269. */
  66270. depth: number;
  66271. /**
  66272. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  66273. */
  66274. baseWidth: number;
  66275. /**
  66276. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  66277. */
  66278. baseHeight: number;
  66279. /**
  66280. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  66281. */
  66282. baseDepth: number;
  66283. /**
  66284. * Gets a boolean indicating if the texture is inverted on Y axis
  66285. */
  66286. invertY: boolean;
  66287. /** @hidden */
  66288. _invertVScale: boolean;
  66289. /** @hidden */
  66290. _associatedChannel: number;
  66291. /** @hidden */
  66292. _dataSource: number;
  66293. /** @hidden */
  66294. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  66295. /** @hidden */
  66296. _bufferView: Nullable<ArrayBufferView>;
  66297. /** @hidden */
  66298. _bufferViewArray: Nullable<ArrayBufferView[]>;
  66299. /** @hidden */
  66300. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  66301. /** @hidden */
  66302. _size: number;
  66303. /** @hidden */
  66304. _extension: string;
  66305. /** @hidden */
  66306. _files: Nullable<string[]>;
  66307. /** @hidden */
  66308. _workingCanvas: Nullable<HTMLCanvasElement>;
  66309. /** @hidden */
  66310. _workingContext: Nullable<CanvasRenderingContext2D>;
  66311. /** @hidden */
  66312. _framebuffer: Nullable<WebGLFramebuffer>;
  66313. /** @hidden */
  66314. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  66315. /** @hidden */
  66316. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  66317. /** @hidden */
  66318. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  66319. /** @hidden */
  66320. _attachments: Nullable<number[]>;
  66321. /** @hidden */
  66322. _cachedCoordinatesMode: Nullable<number>;
  66323. /** @hidden */
  66324. _cachedWrapU: Nullable<number>;
  66325. /** @hidden */
  66326. _cachedWrapV: Nullable<number>;
  66327. /** @hidden */
  66328. _cachedWrapR: Nullable<number>;
  66329. /** @hidden */
  66330. _cachedAnisotropicFilteringLevel: Nullable<number>;
  66331. /** @hidden */
  66332. _isDisabled: boolean;
  66333. /** @hidden */
  66334. _compression: Nullable<string>;
  66335. /** @hidden */
  66336. _generateStencilBuffer: boolean;
  66337. /** @hidden */
  66338. _generateDepthBuffer: boolean;
  66339. /** @hidden */
  66340. _comparisonFunction: number;
  66341. /** @hidden */
  66342. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66343. /** @hidden */
  66344. _lodGenerationScale: number;
  66345. /** @hidden */
  66346. _lodGenerationOffset: number;
  66347. /** @hidden */
  66348. _colorTextureArray: Nullable<WebGLTexture>;
  66349. /** @hidden */
  66350. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66351. /** @hidden */
  66352. _lodTextureHigh: Nullable<BaseTexture>;
  66353. /** @hidden */
  66354. _lodTextureMid: Nullable<BaseTexture>;
  66355. /** @hidden */
  66356. _lodTextureLow: Nullable<BaseTexture>;
  66357. /** @hidden */
  66358. _isRGBD: boolean;
  66359. /** @hidden */
  66360. _webGLTexture: Nullable<WebGLTexture>;
  66361. /** @hidden */
  66362. _references: number;
  66363. private _engine;
  66364. /**
  66365. * Gets the Engine the texture belongs to.
  66366. * @returns The babylon engine
  66367. */
  66368. getEngine(): Engine;
  66369. /**
  66370. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66371. */
  66372. readonly dataSource: number;
  66373. /**
  66374. * Creates a new InternalTexture
  66375. * @param engine defines the engine to use
  66376. * @param dataSource defines the type of data that will be used
  66377. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66378. */
  66379. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66380. /**
  66381. * Increments the number of references (ie. the number of Texture that point to it)
  66382. */
  66383. incrementReferences(): void;
  66384. /**
  66385. * Change the size of the texture (not the size of the content)
  66386. * @param width defines the new width
  66387. * @param height defines the new height
  66388. * @param depth defines the new depth (1 by default)
  66389. */
  66390. updateSize(width: int, height: int, depth?: int): void;
  66391. /** @hidden */
  66392. _rebuild(): void;
  66393. /** @hidden */
  66394. _swapAndDie(target: InternalTexture): void;
  66395. /**
  66396. * Dispose the current allocated resources
  66397. */
  66398. dispose(): void;
  66399. }
  66400. }
  66401. declare module BABYLON {
  66402. /**
  66403. * This represents the main contract an easing function should follow.
  66404. * Easing functions are used throughout the animation system.
  66405. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66406. */
  66407. export interface IEasingFunction {
  66408. /**
  66409. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66410. * of the easing function.
  66411. * The link below provides some of the most common examples of easing functions.
  66412. * @see https://easings.net/
  66413. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66414. * @returns the corresponding value on the curve defined by the easing function
  66415. */
  66416. ease(gradient: number): number;
  66417. }
  66418. /**
  66419. * Base class used for every default easing function.
  66420. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66421. */
  66422. export class EasingFunction implements IEasingFunction {
  66423. /**
  66424. * Interpolation follows the mathematical formula associated with the easing function.
  66425. */
  66426. static readonly EASINGMODE_EASEIN: number;
  66427. /**
  66428. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66429. */
  66430. static readonly EASINGMODE_EASEOUT: number;
  66431. /**
  66432. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66433. */
  66434. static readonly EASINGMODE_EASEINOUT: number;
  66435. private _easingMode;
  66436. /**
  66437. * Sets the easing mode of the current function.
  66438. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66439. */
  66440. setEasingMode(easingMode: number): void;
  66441. /**
  66442. * Gets the current easing mode.
  66443. * @returns the easing mode
  66444. */
  66445. getEasingMode(): number;
  66446. /**
  66447. * @hidden
  66448. */
  66449. easeInCore(gradient: number): number;
  66450. /**
  66451. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66452. * of the easing function.
  66453. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66454. * @returns the corresponding value on the curve defined by the easing function
  66455. */
  66456. ease(gradient: number): number;
  66457. }
  66458. /**
  66459. * Easing function with a circle shape (see link below).
  66460. * @see https://easings.net/#easeInCirc
  66461. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66462. */
  66463. export class CircleEase extends EasingFunction implements IEasingFunction {
  66464. /** @hidden */
  66465. easeInCore(gradient: number): number;
  66466. }
  66467. /**
  66468. * Easing function with a ease back shape (see link below).
  66469. * @see https://easings.net/#easeInBack
  66470. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66471. */
  66472. export class BackEase extends EasingFunction implements IEasingFunction {
  66473. /** Defines the amplitude of the function */
  66474. amplitude: number;
  66475. /**
  66476. * Instantiates a back ease easing
  66477. * @see https://easings.net/#easeInBack
  66478. * @param amplitude Defines the amplitude of the function
  66479. */
  66480. constructor(
  66481. /** Defines the amplitude of the function */
  66482. amplitude?: number);
  66483. /** @hidden */
  66484. easeInCore(gradient: number): number;
  66485. }
  66486. /**
  66487. * Easing function with a bouncing shape (see link below).
  66488. * @see https://easings.net/#easeInBounce
  66489. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66490. */
  66491. export class BounceEase extends EasingFunction implements IEasingFunction {
  66492. /** Defines the number of bounces */
  66493. bounces: number;
  66494. /** Defines the amplitude of the bounce */
  66495. bounciness: number;
  66496. /**
  66497. * Instantiates a bounce easing
  66498. * @see https://easings.net/#easeInBounce
  66499. * @param bounces Defines the number of bounces
  66500. * @param bounciness Defines the amplitude of the bounce
  66501. */
  66502. constructor(
  66503. /** Defines the number of bounces */
  66504. bounces?: number,
  66505. /** Defines the amplitude of the bounce */
  66506. bounciness?: number);
  66507. /** @hidden */
  66508. easeInCore(gradient: number): number;
  66509. }
  66510. /**
  66511. * Easing function with a power of 3 shape (see link below).
  66512. * @see https://easings.net/#easeInCubic
  66513. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66514. */
  66515. export class CubicEase extends EasingFunction implements IEasingFunction {
  66516. /** @hidden */
  66517. easeInCore(gradient: number): number;
  66518. }
  66519. /**
  66520. * Easing function with an elastic shape (see link below).
  66521. * @see https://easings.net/#easeInElastic
  66522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66523. */
  66524. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66525. /** Defines the number of oscillations*/
  66526. oscillations: number;
  66527. /** Defines the amplitude of the oscillations*/
  66528. springiness: number;
  66529. /**
  66530. * Instantiates an elastic easing function
  66531. * @see https://easings.net/#easeInElastic
  66532. * @param oscillations Defines the number of oscillations
  66533. * @param springiness Defines the amplitude of the oscillations
  66534. */
  66535. constructor(
  66536. /** Defines the number of oscillations*/
  66537. oscillations?: number,
  66538. /** Defines the amplitude of the oscillations*/
  66539. springiness?: number);
  66540. /** @hidden */
  66541. easeInCore(gradient: number): number;
  66542. }
  66543. /**
  66544. * Easing function with an exponential shape (see link below).
  66545. * @see https://easings.net/#easeInExpo
  66546. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66547. */
  66548. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66549. /** Defines the exponent of the function */
  66550. exponent: number;
  66551. /**
  66552. * Instantiates an exponential easing function
  66553. * @see https://easings.net/#easeInExpo
  66554. * @param exponent Defines the exponent of the function
  66555. */
  66556. constructor(
  66557. /** Defines the exponent of the function */
  66558. exponent?: number);
  66559. /** @hidden */
  66560. easeInCore(gradient: number): number;
  66561. }
  66562. /**
  66563. * Easing function with a power shape (see link below).
  66564. * @see https://easings.net/#easeInQuad
  66565. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66566. */
  66567. export class PowerEase extends EasingFunction implements IEasingFunction {
  66568. /** Defines the power of the function */
  66569. power: number;
  66570. /**
  66571. * Instantiates an power base easing function
  66572. * @see https://easings.net/#easeInQuad
  66573. * @param power Defines the power of the function
  66574. */
  66575. constructor(
  66576. /** Defines the power of the function */
  66577. power?: number);
  66578. /** @hidden */
  66579. easeInCore(gradient: number): number;
  66580. }
  66581. /**
  66582. * Easing function with a power of 2 shape (see link below).
  66583. * @see https://easings.net/#easeInQuad
  66584. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66585. */
  66586. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66587. /** @hidden */
  66588. easeInCore(gradient: number): number;
  66589. }
  66590. /**
  66591. * Easing function with a power of 4 shape (see link below).
  66592. * @see https://easings.net/#easeInQuart
  66593. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66594. */
  66595. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66596. /** @hidden */
  66597. easeInCore(gradient: number): number;
  66598. }
  66599. /**
  66600. * Easing function with a power of 5 shape (see link below).
  66601. * @see https://easings.net/#easeInQuint
  66602. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66603. */
  66604. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66605. /** @hidden */
  66606. easeInCore(gradient: number): number;
  66607. }
  66608. /**
  66609. * Easing function with a sin shape (see link below).
  66610. * @see https://easings.net/#easeInSine
  66611. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66612. */
  66613. export class SineEase extends EasingFunction implements IEasingFunction {
  66614. /** @hidden */
  66615. easeInCore(gradient: number): number;
  66616. }
  66617. /**
  66618. * Easing function with a bezier shape (see link below).
  66619. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66620. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66621. */
  66622. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66623. /** Defines the x component of the start tangent in the bezier curve */
  66624. x1: number;
  66625. /** Defines the y component of the start tangent in the bezier curve */
  66626. y1: number;
  66627. /** Defines the x component of the end tangent in the bezier curve */
  66628. x2: number;
  66629. /** Defines the y component of the end tangent in the bezier curve */
  66630. y2: number;
  66631. /**
  66632. * Instantiates a bezier function
  66633. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66634. * @param x1 Defines the x component of the start tangent in the bezier curve
  66635. * @param y1 Defines the y component of the start tangent in the bezier curve
  66636. * @param x2 Defines the x component of the end tangent in the bezier curve
  66637. * @param y2 Defines the y component of the end tangent in the bezier curve
  66638. */
  66639. constructor(
  66640. /** Defines the x component of the start tangent in the bezier curve */
  66641. x1?: number,
  66642. /** Defines the y component of the start tangent in the bezier curve */
  66643. y1?: number,
  66644. /** Defines the x component of the end tangent in the bezier curve */
  66645. x2?: number,
  66646. /** Defines the y component of the end tangent in the bezier curve */
  66647. y2?: number);
  66648. /** @hidden */
  66649. easeInCore(gradient: number): number;
  66650. }
  66651. }
  66652. declare module BABYLON {
  66653. /**
  66654. * Defines an interface which represents an animation key frame
  66655. */
  66656. export interface IAnimationKey {
  66657. /**
  66658. * Frame of the key frame
  66659. */
  66660. frame: number;
  66661. /**
  66662. * Value at the specifies key frame
  66663. */
  66664. value: any;
  66665. /**
  66666. * The input tangent for the cubic hermite spline
  66667. */
  66668. inTangent?: any;
  66669. /**
  66670. * The output tangent for the cubic hermite spline
  66671. */
  66672. outTangent?: any;
  66673. /**
  66674. * The animation interpolation type
  66675. */
  66676. interpolation?: AnimationKeyInterpolation;
  66677. }
  66678. /**
  66679. * Enum for the animation key frame interpolation type
  66680. */
  66681. export enum AnimationKeyInterpolation {
  66682. /**
  66683. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66684. */
  66685. STEP = 1
  66686. }
  66687. }
  66688. declare module BABYLON {
  66689. /**
  66690. * Represents the range of an animation
  66691. */
  66692. export class AnimationRange {
  66693. /**The name of the animation range**/
  66694. name: string;
  66695. /**The starting frame of the animation */
  66696. from: number;
  66697. /**The ending frame of the animation*/
  66698. to: number;
  66699. /**
  66700. * Initializes the range of an animation
  66701. * @param name The name of the animation range
  66702. * @param from The starting frame of the animation
  66703. * @param to The ending frame of the animation
  66704. */
  66705. constructor(
  66706. /**The name of the animation range**/
  66707. name: string,
  66708. /**The starting frame of the animation */
  66709. from: number,
  66710. /**The ending frame of the animation*/
  66711. to: number);
  66712. /**
  66713. * Makes a copy of the animation range
  66714. * @returns A copy of the animation range
  66715. */
  66716. clone(): AnimationRange;
  66717. }
  66718. }
  66719. declare module BABYLON {
  66720. /**
  66721. * Composed of a frame, and an action function
  66722. */
  66723. export class AnimationEvent {
  66724. /** The frame for which the event is triggered **/
  66725. frame: number;
  66726. /** The event to perform when triggered **/
  66727. action: (currentFrame: number) => void;
  66728. /** Specifies if the event should be triggered only once**/
  66729. onlyOnce?: boolean | undefined;
  66730. /**
  66731. * Specifies if the animation event is done
  66732. */
  66733. isDone: boolean;
  66734. /**
  66735. * Initializes the animation event
  66736. * @param frame The frame for which the event is triggered
  66737. * @param action The event to perform when triggered
  66738. * @param onlyOnce Specifies if the event should be triggered only once
  66739. */
  66740. constructor(
  66741. /** The frame for which the event is triggered **/
  66742. frame: number,
  66743. /** The event to perform when triggered **/
  66744. action: (currentFrame: number) => void,
  66745. /** Specifies if the event should be triggered only once**/
  66746. onlyOnce?: boolean | undefined);
  66747. /** @hidden */
  66748. _clone(): AnimationEvent;
  66749. }
  66750. }
  66751. declare module BABYLON {
  66752. /**
  66753. * Interface used to define a behavior
  66754. */
  66755. export interface Behavior<T> {
  66756. /** gets or sets behavior's name */
  66757. name: string;
  66758. /**
  66759. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66760. */
  66761. init(): void;
  66762. /**
  66763. * Called when the behavior is attached to a target
  66764. * @param target defines the target where the behavior is attached to
  66765. */
  66766. attach(target: T): void;
  66767. /**
  66768. * Called when the behavior is detached from its target
  66769. */
  66770. detach(): void;
  66771. }
  66772. /**
  66773. * Interface implemented by classes supporting behaviors
  66774. */
  66775. export interface IBehaviorAware<T> {
  66776. /**
  66777. * Attach a behavior
  66778. * @param behavior defines the behavior to attach
  66779. * @returns the current host
  66780. */
  66781. addBehavior(behavior: Behavior<T>): T;
  66782. /**
  66783. * Remove a behavior from the current object
  66784. * @param behavior defines the behavior to detach
  66785. * @returns the current host
  66786. */
  66787. removeBehavior(behavior: Behavior<T>): T;
  66788. /**
  66789. * Gets a behavior using its name to search
  66790. * @param name defines the name to search
  66791. * @returns the behavior or null if not found
  66792. */
  66793. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66794. }
  66795. }
  66796. declare module BABYLON {
  66797. /**
  66798. * @hidden
  66799. */
  66800. export class IntersectionInfo {
  66801. bu: Nullable<number>;
  66802. bv: Nullable<number>;
  66803. distance: number;
  66804. faceId: number;
  66805. subMeshId: number;
  66806. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66807. }
  66808. }
  66809. declare module BABYLON {
  66810. /**
  66811. * Class used to store bounding sphere information
  66812. */
  66813. export class BoundingSphere {
  66814. /**
  66815. * Gets the center of the bounding sphere in local space
  66816. */
  66817. readonly center: Vector3;
  66818. /**
  66819. * Radius of the bounding sphere in local space
  66820. */
  66821. radius: number;
  66822. /**
  66823. * Gets the center of the bounding sphere in world space
  66824. */
  66825. readonly centerWorld: Vector3;
  66826. /**
  66827. * Radius of the bounding sphere in world space
  66828. */
  66829. radiusWorld: number;
  66830. /**
  66831. * Gets the minimum vector in local space
  66832. */
  66833. readonly minimum: Vector3;
  66834. /**
  66835. * Gets the maximum vector in local space
  66836. */
  66837. readonly maximum: Vector3;
  66838. private _worldMatrix;
  66839. private static readonly TmpVector3;
  66840. /**
  66841. * Creates a new bounding sphere
  66842. * @param min defines the minimum vector (in local space)
  66843. * @param max defines the maximum vector (in local space)
  66844. * @param worldMatrix defines the new world matrix
  66845. */
  66846. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66847. /**
  66848. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66849. * @param min defines the new minimum vector (in local space)
  66850. * @param max defines the new maximum vector (in local space)
  66851. * @param worldMatrix defines the new world matrix
  66852. */
  66853. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66854. /**
  66855. * Scale the current bounding sphere by applying a scale factor
  66856. * @param factor defines the scale factor to apply
  66857. * @returns the current bounding box
  66858. */
  66859. scale(factor: number): BoundingSphere;
  66860. /**
  66861. * Gets the world matrix of the bounding box
  66862. * @returns a matrix
  66863. */
  66864. getWorldMatrix(): DeepImmutable<Matrix>;
  66865. /** @hidden */
  66866. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66867. /**
  66868. * Tests if the bounding sphere is intersecting the frustum planes
  66869. * @param frustumPlanes defines the frustum planes to test
  66870. * @returns true if there is an intersection
  66871. */
  66872. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66873. /**
  66874. * Tests if the bounding sphere center is in between the frustum planes.
  66875. * Used for optimistic fast inclusion.
  66876. * @param frustumPlanes defines the frustum planes to test
  66877. * @returns true if the sphere center is in between the frustum planes
  66878. */
  66879. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66880. /**
  66881. * Tests if a point is inside the bounding sphere
  66882. * @param point defines the point to test
  66883. * @returns true if the point is inside the bounding sphere
  66884. */
  66885. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66886. /**
  66887. * Checks if two sphere intersct
  66888. * @param sphere0 sphere 0
  66889. * @param sphere1 sphere 1
  66890. * @returns true if the speres intersect
  66891. */
  66892. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66893. }
  66894. }
  66895. declare module BABYLON {
  66896. /**
  66897. * Class used to store bounding box information
  66898. */
  66899. export class BoundingBox implements ICullable {
  66900. /**
  66901. * Gets the 8 vectors representing the bounding box in local space
  66902. */
  66903. readonly vectors: Vector3[];
  66904. /**
  66905. * Gets the center of the bounding box in local space
  66906. */
  66907. readonly center: Vector3;
  66908. /**
  66909. * Gets the center of the bounding box in world space
  66910. */
  66911. readonly centerWorld: Vector3;
  66912. /**
  66913. * Gets the extend size in local space
  66914. */
  66915. readonly extendSize: Vector3;
  66916. /**
  66917. * Gets the extend size in world space
  66918. */
  66919. readonly extendSizeWorld: Vector3;
  66920. /**
  66921. * Gets the OBB (object bounding box) directions
  66922. */
  66923. readonly directions: Vector3[];
  66924. /**
  66925. * Gets the 8 vectors representing the bounding box in world space
  66926. */
  66927. readonly vectorsWorld: Vector3[];
  66928. /**
  66929. * Gets the minimum vector in world space
  66930. */
  66931. readonly minimumWorld: Vector3;
  66932. /**
  66933. * Gets the maximum vector in world space
  66934. */
  66935. readonly maximumWorld: Vector3;
  66936. /**
  66937. * Gets the minimum vector in local space
  66938. */
  66939. readonly minimum: Vector3;
  66940. /**
  66941. * Gets the maximum vector in local space
  66942. */
  66943. readonly maximum: Vector3;
  66944. private _worldMatrix;
  66945. private static readonly TmpVector3;
  66946. /**
  66947. * @hidden
  66948. */
  66949. _tag: number;
  66950. /**
  66951. * Creates a new bounding box
  66952. * @param min defines the minimum vector (in local space)
  66953. * @param max defines the maximum vector (in local space)
  66954. * @param worldMatrix defines the new world matrix
  66955. */
  66956. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66957. /**
  66958. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66959. * @param min defines the new minimum vector (in local space)
  66960. * @param max defines the new maximum vector (in local space)
  66961. * @param worldMatrix defines the new world matrix
  66962. */
  66963. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66964. /**
  66965. * Scale the current bounding box by applying a scale factor
  66966. * @param factor defines the scale factor to apply
  66967. * @returns the current bounding box
  66968. */
  66969. scale(factor: number): BoundingBox;
  66970. /**
  66971. * Gets the world matrix of the bounding box
  66972. * @returns a matrix
  66973. */
  66974. getWorldMatrix(): DeepImmutable<Matrix>;
  66975. /** @hidden */
  66976. _update(world: DeepImmutable<Matrix>): void;
  66977. /**
  66978. * Tests if the bounding box is intersecting the frustum planes
  66979. * @param frustumPlanes defines the frustum planes to test
  66980. * @returns true if there is an intersection
  66981. */
  66982. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66983. /**
  66984. * Tests if the bounding box is entirely inside the frustum planes
  66985. * @param frustumPlanes defines the frustum planes to test
  66986. * @returns true if there is an inclusion
  66987. */
  66988. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66989. /**
  66990. * Tests if a point is inside the bounding box
  66991. * @param point defines the point to test
  66992. * @returns true if the point is inside the bounding box
  66993. */
  66994. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66995. /**
  66996. * Tests if the bounding box intersects with a bounding sphere
  66997. * @param sphere defines the sphere to test
  66998. * @returns true if there is an intersection
  66999. */
  67000. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  67001. /**
  67002. * Tests if the bounding box intersects with a box defined by a min and max vectors
  67003. * @param min defines the min vector to use
  67004. * @param max defines the max vector to use
  67005. * @returns true if there is an intersection
  67006. */
  67007. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  67008. /**
  67009. * Tests if two bounding boxes are intersections
  67010. * @param box0 defines the first box to test
  67011. * @param box1 defines the second box to test
  67012. * @returns true if there is an intersection
  67013. */
  67014. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  67015. /**
  67016. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  67017. * @param minPoint defines the minimum vector of the bounding box
  67018. * @param maxPoint defines the maximum vector of the bounding box
  67019. * @param sphereCenter defines the sphere center
  67020. * @param sphereRadius defines the sphere radius
  67021. * @returns true if there is an intersection
  67022. */
  67023. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  67024. /**
  67025. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  67026. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67027. * @param frustumPlanes defines the frustum planes to test
  67028. * @return true if there is an inclusion
  67029. */
  67030. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67031. /**
  67032. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  67033. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67034. * @param frustumPlanes defines the frustum planes to test
  67035. * @return true if there is an intersection
  67036. */
  67037. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67038. }
  67039. }
  67040. declare module BABYLON {
  67041. /** @hidden */
  67042. export class Collider {
  67043. /** Define if a collision was found */
  67044. collisionFound: boolean;
  67045. /**
  67046. * Define last intersection point in local space
  67047. */
  67048. intersectionPoint: Vector3;
  67049. /**
  67050. * Define last collided mesh
  67051. */
  67052. collidedMesh: Nullable<AbstractMesh>;
  67053. private _collisionPoint;
  67054. private _planeIntersectionPoint;
  67055. private _tempVector;
  67056. private _tempVector2;
  67057. private _tempVector3;
  67058. private _tempVector4;
  67059. private _edge;
  67060. private _baseToVertex;
  67061. private _destinationPoint;
  67062. private _slidePlaneNormal;
  67063. private _displacementVector;
  67064. /** @hidden */
  67065. _radius: Vector3;
  67066. /** @hidden */
  67067. _retry: number;
  67068. private _velocity;
  67069. private _basePoint;
  67070. private _epsilon;
  67071. /** @hidden */
  67072. _velocityWorldLength: number;
  67073. /** @hidden */
  67074. _basePointWorld: Vector3;
  67075. private _velocityWorld;
  67076. private _normalizedVelocity;
  67077. /** @hidden */
  67078. _initialVelocity: Vector3;
  67079. /** @hidden */
  67080. _initialPosition: Vector3;
  67081. private _nearestDistance;
  67082. private _collisionMask;
  67083. collisionMask: number;
  67084. /**
  67085. * Gets the plane normal used to compute the sliding response (in local space)
  67086. */
  67087. readonly slidePlaneNormal: Vector3;
  67088. /** @hidden */
  67089. _initialize(source: Vector3, dir: Vector3, e: number): void;
  67090. /** @hidden */
  67091. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  67092. /** @hidden */
  67093. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  67094. /** @hidden */
  67095. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  67096. /** @hidden */
  67097. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  67098. /** @hidden */
  67099. _getResponse(pos: Vector3, vel: Vector3): void;
  67100. }
  67101. }
  67102. declare module BABYLON {
  67103. /**
  67104. * Interface for cullable objects
  67105. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  67106. */
  67107. export interface ICullable {
  67108. /**
  67109. * Checks if the object or part of the object is in the frustum
  67110. * @param frustumPlanes Camera near/planes
  67111. * @returns true if the object is in frustum otherwise false
  67112. */
  67113. isInFrustum(frustumPlanes: Plane[]): boolean;
  67114. /**
  67115. * Checks if a cullable object (mesh...) is in the camera frustum
  67116. * Unlike isInFrustum this cheks the full bounding box
  67117. * @param frustumPlanes Camera near/planes
  67118. * @returns true if the object is in frustum otherwise false
  67119. */
  67120. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  67121. }
  67122. /**
  67123. * Info for a bounding data of a mesh
  67124. */
  67125. export class BoundingInfo implements ICullable {
  67126. /**
  67127. * Bounding box for the mesh
  67128. */
  67129. readonly boundingBox: BoundingBox;
  67130. /**
  67131. * Bounding sphere for the mesh
  67132. */
  67133. readonly boundingSphere: BoundingSphere;
  67134. private _isLocked;
  67135. private static readonly TmpVector3;
  67136. /**
  67137. * Constructs bounding info
  67138. * @param minimum min vector of the bounding box/sphere
  67139. * @param maximum max vector of the bounding box/sphere
  67140. * @param worldMatrix defines the new world matrix
  67141. */
  67142. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67143. /**
  67144. * Recreates the entire bounding info from scratch as if we call the constructor in place
  67145. * @param min defines the new minimum vector (in local space)
  67146. * @param max defines the new maximum vector (in local space)
  67147. * @param worldMatrix defines the new world matrix
  67148. */
  67149. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67150. /**
  67151. * min vector of the bounding box/sphere
  67152. */
  67153. readonly minimum: Vector3;
  67154. /**
  67155. * max vector of the bounding box/sphere
  67156. */
  67157. readonly maximum: Vector3;
  67158. /**
  67159. * If the info is locked and won't be updated to avoid perf overhead
  67160. */
  67161. isLocked: boolean;
  67162. /**
  67163. * Updates the bounding sphere and box
  67164. * @param world world matrix to be used to update
  67165. */
  67166. update(world: DeepImmutable<Matrix>): void;
  67167. /**
  67168. * Recreate the bounding info to be centered around a specific point given a specific extend.
  67169. * @param center New center of the bounding info
  67170. * @param extend New extend of the bounding info
  67171. * @returns the current bounding info
  67172. */
  67173. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  67174. /**
  67175. * Scale the current bounding info by applying a scale factor
  67176. * @param factor defines the scale factor to apply
  67177. * @returns the current bounding info
  67178. */
  67179. scale(factor: number): BoundingInfo;
  67180. /**
  67181. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  67182. * @param frustumPlanes defines the frustum to test
  67183. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  67184. * @returns true if the bounding info is in the frustum planes
  67185. */
  67186. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  67187. /**
  67188. * Gets the world distance between the min and max points of the bounding box
  67189. */
  67190. readonly diagonalLength: number;
  67191. /**
  67192. * Checks if a cullable object (mesh...) is in the camera frustum
  67193. * Unlike isInFrustum this cheks the full bounding box
  67194. * @param frustumPlanes Camera near/planes
  67195. * @returns true if the object is in frustum otherwise false
  67196. */
  67197. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67198. /** @hidden */
  67199. _checkCollision(collider: Collider): boolean;
  67200. /**
  67201. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  67202. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67203. * @param point the point to check intersection with
  67204. * @returns if the point intersects
  67205. */
  67206. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67207. /**
  67208. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  67209. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67210. * @param boundingInfo the bounding info to check intersection with
  67211. * @param precise if the intersection should be done using OBB
  67212. * @returns if the bounding info intersects
  67213. */
  67214. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  67215. }
  67216. }
  67217. declare module BABYLON {
  67218. /**
  67219. * Defines an array and its length.
  67220. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  67221. */
  67222. export interface ISmartArrayLike<T> {
  67223. /**
  67224. * The data of the array.
  67225. */
  67226. data: Array<T>;
  67227. /**
  67228. * The active length of the array.
  67229. */
  67230. length: number;
  67231. }
  67232. /**
  67233. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67234. */
  67235. export class SmartArray<T> implements ISmartArrayLike<T> {
  67236. /**
  67237. * The full set of data from the array.
  67238. */
  67239. data: Array<T>;
  67240. /**
  67241. * The active length of the array.
  67242. */
  67243. length: number;
  67244. protected _id: number;
  67245. /**
  67246. * Instantiates a Smart Array.
  67247. * @param capacity defines the default capacity of the array.
  67248. */
  67249. constructor(capacity: number);
  67250. /**
  67251. * Pushes a value at the end of the active data.
  67252. * @param value defines the object to push in the array.
  67253. */
  67254. push(value: T): void;
  67255. /**
  67256. * Iterates over the active data and apply the lambda to them.
  67257. * @param func defines the action to apply on each value.
  67258. */
  67259. forEach(func: (content: T) => void): void;
  67260. /**
  67261. * Sorts the full sets of data.
  67262. * @param compareFn defines the comparison function to apply.
  67263. */
  67264. sort(compareFn: (a: T, b: T) => number): void;
  67265. /**
  67266. * Resets the active data to an empty array.
  67267. */
  67268. reset(): void;
  67269. /**
  67270. * Releases all the data from the array as well as the array.
  67271. */
  67272. dispose(): void;
  67273. /**
  67274. * Concats the active data with a given array.
  67275. * @param array defines the data to concatenate with.
  67276. */
  67277. concat(array: any): void;
  67278. /**
  67279. * Returns the position of a value in the active data.
  67280. * @param value defines the value to find the index for
  67281. * @returns the index if found in the active data otherwise -1
  67282. */
  67283. indexOf(value: T): number;
  67284. /**
  67285. * Returns whether an element is part of the active data.
  67286. * @param value defines the value to look for
  67287. * @returns true if found in the active data otherwise false
  67288. */
  67289. contains(value: T): boolean;
  67290. private static _GlobalId;
  67291. }
  67292. /**
  67293. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67294. * The data in this array can only be present once
  67295. */
  67296. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  67297. private _duplicateId;
  67298. /**
  67299. * Pushes a value at the end of the active data.
  67300. * THIS DOES NOT PREVENT DUPPLICATE DATA
  67301. * @param value defines the object to push in the array.
  67302. */
  67303. push(value: T): void;
  67304. /**
  67305. * Pushes a value at the end of the active data.
  67306. * If the data is already present, it won t be added again
  67307. * @param value defines the object to push in the array.
  67308. * @returns true if added false if it was already present
  67309. */
  67310. pushNoDuplicate(value: T): boolean;
  67311. /**
  67312. * Resets the active data to an empty array.
  67313. */
  67314. reset(): void;
  67315. /**
  67316. * Concats the active data with a given array.
  67317. * This ensures no dupplicate will be present in the result.
  67318. * @param array defines the data to concatenate with.
  67319. */
  67320. concatWithNoDuplicate(array: any): void;
  67321. }
  67322. }
  67323. declare module BABYLON {
  67324. /**
  67325. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67326. * separate meshes. This can be use to improve performances.
  67327. * @see http://doc.babylonjs.com/how_to/multi_materials
  67328. */
  67329. export class MultiMaterial extends Material {
  67330. private _subMaterials;
  67331. /**
  67332. * Gets or Sets the list of Materials used within the multi material.
  67333. * They need to be ordered according to the submeshes order in the associated mesh
  67334. */
  67335. subMaterials: Nullable<Material>[];
  67336. /**
  67337. * Function used to align with Node.getChildren()
  67338. * @returns the list of Materials used within the multi material
  67339. */
  67340. getChildren(): Nullable<Material>[];
  67341. /**
  67342. * Instantiates a new Multi Material
  67343. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67344. * separate meshes. This can be use to improve performances.
  67345. * @see http://doc.babylonjs.com/how_to/multi_materials
  67346. * @param name Define the name in the scene
  67347. * @param scene Define the scene the material belongs to
  67348. */
  67349. constructor(name: string, scene: Scene);
  67350. private _hookArray;
  67351. /**
  67352. * Get one of the submaterial by its index in the submaterials array
  67353. * @param index The index to look the sub material at
  67354. * @returns The Material if the index has been defined
  67355. */
  67356. getSubMaterial(index: number): Nullable<Material>;
  67357. /**
  67358. * Get the list of active textures for the whole sub materials list.
  67359. * @returns All the textures that will be used during the rendering
  67360. */
  67361. getActiveTextures(): BaseTexture[];
  67362. /**
  67363. * Gets the current class name of the material e.g. "MultiMaterial"
  67364. * Mainly use in serialization.
  67365. * @returns the class name
  67366. */
  67367. getClassName(): string;
  67368. /**
  67369. * Checks if the material is ready to render the requested sub mesh
  67370. * @param mesh Define the mesh the submesh belongs to
  67371. * @param subMesh Define the sub mesh to look readyness for
  67372. * @param useInstances Define whether or not the material is used with instances
  67373. * @returns true if ready, otherwise false
  67374. */
  67375. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67376. /**
  67377. * Clones the current material and its related sub materials
  67378. * @param name Define the name of the newly cloned material
  67379. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67380. * @returns the cloned material
  67381. */
  67382. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67383. /**
  67384. * Serializes the materials into a JSON representation.
  67385. * @returns the JSON representation
  67386. */
  67387. serialize(): any;
  67388. /**
  67389. * Dispose the material and release its associated resources
  67390. * @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)
  67391. * @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)
  67392. * @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)
  67393. */
  67394. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67395. /**
  67396. * Creates a MultiMaterial from parsed MultiMaterial data.
  67397. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67398. * @param scene defines the hosting scene
  67399. * @returns a new MultiMaterial
  67400. */
  67401. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67402. }
  67403. }
  67404. declare module BABYLON {
  67405. /**
  67406. * Class used to represent data loading progression
  67407. */
  67408. export class SceneLoaderFlags {
  67409. private static _ForceFullSceneLoadingForIncremental;
  67410. private static _ShowLoadingScreen;
  67411. private static _CleanBoneMatrixWeights;
  67412. private static _loggingLevel;
  67413. /**
  67414. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67415. */
  67416. static ForceFullSceneLoadingForIncremental: boolean;
  67417. /**
  67418. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67419. */
  67420. static ShowLoadingScreen: boolean;
  67421. /**
  67422. * Defines the current logging level (while loading the scene)
  67423. * @ignorenaming
  67424. */
  67425. static loggingLevel: number;
  67426. /**
  67427. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67428. */
  67429. static CleanBoneMatrixWeights: boolean;
  67430. }
  67431. }
  67432. declare module BABYLON {
  67433. /**
  67434. * 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.
  67435. * @see https://doc.babylonjs.com/how_to/transformnode
  67436. */
  67437. export class TransformNode extends Node {
  67438. /**
  67439. * Object will not rotate to face the camera
  67440. */
  67441. static BILLBOARDMODE_NONE: number;
  67442. /**
  67443. * Object will rotate to face the camera but only on the x axis
  67444. */
  67445. static BILLBOARDMODE_X: number;
  67446. /**
  67447. * Object will rotate to face the camera but only on the y axis
  67448. */
  67449. static BILLBOARDMODE_Y: number;
  67450. /**
  67451. * Object will rotate to face the camera but only on the z axis
  67452. */
  67453. static BILLBOARDMODE_Z: number;
  67454. /**
  67455. * Object will rotate to face the camera
  67456. */
  67457. static BILLBOARDMODE_ALL: number;
  67458. private _forward;
  67459. private _forwardInverted;
  67460. private _up;
  67461. private _right;
  67462. private _rightInverted;
  67463. private _position;
  67464. private _rotation;
  67465. private _rotationQuaternion;
  67466. protected _scaling: Vector3;
  67467. protected _isDirty: boolean;
  67468. private _transformToBoneReferal;
  67469. private _billboardMode;
  67470. /**
  67471. * Gets or sets the billboard mode. Default is 0.
  67472. *
  67473. * | Value | Type | Description |
  67474. * | --- | --- | --- |
  67475. * | 0 | BILLBOARDMODE_NONE | |
  67476. * | 1 | BILLBOARDMODE_X | |
  67477. * | 2 | BILLBOARDMODE_Y | |
  67478. * | 4 | BILLBOARDMODE_Z | |
  67479. * | 7 | BILLBOARDMODE_ALL | |
  67480. *
  67481. */
  67482. billboardMode: number;
  67483. private _preserveParentRotationForBillboard;
  67484. /**
  67485. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67486. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67487. */
  67488. preserveParentRotationForBillboard: boolean;
  67489. /**
  67490. * 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
  67491. */
  67492. scalingDeterminant: number;
  67493. private _infiniteDistance;
  67494. /**
  67495. * Gets or sets the distance of the object to max, often used by skybox
  67496. */
  67497. infiniteDistance: boolean;
  67498. /**
  67499. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67500. * By default the system will update normals to compensate
  67501. */
  67502. ignoreNonUniformScaling: boolean;
  67503. /**
  67504. * 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
  67505. */
  67506. reIntegrateRotationIntoRotationQuaternion: boolean;
  67507. /** @hidden */
  67508. _poseMatrix: Nullable<Matrix>;
  67509. /** @hidden */
  67510. _localMatrix: Matrix;
  67511. private _usePivotMatrix;
  67512. private _absolutePosition;
  67513. private _pivotMatrix;
  67514. private _pivotMatrixInverse;
  67515. protected _postMultiplyPivotMatrix: boolean;
  67516. protected _isWorldMatrixFrozen: boolean;
  67517. /** @hidden */
  67518. _indexInSceneTransformNodesArray: number;
  67519. /**
  67520. * An event triggered after the world matrix is updated
  67521. */
  67522. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67523. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67524. /**
  67525. * Gets a string identifying the name of the class
  67526. * @returns "TransformNode" string
  67527. */
  67528. getClassName(): string;
  67529. /**
  67530. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67531. */
  67532. position: Vector3;
  67533. /**
  67534. * 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)).
  67535. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67536. */
  67537. rotation: Vector3;
  67538. /**
  67539. * 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)).
  67540. */
  67541. scaling: Vector3;
  67542. /**
  67543. * 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).
  67544. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67545. */
  67546. rotationQuaternion: Nullable<Quaternion>;
  67547. /**
  67548. * The forward direction of that transform in world space.
  67549. */
  67550. readonly forward: Vector3;
  67551. /**
  67552. * The up direction of that transform in world space.
  67553. */
  67554. readonly up: Vector3;
  67555. /**
  67556. * The right direction of that transform in world space.
  67557. */
  67558. readonly right: Vector3;
  67559. /**
  67560. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67561. * @param matrix the matrix to copy the pose from
  67562. * @returns this TransformNode.
  67563. */
  67564. updatePoseMatrix(matrix: Matrix): TransformNode;
  67565. /**
  67566. * Returns the mesh Pose matrix.
  67567. * @returns the pose matrix
  67568. */
  67569. getPoseMatrix(): Matrix;
  67570. /** @hidden */
  67571. _isSynchronized(): boolean;
  67572. /** @hidden */
  67573. _initCache(): void;
  67574. /**
  67575. * Flag the transform node as dirty (Forcing it to update everything)
  67576. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67577. * @returns this transform node
  67578. */
  67579. markAsDirty(property: string): TransformNode;
  67580. /**
  67581. * Returns the current mesh absolute position.
  67582. * Returns a Vector3.
  67583. */
  67584. readonly absolutePosition: Vector3;
  67585. /**
  67586. * Sets a new matrix to apply before all other transformation
  67587. * @param matrix defines the transform matrix
  67588. * @returns the current TransformNode
  67589. */
  67590. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67591. /**
  67592. * Sets a new pivot matrix to the current node
  67593. * @param matrix defines the new pivot matrix to use
  67594. * @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
  67595. * @returns the current TransformNode
  67596. */
  67597. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67598. /**
  67599. * Returns the mesh pivot matrix.
  67600. * Default : Identity.
  67601. * @returns the matrix
  67602. */
  67603. getPivotMatrix(): Matrix;
  67604. /**
  67605. * Prevents the World matrix to be computed any longer.
  67606. * @returns the TransformNode.
  67607. */
  67608. freezeWorldMatrix(): TransformNode;
  67609. /**
  67610. * Allows back the World matrix computation.
  67611. * @returns the TransformNode.
  67612. */
  67613. unfreezeWorldMatrix(): this;
  67614. /**
  67615. * True if the World matrix has been frozen.
  67616. */
  67617. readonly isWorldMatrixFrozen: boolean;
  67618. /**
  67619. * Retuns the mesh absolute position in the World.
  67620. * @returns a Vector3.
  67621. */
  67622. getAbsolutePosition(): Vector3;
  67623. /**
  67624. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67625. * @param absolutePosition the absolute position to set
  67626. * @returns the TransformNode.
  67627. */
  67628. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67629. /**
  67630. * Sets the mesh position in its local space.
  67631. * @param vector3 the position to set in localspace
  67632. * @returns the TransformNode.
  67633. */
  67634. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67635. /**
  67636. * Returns the mesh position in the local space from the current World matrix values.
  67637. * @returns a new Vector3.
  67638. */
  67639. getPositionExpressedInLocalSpace(): Vector3;
  67640. /**
  67641. * Translates the mesh along the passed Vector3 in its local space.
  67642. * @param vector3 the distance to translate in localspace
  67643. * @returns the TransformNode.
  67644. */
  67645. locallyTranslate(vector3: Vector3): TransformNode;
  67646. private static _lookAtVectorCache;
  67647. /**
  67648. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67649. * @param targetPoint the position (must be in same space as current mesh) to look at
  67650. * @param yawCor optional yaw (y-axis) correction in radians
  67651. * @param pitchCor optional pitch (x-axis) correction in radians
  67652. * @param rollCor optional roll (z-axis) correction in radians
  67653. * @param space the choosen space of the target
  67654. * @returns the TransformNode.
  67655. */
  67656. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67657. /**
  67658. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67659. * This Vector3 is expressed in the World space.
  67660. * @param localAxis axis to rotate
  67661. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67662. */
  67663. getDirection(localAxis: Vector3): Vector3;
  67664. /**
  67665. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67666. * localAxis is expressed in the mesh local space.
  67667. * result is computed in the Wordl space from the mesh World matrix.
  67668. * @param localAxis axis to rotate
  67669. * @param result the resulting transformnode
  67670. * @returns this TransformNode.
  67671. */
  67672. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67673. /**
  67674. * Sets this transform node rotation to the given local axis.
  67675. * @param localAxis the axis in local space
  67676. * @param yawCor optional yaw (y-axis) correction in radians
  67677. * @param pitchCor optional pitch (x-axis) correction in radians
  67678. * @param rollCor optional roll (z-axis) correction in radians
  67679. * @returns this TransformNode
  67680. */
  67681. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67682. /**
  67683. * Sets a new pivot point to the current node
  67684. * @param point defines the new pivot point to use
  67685. * @param space defines if the point is in world or local space (local by default)
  67686. * @returns the current TransformNode
  67687. */
  67688. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67689. /**
  67690. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67691. * @returns the pivot point
  67692. */
  67693. getPivotPoint(): Vector3;
  67694. /**
  67695. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67696. * @param result the vector3 to store the result
  67697. * @returns this TransformNode.
  67698. */
  67699. getPivotPointToRef(result: Vector3): TransformNode;
  67700. /**
  67701. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67702. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67703. */
  67704. getAbsolutePivotPoint(): Vector3;
  67705. /**
  67706. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67707. * @param result vector3 to store the result
  67708. * @returns this TransformNode.
  67709. */
  67710. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67711. /**
  67712. * Defines the passed node as the parent of the current node.
  67713. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67714. * @see https://doc.babylonjs.com/how_to/parenting
  67715. * @param node the node ot set as the parent
  67716. * @returns this TransformNode.
  67717. */
  67718. setParent(node: Nullable<Node>): TransformNode;
  67719. private _nonUniformScaling;
  67720. /**
  67721. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67722. */
  67723. readonly nonUniformScaling: boolean;
  67724. /** @hidden */
  67725. _updateNonUniformScalingState(value: boolean): boolean;
  67726. /**
  67727. * Attach the current TransformNode to another TransformNode associated with a bone
  67728. * @param bone Bone affecting the TransformNode
  67729. * @param affectedTransformNode TransformNode associated with the bone
  67730. * @returns this object
  67731. */
  67732. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67733. /**
  67734. * Detach the transform node if its associated with a bone
  67735. * @returns this object
  67736. */
  67737. detachFromBone(): TransformNode;
  67738. private static _rotationAxisCache;
  67739. /**
  67740. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67741. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67742. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67743. * The passed axis is also normalized.
  67744. * @param axis the axis to rotate around
  67745. * @param amount the amount to rotate in radians
  67746. * @param space Space to rotate in (Default: local)
  67747. * @returns the TransformNode.
  67748. */
  67749. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67750. /**
  67751. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67752. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67753. * The passed axis is also normalized. .
  67754. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67755. * @param point the point to rotate around
  67756. * @param axis the axis to rotate around
  67757. * @param amount the amount to rotate in radians
  67758. * @returns the TransformNode
  67759. */
  67760. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67761. /**
  67762. * Translates the mesh along the axis vector for the passed distance in the given space.
  67763. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67764. * @param axis the axis to translate in
  67765. * @param distance the distance to translate
  67766. * @param space Space to rotate in (Default: local)
  67767. * @returns the TransformNode.
  67768. */
  67769. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67770. /**
  67771. * Adds a rotation step to the mesh current rotation.
  67772. * x, y, z are Euler angles expressed in radians.
  67773. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67774. * This means this rotation is made in the mesh local space only.
  67775. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67776. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67777. * ```javascript
  67778. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67779. * ```
  67780. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67781. * 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.
  67782. * @param x Rotation to add
  67783. * @param y Rotation to add
  67784. * @param z Rotation to add
  67785. * @returns the TransformNode.
  67786. */
  67787. addRotation(x: number, y: number, z: number): TransformNode;
  67788. /**
  67789. * @hidden
  67790. */
  67791. protected _getEffectiveParent(): Nullable<Node>;
  67792. /**
  67793. * Computes the world matrix of the node
  67794. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67795. * @returns the world matrix
  67796. */
  67797. computeWorldMatrix(force?: boolean): Matrix;
  67798. protected _afterComputeWorldMatrix(): void;
  67799. /**
  67800. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67801. * @param func callback function to add
  67802. *
  67803. * @returns the TransformNode.
  67804. */
  67805. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67806. /**
  67807. * Removes a registered callback function.
  67808. * @param func callback function to remove
  67809. * @returns the TransformNode.
  67810. */
  67811. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67812. /**
  67813. * Gets the position of the current mesh in camera space
  67814. * @param camera defines the camera to use
  67815. * @returns a position
  67816. */
  67817. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67818. /**
  67819. * Returns the distance from the mesh to the active camera
  67820. * @param camera defines the camera to use
  67821. * @returns the distance
  67822. */
  67823. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67824. /**
  67825. * Clone the current transform node
  67826. * @param name Name of the new clone
  67827. * @param newParent New parent for the clone
  67828. * @param doNotCloneChildren Do not clone children hierarchy
  67829. * @returns the new transform node
  67830. */
  67831. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67832. /**
  67833. * Serializes the objects information.
  67834. * @param currentSerializationObject defines the object to serialize in
  67835. * @returns the serialized object
  67836. */
  67837. serialize(currentSerializationObject?: any): any;
  67838. /**
  67839. * Returns a new TransformNode object parsed from the source provided.
  67840. * @param parsedTransformNode is the source.
  67841. * @param scene the scne the object belongs to
  67842. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67843. * @returns a new TransformNode object parsed from the source provided.
  67844. */
  67845. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67846. /**
  67847. * Get all child-transformNodes of this node
  67848. * @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
  67849. * @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
  67850. * @returns an array of TransformNode
  67851. */
  67852. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67853. /**
  67854. * Releases resources associated with this transform node.
  67855. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67856. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67857. */
  67858. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67859. }
  67860. }
  67861. declare module BABYLON {
  67862. /**
  67863. * Class used to override all child animations of a given target
  67864. */
  67865. export class AnimationPropertiesOverride {
  67866. /**
  67867. * Gets or sets a value indicating if animation blending must be used
  67868. */
  67869. enableBlending: boolean;
  67870. /**
  67871. * Gets or sets the blending speed to use when enableBlending is true
  67872. */
  67873. blendingSpeed: number;
  67874. /**
  67875. * Gets or sets the default loop mode to use
  67876. */
  67877. loopMode: number;
  67878. }
  67879. }
  67880. declare module BABYLON {
  67881. /**
  67882. * Class used to store bone information
  67883. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67884. */
  67885. export class Bone extends Node {
  67886. /**
  67887. * defines the bone name
  67888. */
  67889. name: string;
  67890. private static _tmpVecs;
  67891. private static _tmpQuat;
  67892. private static _tmpMats;
  67893. /**
  67894. * Gets the list of child bones
  67895. */
  67896. children: Bone[];
  67897. /** Gets the animations associated with this bone */
  67898. animations: Animation[];
  67899. /**
  67900. * Gets or sets bone length
  67901. */
  67902. length: number;
  67903. /**
  67904. * @hidden Internal only
  67905. * Set this value to map this bone to a different index in the transform matrices
  67906. * Set this value to -1 to exclude the bone from the transform matrices
  67907. */
  67908. _index: Nullable<number>;
  67909. private _skeleton;
  67910. private _localMatrix;
  67911. private _restPose;
  67912. private _baseMatrix;
  67913. private _absoluteTransform;
  67914. private _invertedAbsoluteTransform;
  67915. private _parent;
  67916. private _scalingDeterminant;
  67917. private _worldTransform;
  67918. private _localScaling;
  67919. private _localRotation;
  67920. private _localPosition;
  67921. private _needToDecompose;
  67922. private _needToCompose;
  67923. /** @hidden */
  67924. _linkedTransformNode: Nullable<TransformNode>;
  67925. /** @hidden */
  67926. _waitingTransformNodeId: Nullable<string>;
  67927. /** @hidden */
  67928. /** @hidden */
  67929. _matrix: Matrix;
  67930. /**
  67931. * Create a new bone
  67932. * @param name defines the bone name
  67933. * @param skeleton defines the parent skeleton
  67934. * @param parentBone defines the parent (can be null if the bone is the root)
  67935. * @param localMatrix defines the local matrix
  67936. * @param restPose defines the rest pose matrix
  67937. * @param baseMatrix defines the base matrix
  67938. * @param index defines index of the bone in the hiearchy
  67939. */
  67940. constructor(
  67941. /**
  67942. * defines the bone name
  67943. */
  67944. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67945. /**
  67946. * Gets the current object class name.
  67947. * @return the class name
  67948. */
  67949. getClassName(): string;
  67950. /**
  67951. * Gets the parent skeleton
  67952. * @returns a skeleton
  67953. */
  67954. getSkeleton(): Skeleton;
  67955. /**
  67956. * Gets parent bone
  67957. * @returns a bone or null if the bone is the root of the bone hierarchy
  67958. */
  67959. getParent(): Nullable<Bone>;
  67960. /**
  67961. * Returns an array containing the root bones
  67962. * @returns an array containing the root bones
  67963. */
  67964. getChildren(): Array<Bone>;
  67965. /**
  67966. * Sets the parent bone
  67967. * @param parent defines the parent (can be null if the bone is the root)
  67968. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67969. */
  67970. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67971. /**
  67972. * Gets the local matrix
  67973. * @returns a matrix
  67974. */
  67975. getLocalMatrix(): Matrix;
  67976. /**
  67977. * Gets the base matrix (initial matrix which remains unchanged)
  67978. * @returns a matrix
  67979. */
  67980. getBaseMatrix(): Matrix;
  67981. /**
  67982. * Gets the rest pose matrix
  67983. * @returns a matrix
  67984. */
  67985. getRestPose(): Matrix;
  67986. /**
  67987. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67988. */
  67989. getWorldMatrix(): Matrix;
  67990. /**
  67991. * Sets the local matrix to rest pose matrix
  67992. */
  67993. returnToRest(): void;
  67994. /**
  67995. * Gets the inverse of the absolute transform matrix.
  67996. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67997. * @returns a matrix
  67998. */
  67999. getInvertedAbsoluteTransform(): Matrix;
  68000. /**
  68001. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  68002. * @returns a matrix
  68003. */
  68004. getAbsoluteTransform(): Matrix;
  68005. /**
  68006. * Links with the given transform node.
  68007. * The local matrix of this bone is copied from the transform node every frame.
  68008. * @param transformNode defines the transform node to link to
  68009. */
  68010. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  68011. /** Gets or sets current position (in local space) */
  68012. position: Vector3;
  68013. /** Gets or sets current rotation (in local space) */
  68014. rotation: Vector3;
  68015. /** Gets or sets current rotation quaternion (in local space) */
  68016. rotationQuaternion: Quaternion;
  68017. /** Gets or sets current scaling (in local space) */
  68018. scaling: Vector3;
  68019. /**
  68020. * Gets the animation properties override
  68021. */
  68022. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  68023. private _decompose;
  68024. private _compose;
  68025. /**
  68026. * Update the base and local matrices
  68027. * @param matrix defines the new base or local matrix
  68028. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68029. * @param updateLocalMatrix defines if the local matrix should be updated
  68030. */
  68031. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  68032. /** @hidden */
  68033. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  68034. /**
  68035. * Flag the bone as dirty (Forcing it to update everything)
  68036. */
  68037. markAsDirty(): void;
  68038. private _markAsDirtyAndCompose;
  68039. private _markAsDirtyAndDecompose;
  68040. /**
  68041. * Translate the bone in local or world space
  68042. * @param vec The amount to translate the bone
  68043. * @param space The space that the translation is in
  68044. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68045. */
  68046. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68047. /**
  68048. * Set the postion of the bone in local or world space
  68049. * @param position The position to set the bone
  68050. * @param space The space that the position is in
  68051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68052. */
  68053. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68054. /**
  68055. * Set the absolute position of the bone (world space)
  68056. * @param position The position to set the bone
  68057. * @param mesh The mesh that this bone is attached to
  68058. */
  68059. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  68060. /**
  68061. * Scale the bone on the x, y and z axes (in local space)
  68062. * @param x The amount to scale the bone on the x axis
  68063. * @param y The amount to scale the bone on the y axis
  68064. * @param z The amount to scale the bone on the z axis
  68065. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  68066. */
  68067. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  68068. /**
  68069. * Set the bone scaling in local space
  68070. * @param scale defines the scaling vector
  68071. */
  68072. setScale(scale: Vector3): void;
  68073. /**
  68074. * Gets the current scaling in local space
  68075. * @returns the current scaling vector
  68076. */
  68077. getScale(): Vector3;
  68078. /**
  68079. * Gets the current scaling in local space and stores it in a target vector
  68080. * @param result defines the target vector
  68081. */
  68082. getScaleToRef(result: Vector3): void;
  68083. /**
  68084. * Set the yaw, pitch, and roll of the bone in local or world space
  68085. * @param yaw The rotation of the bone on the y axis
  68086. * @param pitch The rotation of the bone on the x axis
  68087. * @param roll The rotation of the bone on the z axis
  68088. * @param space The space that the axes of rotation are in
  68089. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68090. */
  68091. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  68092. /**
  68093. * Add a rotation to the bone on an axis in local or world space
  68094. * @param axis The axis to rotate the bone on
  68095. * @param amount The amount to rotate the bone
  68096. * @param space The space that the axis is in
  68097. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68098. */
  68099. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  68100. /**
  68101. * Set the rotation of the bone to a particular axis angle in local or world space
  68102. * @param axis The axis to rotate the bone on
  68103. * @param angle The angle that the bone should be rotated to
  68104. * @param space The space that the axis is in
  68105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68106. */
  68107. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  68108. /**
  68109. * Set the euler rotation of the bone in local of world space
  68110. * @param rotation The euler rotation that the bone should be set to
  68111. * @param space The space that the rotation is in
  68112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68113. */
  68114. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68115. /**
  68116. * Set the quaternion rotation of the bone in local of world space
  68117. * @param quat The quaternion rotation that the bone should be set to
  68118. * @param space The space that the rotation is in
  68119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68120. */
  68121. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  68122. /**
  68123. * Set the rotation matrix of the bone in local of world space
  68124. * @param rotMat The rotation matrix that the bone should be set to
  68125. * @param space The space that the rotation is in
  68126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68127. */
  68128. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  68129. private _rotateWithMatrix;
  68130. private _getNegativeRotationToRef;
  68131. /**
  68132. * Get the position of the bone in local or world space
  68133. * @param space The space that the returned position is in
  68134. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68135. * @returns The position of the bone
  68136. */
  68137. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68138. /**
  68139. * Copy the position of the bone to a vector3 in local or world space
  68140. * @param space The space that the returned position is in
  68141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68142. * @param result The vector3 to copy the position to
  68143. */
  68144. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  68145. /**
  68146. * Get the absolute position of the bone (world space)
  68147. * @param mesh The mesh that this bone is attached to
  68148. * @returns The absolute position of the bone
  68149. */
  68150. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  68151. /**
  68152. * Copy the absolute position of the bone (world space) to the result param
  68153. * @param mesh The mesh that this bone is attached to
  68154. * @param result The vector3 to copy the absolute position to
  68155. */
  68156. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  68157. /**
  68158. * Compute the absolute transforms of this bone and its children
  68159. */
  68160. computeAbsoluteTransforms(): void;
  68161. /**
  68162. * Get the world direction from an axis that is in the local space of the bone
  68163. * @param localAxis The local direction that is used to compute the world direction
  68164. * @param mesh The mesh that this bone is attached to
  68165. * @returns The world direction
  68166. */
  68167. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68168. /**
  68169. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  68170. * @param localAxis The local direction that is used to compute the world direction
  68171. * @param mesh The mesh that this bone is attached to
  68172. * @param result The vector3 that the world direction will be copied to
  68173. */
  68174. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68175. /**
  68176. * Get the euler rotation of the bone in local or world space
  68177. * @param space The space that the rotation should be in
  68178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68179. * @returns The euler rotation
  68180. */
  68181. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68182. /**
  68183. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  68184. * @param space The space that the rotation should be in
  68185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68186. * @param result The vector3 that the rotation should be copied to
  68187. */
  68188. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68189. /**
  68190. * Get the quaternion rotation of the bone in either local or world space
  68191. * @param space The space that the rotation should be in
  68192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68193. * @returns The quaternion rotation
  68194. */
  68195. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  68196. /**
  68197. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  68198. * @param space The space that the rotation should be in
  68199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68200. * @param result The quaternion that the rotation should be copied to
  68201. */
  68202. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  68203. /**
  68204. * Get the rotation matrix of the bone in local or world space
  68205. * @param space The space that the rotation should be in
  68206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68207. * @returns The rotation matrix
  68208. */
  68209. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  68210. /**
  68211. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  68212. * @param space The space that the rotation should be in
  68213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68214. * @param result The quaternion that the rotation should be copied to
  68215. */
  68216. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  68217. /**
  68218. * Get the world position of a point that is in the local space of the bone
  68219. * @param position The local position
  68220. * @param mesh The mesh that this bone is attached to
  68221. * @returns The world position
  68222. */
  68223. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68224. /**
  68225. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  68226. * @param position The local position
  68227. * @param mesh The mesh that this bone is attached to
  68228. * @param result The vector3 that the world position should be copied to
  68229. */
  68230. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68231. /**
  68232. * Get the local position of a point that is in world space
  68233. * @param position The world position
  68234. * @param mesh The mesh that this bone is attached to
  68235. * @returns The local position
  68236. */
  68237. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68238. /**
  68239. * Get the local position of a point that is in world space and copy it to the result param
  68240. * @param position The world position
  68241. * @param mesh The mesh that this bone is attached to
  68242. * @param result The vector3 that the local position should be copied to
  68243. */
  68244. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68245. }
  68246. }
  68247. declare module BABYLON {
  68248. /**
  68249. * Enum that determines the text-wrapping mode to use.
  68250. */
  68251. export enum InspectableType {
  68252. /**
  68253. * Checkbox for booleans
  68254. */
  68255. Checkbox = 0,
  68256. /**
  68257. * Sliders for numbers
  68258. */
  68259. Slider = 1,
  68260. /**
  68261. * Vector3
  68262. */
  68263. Vector3 = 2,
  68264. /**
  68265. * Quaternions
  68266. */
  68267. Quaternion = 3,
  68268. /**
  68269. * Color3
  68270. */
  68271. Color3 = 4
  68272. }
  68273. /**
  68274. * Interface used to define custom inspectable properties.
  68275. * This interface is used by the inspector to display custom property grids
  68276. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68277. */
  68278. export interface IInspectable {
  68279. /**
  68280. * Gets the label to display
  68281. */
  68282. label: string;
  68283. /**
  68284. * Gets the name of the property to edit
  68285. */
  68286. propertyName: string;
  68287. /**
  68288. * Gets the type of the editor to use
  68289. */
  68290. type: InspectableType;
  68291. /**
  68292. * Gets the minimum value of the property when using in "slider" mode
  68293. */
  68294. min?: number;
  68295. /**
  68296. * Gets the maximum value of the property when using in "slider" mode
  68297. */
  68298. max?: number;
  68299. /**
  68300. * Gets the setp to use when using in "slider" mode
  68301. */
  68302. step?: number;
  68303. }
  68304. }
  68305. declare module BABYLON {
  68306. /**
  68307. * This represents the required contract to create a new type of texture loader.
  68308. */
  68309. export interface IInternalTextureLoader {
  68310. /**
  68311. * Defines wether the loader supports cascade loading the different faces.
  68312. */
  68313. supportCascades: boolean;
  68314. /**
  68315. * This returns if the loader support the current file information.
  68316. * @param extension defines the file extension of the file being loaded
  68317. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68318. * @param fallback defines the fallback internal texture if any
  68319. * @param isBase64 defines whether the texture is encoded as a base64
  68320. * @param isBuffer defines whether the texture data are stored as a buffer
  68321. * @returns true if the loader can load the specified file
  68322. */
  68323. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68324. /**
  68325. * Transform the url before loading if required.
  68326. * @param rootUrl the url of the texture
  68327. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68328. * @returns the transformed texture
  68329. */
  68330. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68331. /**
  68332. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68333. * @param rootUrl the url of the texture
  68334. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68335. * @returns the fallback texture
  68336. */
  68337. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68338. /**
  68339. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68340. * @param data contains the texture data
  68341. * @param texture defines the BabylonJS internal texture
  68342. * @param createPolynomials will be true if polynomials have been requested
  68343. * @param onLoad defines the callback to trigger once the texture is ready
  68344. * @param onError defines the callback to trigger in case of error
  68345. */
  68346. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68347. /**
  68348. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68349. * @param data contains the texture data
  68350. * @param texture defines the BabylonJS internal texture
  68351. * @param callback defines the method to call once ready to upload
  68352. */
  68353. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68354. }
  68355. }
  68356. declare module BABYLON {
  68357. interface Engine {
  68358. /**
  68359. * Creates a depth stencil cube texture.
  68360. * This is only available in WebGL 2.
  68361. * @param size The size of face edge in the cube texture.
  68362. * @param options The options defining the cube texture.
  68363. * @returns The cube texture
  68364. */
  68365. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68366. /**
  68367. * Creates a cube texture
  68368. * @param rootUrl defines the url where the files to load is located
  68369. * @param scene defines the current scene
  68370. * @param files defines the list of files to load (1 per face)
  68371. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68372. * @param onLoad defines an optional callback raised when the texture is loaded
  68373. * @param onError defines an optional callback raised if there is an issue to load the texture
  68374. * @param format defines the format of the data
  68375. * @param forcedExtension defines the extension to use to pick the right loader
  68376. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68377. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68378. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68379. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68380. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68381. * @returns the cube texture as an InternalTexture
  68382. */
  68383. 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;
  68384. /**
  68385. * Creates a cube texture
  68386. * @param rootUrl defines the url where the files to load is located
  68387. * @param scene defines the current scene
  68388. * @param files defines the list of files to load (1 per face)
  68389. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68390. * @param onLoad defines an optional callback raised when the texture is loaded
  68391. * @param onError defines an optional callback raised if there is an issue to load the texture
  68392. * @param format defines the format of the data
  68393. * @param forcedExtension defines the extension to use to pick the right loader
  68394. * @returns the cube texture as an InternalTexture
  68395. */
  68396. 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;
  68397. /**
  68398. * Creates a cube texture
  68399. * @param rootUrl defines the url where the files to load is located
  68400. * @param scene defines the current scene
  68401. * @param files defines the list of files to load (1 per face)
  68402. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68403. * @param onLoad defines an optional callback raised when the texture is loaded
  68404. * @param onError defines an optional callback raised if there is an issue to load the texture
  68405. * @param format defines the format of the data
  68406. * @param forcedExtension defines the extension to use to pick the right loader
  68407. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68408. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68409. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68410. * @returns the cube texture as an InternalTexture
  68411. */
  68412. 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;
  68413. /** @hidden */
  68414. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68415. /** @hidden */
  68416. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68417. /** @hidden */
  68418. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68419. /** @hidden */
  68420. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68421. }
  68422. }
  68423. declare module BABYLON {
  68424. /**
  68425. * Class for creating a cube texture
  68426. */
  68427. export class CubeTexture extends BaseTexture {
  68428. private _delayedOnLoad;
  68429. /**
  68430. * The url of the texture
  68431. */
  68432. url: string;
  68433. /**
  68434. * Gets or sets the center of the bounding box associated with the cube texture.
  68435. * It must define where the camera used to render the texture was set
  68436. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68437. */
  68438. boundingBoxPosition: Vector3;
  68439. private _boundingBoxSize;
  68440. /**
  68441. * Gets or sets the size of the bounding box associated with the cube texture
  68442. * When defined, the cubemap will switch to local mode
  68443. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68444. * @example https://www.babylonjs-playground.com/#RNASML
  68445. */
  68446. /**
  68447. * Returns the bounding box size
  68448. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68449. */
  68450. boundingBoxSize: Vector3;
  68451. protected _rotationY: number;
  68452. /**
  68453. * Sets texture matrix rotation angle around Y axis in radians.
  68454. */
  68455. /**
  68456. * Gets texture matrix rotation angle around Y axis radians.
  68457. */
  68458. rotationY: number;
  68459. /**
  68460. * Are mip maps generated for this texture or not.
  68461. */
  68462. readonly noMipmap: boolean;
  68463. private _noMipmap;
  68464. private _files;
  68465. private _extensions;
  68466. private _textureMatrix;
  68467. private _format;
  68468. private _createPolynomials;
  68469. /** @hidden */
  68470. _prefiltered: boolean;
  68471. /**
  68472. * Creates a cube texture from an array of image urls
  68473. * @param files defines an array of image urls
  68474. * @param scene defines the hosting scene
  68475. * @param noMipmap specifies if mip maps are not used
  68476. * @returns a cube texture
  68477. */
  68478. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68479. /**
  68480. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68481. * @param url defines the url of the prefiltered texture
  68482. * @param scene defines the scene the texture is attached to
  68483. * @param forcedExtension defines the extension of the file if different from the url
  68484. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68485. * @return the prefiltered texture
  68486. */
  68487. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68488. /**
  68489. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68490. * as prefiltered data.
  68491. * @param rootUrl defines the url of the texture or the root name of the six images
  68492. * @param scene defines the scene the texture is attached to
  68493. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68494. * @param noMipmap defines if mipmaps should be created or not
  68495. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68496. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68497. * @param onError defines a callback triggered in case of error during load
  68498. * @param format defines the internal format to use for the texture once loaded
  68499. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68500. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68501. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68502. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68503. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68504. * @return the cube texture
  68505. */
  68506. 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);
  68507. /**
  68508. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  68509. */
  68510. readonly isPrefiltered: boolean;
  68511. /**
  68512. * Get the current class name of the texture useful for serialization or dynamic coding.
  68513. * @returns "CubeTexture"
  68514. */
  68515. getClassName(): string;
  68516. /**
  68517. * Update the url (and optional buffer) of this texture if url was null during construction.
  68518. * @param url the url of the texture
  68519. * @param forcedExtension defines the extension to use
  68520. * @param onLoad callback called when the texture is loaded (defaults to null)
  68521. */
  68522. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68523. /**
  68524. * Delays loading of the cube texture
  68525. * @param forcedExtension defines the extension to use
  68526. */
  68527. delayLoad(forcedExtension?: string): void;
  68528. /**
  68529. * Returns the reflection texture matrix
  68530. * @returns the reflection texture matrix
  68531. */
  68532. getReflectionTextureMatrix(): Matrix;
  68533. /**
  68534. * Sets the reflection texture matrix
  68535. * @param value Reflection texture matrix
  68536. */
  68537. setReflectionTextureMatrix(value: Matrix): void;
  68538. /**
  68539. * Parses text to create a cube texture
  68540. * @param parsedTexture define the serialized text to read from
  68541. * @param scene defines the hosting scene
  68542. * @param rootUrl defines the root url of the cube texture
  68543. * @returns a cube texture
  68544. */
  68545. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68546. /**
  68547. * Makes a clone, or deep copy, of the cube texture
  68548. * @returns a new cube texture
  68549. */
  68550. clone(): CubeTexture;
  68551. }
  68552. }
  68553. declare module BABYLON {
  68554. /** @hidden */
  68555. export var postprocessVertexShader: {
  68556. name: string;
  68557. shader: string;
  68558. };
  68559. }
  68560. declare module BABYLON {
  68561. /**
  68562. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68563. * This is the base of the follow, arc rotate cameras and Free camera
  68564. * @see http://doc.babylonjs.com/features/cameras
  68565. */
  68566. export class TargetCamera extends Camera {
  68567. private static _RigCamTransformMatrix;
  68568. private static _TargetTransformMatrix;
  68569. private static _TargetFocalPoint;
  68570. /**
  68571. * Define the current direction the camera is moving to
  68572. */
  68573. cameraDirection: Vector3;
  68574. /**
  68575. * Define the current rotation the camera is rotating to
  68576. */
  68577. cameraRotation: Vector2;
  68578. /**
  68579. * When set, the up vector of the camera will be updated by the rotation of the camera
  68580. */
  68581. updateUpVectorFromRotation: boolean;
  68582. private _tmpQuaternion;
  68583. /**
  68584. * Define the current rotation of the camera
  68585. */
  68586. rotation: Vector3;
  68587. /**
  68588. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68589. */
  68590. rotationQuaternion: Quaternion;
  68591. /**
  68592. * Define the current speed of the camera
  68593. */
  68594. speed: number;
  68595. /**
  68596. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68597. * around all axis.
  68598. */
  68599. noRotationConstraint: boolean;
  68600. /**
  68601. * Define the current target of the camera as an object or a position.
  68602. */
  68603. lockedTarget: any;
  68604. /** @hidden */
  68605. _currentTarget: Vector3;
  68606. /** @hidden */
  68607. _initialFocalDistance: number;
  68608. /** @hidden */
  68609. _viewMatrix: Matrix;
  68610. /** @hidden */
  68611. _camMatrix: Matrix;
  68612. /** @hidden */
  68613. _cameraTransformMatrix: Matrix;
  68614. /** @hidden */
  68615. _cameraRotationMatrix: Matrix;
  68616. /** @hidden */
  68617. _referencePoint: Vector3;
  68618. /** @hidden */
  68619. _transformedReferencePoint: Vector3;
  68620. protected _globalCurrentTarget: Vector3;
  68621. protected _globalCurrentUpVector: Vector3;
  68622. /** @hidden */
  68623. _reset: () => void;
  68624. private _defaultUp;
  68625. /**
  68626. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68627. * This is the base of the follow, arc rotate cameras and Free camera
  68628. * @see http://doc.babylonjs.com/features/cameras
  68629. * @param name Defines the name of the camera in the scene
  68630. * @param position Defines the start position of the camera in the scene
  68631. * @param scene Defines the scene the camera belongs to
  68632. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68633. */
  68634. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68635. /**
  68636. * Gets the position in front of the camera at a given distance.
  68637. * @param distance The distance from the camera we want the position to be
  68638. * @returns the position
  68639. */
  68640. getFrontPosition(distance: number): Vector3;
  68641. /** @hidden */
  68642. _getLockedTargetPosition(): Nullable<Vector3>;
  68643. private _storedPosition;
  68644. private _storedRotation;
  68645. private _storedRotationQuaternion;
  68646. /**
  68647. * Store current camera state of the camera (fov, position, rotation, etc..)
  68648. * @returns the camera
  68649. */
  68650. storeState(): Camera;
  68651. /**
  68652. * Restored camera state. You must call storeState() first
  68653. * @returns whether it was successful or not
  68654. * @hidden
  68655. */
  68656. _restoreStateValues(): boolean;
  68657. /** @hidden */
  68658. _initCache(): void;
  68659. /** @hidden */
  68660. _updateCache(ignoreParentClass?: boolean): void;
  68661. /** @hidden */
  68662. _isSynchronizedViewMatrix(): boolean;
  68663. /** @hidden */
  68664. _computeLocalCameraSpeed(): number;
  68665. /**
  68666. * Defines the target the camera should look at.
  68667. * This will automatically adapt alpha beta and radius to fit within the new target.
  68668. * @param target Defines the new target as a Vector or a mesh
  68669. */
  68670. setTarget(target: Vector3): void;
  68671. /**
  68672. * Return the current target position of the camera. This value is expressed in local space.
  68673. * @returns the target position
  68674. */
  68675. getTarget(): Vector3;
  68676. /** @hidden */
  68677. _decideIfNeedsToMove(): boolean;
  68678. /** @hidden */
  68679. _updatePosition(): void;
  68680. /** @hidden */
  68681. _checkInputs(): void;
  68682. protected _updateCameraRotationMatrix(): void;
  68683. /**
  68684. * 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)
  68685. * @returns the current camera
  68686. */
  68687. private _rotateUpVectorWithCameraRotationMatrix;
  68688. private _cachedRotationZ;
  68689. private _cachedQuaternionRotationZ;
  68690. /** @hidden */
  68691. _getViewMatrix(): Matrix;
  68692. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68693. /**
  68694. * @hidden
  68695. */
  68696. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68697. /**
  68698. * @hidden
  68699. */
  68700. _updateRigCameras(): void;
  68701. private _getRigCamPositionAndTarget;
  68702. /**
  68703. * Gets the current object class name.
  68704. * @return the class name
  68705. */
  68706. getClassName(): string;
  68707. }
  68708. }
  68709. declare module BABYLON {
  68710. /**
  68711. * @ignore
  68712. * This is a list of all the different input types that are available in the application.
  68713. * Fo instance: ArcRotateCameraGamepadInput...
  68714. */
  68715. export var CameraInputTypes: {};
  68716. /**
  68717. * This is the contract to implement in order to create a new input class.
  68718. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68719. */
  68720. export interface ICameraInput<TCamera extends Camera> {
  68721. /**
  68722. * Defines the camera the input is attached to.
  68723. */
  68724. camera: Nullable<TCamera>;
  68725. /**
  68726. * Gets the class name of the current intput.
  68727. * @returns the class name
  68728. */
  68729. getClassName(): string;
  68730. /**
  68731. * Get the friendly name associated with the input class.
  68732. * @returns the input friendly name
  68733. */
  68734. getSimpleName(): string;
  68735. /**
  68736. * Attach the input controls to a specific dom element to get the input from.
  68737. * @param element Defines the element the controls should be listened from
  68738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68739. */
  68740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68741. /**
  68742. * Detach the current controls from the specified dom element.
  68743. * @param element Defines the element to stop listening the inputs from
  68744. */
  68745. detachControl(element: Nullable<HTMLElement>): void;
  68746. /**
  68747. * Update the current camera state depending on the inputs that have been used this frame.
  68748. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68749. */
  68750. checkInputs?: () => void;
  68751. }
  68752. /**
  68753. * Represents a map of input types to input instance or input index to input instance.
  68754. */
  68755. export interface CameraInputsMap<TCamera extends Camera> {
  68756. /**
  68757. * Accessor to the input by input type.
  68758. */
  68759. [name: string]: ICameraInput<TCamera>;
  68760. /**
  68761. * Accessor to the input by input index.
  68762. */
  68763. [idx: number]: ICameraInput<TCamera>;
  68764. }
  68765. /**
  68766. * This represents the input manager used within a camera.
  68767. * It helps dealing with all the different kind of input attached to a camera.
  68768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68769. */
  68770. export class CameraInputsManager<TCamera extends Camera> {
  68771. /**
  68772. * Defines the list of inputs attahed to the camera.
  68773. */
  68774. attached: CameraInputsMap<TCamera>;
  68775. /**
  68776. * Defines the dom element the camera is collecting inputs from.
  68777. * This is null if the controls have not been attached.
  68778. */
  68779. attachedElement: Nullable<HTMLElement>;
  68780. /**
  68781. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68782. */
  68783. noPreventDefault: boolean;
  68784. /**
  68785. * Defined the camera the input manager belongs to.
  68786. */
  68787. camera: TCamera;
  68788. /**
  68789. * Update the current camera state depending on the inputs that have been used this frame.
  68790. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68791. */
  68792. checkInputs: () => void;
  68793. /**
  68794. * Instantiate a new Camera Input Manager.
  68795. * @param camera Defines the camera the input manager blongs to
  68796. */
  68797. constructor(camera: TCamera);
  68798. /**
  68799. * Add an input method to a camera
  68800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68801. * @param input camera input method
  68802. */
  68803. add(input: ICameraInput<TCamera>): void;
  68804. /**
  68805. * Remove a specific input method from a camera
  68806. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68807. * @param inputToRemove camera input method
  68808. */
  68809. remove(inputToRemove: ICameraInput<TCamera>): void;
  68810. /**
  68811. * Remove a specific input type from a camera
  68812. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68813. * @param inputType the type of the input to remove
  68814. */
  68815. removeByType(inputType: string): void;
  68816. private _addCheckInputs;
  68817. /**
  68818. * Attach the input controls to the currently attached dom element to listen the events from.
  68819. * @param input Defines the input to attach
  68820. */
  68821. attachInput(input: ICameraInput<TCamera>): void;
  68822. /**
  68823. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68824. * @param element Defines the dom element to collect the events from
  68825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68826. */
  68827. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68828. /**
  68829. * Detach the current manager inputs controls from a specific dom element.
  68830. * @param element Defines the dom element to collect the events from
  68831. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68832. */
  68833. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68834. /**
  68835. * Rebuild the dynamic inputCheck function from the current list of
  68836. * defined inputs in the manager.
  68837. */
  68838. rebuildInputCheck(): void;
  68839. /**
  68840. * Remove all attached input methods from a camera
  68841. */
  68842. clear(): void;
  68843. /**
  68844. * Serialize the current input manager attached to a camera.
  68845. * This ensures than once parsed,
  68846. * the input associated to the camera will be identical to the current ones
  68847. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68848. */
  68849. serialize(serializedCamera: any): void;
  68850. /**
  68851. * Parses an input manager serialized JSON to restore the previous list of inputs
  68852. * and states associated to a camera.
  68853. * @param parsedCamera Defines the JSON to parse
  68854. */
  68855. parse(parsedCamera: any): void;
  68856. }
  68857. }
  68858. declare module BABYLON {
  68859. /**
  68860. * Gather the list of keyboard event types as constants.
  68861. */
  68862. export class KeyboardEventTypes {
  68863. /**
  68864. * The keydown event is fired when a key becomes active (pressed).
  68865. */
  68866. static readonly KEYDOWN: number;
  68867. /**
  68868. * The keyup event is fired when a key has been released.
  68869. */
  68870. static readonly KEYUP: number;
  68871. }
  68872. /**
  68873. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68874. */
  68875. export class KeyboardInfo {
  68876. /**
  68877. * Defines the type of event (KeyboardEventTypes)
  68878. */
  68879. type: number;
  68880. /**
  68881. * Defines the related dom event
  68882. */
  68883. event: KeyboardEvent;
  68884. /**
  68885. * Instantiates a new keyboard info.
  68886. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68887. * @param type Defines the type of event (KeyboardEventTypes)
  68888. * @param event Defines the related dom event
  68889. */
  68890. constructor(
  68891. /**
  68892. * Defines the type of event (KeyboardEventTypes)
  68893. */
  68894. type: number,
  68895. /**
  68896. * Defines the related dom event
  68897. */
  68898. event: KeyboardEvent);
  68899. }
  68900. /**
  68901. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68902. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68903. */
  68904. export class KeyboardInfoPre extends KeyboardInfo {
  68905. /**
  68906. * Defines the type of event (KeyboardEventTypes)
  68907. */
  68908. type: number;
  68909. /**
  68910. * Defines the related dom event
  68911. */
  68912. event: KeyboardEvent;
  68913. /**
  68914. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68915. */
  68916. skipOnPointerObservable: boolean;
  68917. /**
  68918. * Instantiates a new keyboard pre info.
  68919. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68920. * @param type Defines the type of event (KeyboardEventTypes)
  68921. * @param event Defines the related dom event
  68922. */
  68923. constructor(
  68924. /**
  68925. * Defines the type of event (KeyboardEventTypes)
  68926. */
  68927. type: number,
  68928. /**
  68929. * Defines the related dom event
  68930. */
  68931. event: KeyboardEvent);
  68932. }
  68933. }
  68934. declare module BABYLON {
  68935. /**
  68936. * Manage the keyboard inputs to control the movement of a free camera.
  68937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68938. */
  68939. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68940. /**
  68941. * Defines the camera the input is attached to.
  68942. */
  68943. camera: FreeCamera;
  68944. /**
  68945. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68946. */
  68947. keysUp: number[];
  68948. /**
  68949. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68950. */
  68951. keysDown: number[];
  68952. /**
  68953. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68954. */
  68955. keysLeft: number[];
  68956. /**
  68957. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68958. */
  68959. keysRight: number[];
  68960. private _keys;
  68961. private _onCanvasBlurObserver;
  68962. private _onKeyboardObserver;
  68963. private _engine;
  68964. private _scene;
  68965. /**
  68966. * Attach the input controls to a specific dom element to get the input from.
  68967. * @param element Defines the element the controls should be listened from
  68968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68969. */
  68970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68971. /**
  68972. * Detach the current controls from the specified dom element.
  68973. * @param element Defines the element to stop listening the inputs from
  68974. */
  68975. detachControl(element: Nullable<HTMLElement>): void;
  68976. /**
  68977. * Update the current camera state depending on the inputs that have been used this frame.
  68978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68979. */
  68980. checkInputs(): void;
  68981. /**
  68982. * Gets the class name of the current intput.
  68983. * @returns the class name
  68984. */
  68985. getClassName(): string;
  68986. /** @hidden */
  68987. _onLostFocus(): void;
  68988. /**
  68989. * Get the friendly name associated with the input class.
  68990. * @returns the input friendly name
  68991. */
  68992. getSimpleName(): string;
  68993. }
  68994. }
  68995. declare module BABYLON {
  68996. /**
  68997. * Interface describing all the common properties and methods a shadow light needs to implement.
  68998. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68999. * as well as binding the different shadow properties to the effects.
  69000. */
  69001. export interface IShadowLight extends Light {
  69002. /**
  69003. * The light id in the scene (used in scene.findLighById for instance)
  69004. */
  69005. id: string;
  69006. /**
  69007. * The position the shdow will be casted from.
  69008. */
  69009. position: Vector3;
  69010. /**
  69011. * In 2d mode (needCube being false), the direction used to cast the shadow.
  69012. */
  69013. direction: Vector3;
  69014. /**
  69015. * The transformed position. Position of the light in world space taking parenting in account.
  69016. */
  69017. transformedPosition: Vector3;
  69018. /**
  69019. * The transformed direction. Direction of the light in world space taking parenting in account.
  69020. */
  69021. transformedDirection: Vector3;
  69022. /**
  69023. * The friendly name of the light in the scene.
  69024. */
  69025. name: string;
  69026. /**
  69027. * Defines the shadow projection clipping minimum z value.
  69028. */
  69029. shadowMinZ: number;
  69030. /**
  69031. * Defines the shadow projection clipping maximum z value.
  69032. */
  69033. shadowMaxZ: number;
  69034. /**
  69035. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69036. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69037. */
  69038. computeTransformedInformation(): boolean;
  69039. /**
  69040. * Gets the scene the light belongs to.
  69041. * @returns The scene
  69042. */
  69043. getScene(): Scene;
  69044. /**
  69045. * Callback defining a custom Projection Matrix Builder.
  69046. * This can be used to override the default projection matrix computation.
  69047. */
  69048. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69049. /**
  69050. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69051. * @param matrix The materix to updated with the projection information
  69052. * @param viewMatrix The transform matrix of the light
  69053. * @param renderList The list of mesh to render in the map
  69054. * @returns The current light
  69055. */
  69056. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69057. /**
  69058. * Gets the current depth scale used in ESM.
  69059. * @returns The scale
  69060. */
  69061. getDepthScale(): number;
  69062. /**
  69063. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69064. * @returns true if a cube texture needs to be use
  69065. */
  69066. needCube(): boolean;
  69067. /**
  69068. * Detects if the projection matrix requires to be recomputed this frame.
  69069. * @returns true if it requires to be recomputed otherwise, false.
  69070. */
  69071. needProjectionMatrixCompute(): boolean;
  69072. /**
  69073. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69074. */
  69075. forceProjectionMatrixCompute(): void;
  69076. /**
  69077. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69078. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69079. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69080. */
  69081. getShadowDirection(faceIndex?: number): Vector3;
  69082. /**
  69083. * Gets the minZ used for shadow according to both the scene and the light.
  69084. * @param activeCamera The camera we are returning the min for
  69085. * @returns the depth min z
  69086. */
  69087. getDepthMinZ(activeCamera: Camera): number;
  69088. /**
  69089. * Gets the maxZ used for shadow according to both the scene and the light.
  69090. * @param activeCamera The camera we are returning the max for
  69091. * @returns the depth max z
  69092. */
  69093. getDepthMaxZ(activeCamera: Camera): number;
  69094. }
  69095. /**
  69096. * Base implementation IShadowLight
  69097. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  69098. */
  69099. export abstract class ShadowLight extends Light implements IShadowLight {
  69100. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  69101. protected _position: Vector3;
  69102. protected _setPosition(value: Vector3): void;
  69103. /**
  69104. * Sets the position the shadow will be casted from. Also use as the light position for both
  69105. * point and spot lights.
  69106. */
  69107. /**
  69108. * Sets the position the shadow will be casted from. Also use as the light position for both
  69109. * point and spot lights.
  69110. */
  69111. position: Vector3;
  69112. protected _direction: Vector3;
  69113. protected _setDirection(value: Vector3): void;
  69114. /**
  69115. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  69116. * Also use as the light direction on spot and directional lights.
  69117. */
  69118. /**
  69119. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  69120. * Also use as the light direction on spot and directional lights.
  69121. */
  69122. direction: Vector3;
  69123. private _shadowMinZ;
  69124. /**
  69125. * Gets the shadow projection clipping minimum z value.
  69126. */
  69127. /**
  69128. * Sets the shadow projection clipping minimum z value.
  69129. */
  69130. shadowMinZ: number;
  69131. private _shadowMaxZ;
  69132. /**
  69133. * Sets the shadow projection clipping maximum z value.
  69134. */
  69135. /**
  69136. * Gets the shadow projection clipping maximum z value.
  69137. */
  69138. shadowMaxZ: number;
  69139. /**
  69140. * Callback defining a custom Projection Matrix Builder.
  69141. * This can be used to override the default projection matrix computation.
  69142. */
  69143. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69144. /**
  69145. * The transformed position. Position of the light in world space taking parenting in account.
  69146. */
  69147. transformedPosition: Vector3;
  69148. /**
  69149. * The transformed direction. Direction of the light in world space taking parenting in account.
  69150. */
  69151. transformedDirection: Vector3;
  69152. private _needProjectionMatrixCompute;
  69153. /**
  69154. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69155. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69156. */
  69157. computeTransformedInformation(): boolean;
  69158. /**
  69159. * Return the depth scale used for the shadow map.
  69160. * @returns the depth scale.
  69161. */
  69162. getDepthScale(): number;
  69163. /**
  69164. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69165. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69166. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69167. */
  69168. getShadowDirection(faceIndex?: number): Vector3;
  69169. /**
  69170. * Returns the ShadowLight absolute position in the World.
  69171. * @returns the position vector in world space
  69172. */
  69173. getAbsolutePosition(): Vector3;
  69174. /**
  69175. * Sets the ShadowLight direction toward the passed target.
  69176. * @param target The point to target in local space
  69177. * @returns the updated ShadowLight direction
  69178. */
  69179. setDirectionToTarget(target: Vector3): Vector3;
  69180. /**
  69181. * Returns the light rotation in euler definition.
  69182. * @returns the x y z rotation in local space.
  69183. */
  69184. getRotation(): Vector3;
  69185. /**
  69186. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69187. * @returns true if a cube texture needs to be use
  69188. */
  69189. needCube(): boolean;
  69190. /**
  69191. * Detects if the projection matrix requires to be recomputed this frame.
  69192. * @returns true if it requires to be recomputed otherwise, false.
  69193. */
  69194. needProjectionMatrixCompute(): boolean;
  69195. /**
  69196. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69197. */
  69198. forceProjectionMatrixCompute(): void;
  69199. /** @hidden */
  69200. _initCache(): void;
  69201. /** @hidden */
  69202. _isSynchronized(): boolean;
  69203. /**
  69204. * Computes the world matrix of the node
  69205. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69206. * @returns the world matrix
  69207. */
  69208. computeWorldMatrix(force?: boolean): Matrix;
  69209. /**
  69210. * Gets the minZ used for shadow according to both the scene and the light.
  69211. * @param activeCamera The camera we are returning the min for
  69212. * @returns the depth min z
  69213. */
  69214. getDepthMinZ(activeCamera: Camera): number;
  69215. /**
  69216. * Gets the maxZ used for shadow according to both the scene and the light.
  69217. * @param activeCamera The camera we are returning the max for
  69218. * @returns the depth max z
  69219. */
  69220. getDepthMaxZ(activeCamera: Camera): number;
  69221. /**
  69222. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69223. * @param matrix The materix to updated with the projection information
  69224. * @param viewMatrix The transform matrix of the light
  69225. * @param renderList The list of mesh to render in the map
  69226. * @returns The current light
  69227. */
  69228. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69229. }
  69230. }
  69231. declare module BABYLON {
  69232. /**
  69233. * "Static Class" containing the most commonly used helper while dealing with material for
  69234. * rendering purpose.
  69235. *
  69236. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  69237. *
  69238. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  69239. */
  69240. export class MaterialHelper {
  69241. /**
  69242. * Bind the current view position to an effect.
  69243. * @param effect The effect to be bound
  69244. * @param scene The scene the eyes position is used from
  69245. */
  69246. static BindEyePosition(effect: Effect, scene: Scene): void;
  69247. /**
  69248. * Helps preparing the defines values about the UVs in used in the effect.
  69249. * UVs are shared as much as we can accross channels in the shaders.
  69250. * @param texture The texture we are preparing the UVs for
  69251. * @param defines The defines to update
  69252. * @param key The channel key "diffuse", "specular"... used in the shader
  69253. */
  69254. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  69255. /**
  69256. * Binds a texture matrix value to its corrsponding uniform
  69257. * @param texture The texture to bind the matrix for
  69258. * @param uniformBuffer The uniform buffer receivin the data
  69259. * @param key The channel key "diffuse", "specular"... used in the shader
  69260. */
  69261. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  69262. /**
  69263. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  69264. * @param mesh defines the current mesh
  69265. * @param scene defines the current scene
  69266. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  69267. * @param pointsCloud defines if point cloud rendering has to be turned on
  69268. * @param fogEnabled defines if fog has to be turned on
  69269. * @param alphaTest defines if alpha testing has to be turned on
  69270. * @param defines defines the current list of defines
  69271. */
  69272. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  69273. /**
  69274. * Helper used to prepare the list of defines associated with frame values for shader compilation
  69275. * @param scene defines the current scene
  69276. * @param engine defines the current engine
  69277. * @param defines specifies the list of active defines
  69278. * @param useInstances defines if instances have to be turned on
  69279. * @param useClipPlane defines if clip plane have to be turned on
  69280. */
  69281. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  69282. /**
  69283. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  69284. * @param mesh The mesh containing the geometry data we will draw
  69285. * @param defines The defines to update
  69286. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  69287. * @param useBones Precise whether bones should be used or not (override mesh info)
  69288. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  69289. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  69290. * @returns false if defines are considered not dirty and have not been checked
  69291. */
  69292. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  69293. /**
  69294. * Prepares the defines related to multiview
  69295. * @param scene The scene we are intending to draw
  69296. * @param defines The defines to update
  69297. */
  69298. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  69299. /**
  69300. * Prepares the defines related to the light information passed in parameter
  69301. * @param scene The scene we are intending to draw
  69302. * @param mesh The mesh the effect is compiling for
  69303. * @param defines The defines to update
  69304. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  69305. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  69306. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  69307. * @returns true if normals will be required for the rest of the effect
  69308. */
  69309. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  69310. /**
  69311. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  69312. * that won t be acctive due to defines being turned off.
  69313. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  69314. * @param samplersList The samplers list
  69315. * @param defines The defines helping in the list generation
  69316. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  69317. */
  69318. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  69319. /**
  69320. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  69321. * @param defines The defines to update while falling back
  69322. * @param fallbacks The authorized effect fallbacks
  69323. * @param maxSimultaneousLights The maximum number of lights allowed
  69324. * @param rank the current rank of the Effect
  69325. * @returns The newly affected rank
  69326. */
  69327. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  69328. /**
  69329. * Prepares the list of attributes required for morph targets according to the effect defines.
  69330. * @param attribs The current list of supported attribs
  69331. * @param mesh The mesh to prepare the morph targets attributes for
  69332. * @param defines The current Defines of the effect
  69333. */
  69334. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  69335. /**
  69336. * Prepares the list of attributes required for bones according to the effect defines.
  69337. * @param attribs The current list of supported attribs
  69338. * @param mesh The mesh to prepare the bones attributes for
  69339. * @param defines The current Defines of the effect
  69340. * @param fallbacks The current efffect fallback strategy
  69341. */
  69342. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  69343. /**
  69344. * Prepares the list of attributes required for instances according to the effect defines.
  69345. * @param attribs The current list of supported attribs
  69346. * @param defines The current Defines of the effect
  69347. */
  69348. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69349. /**
  69350. * Binds the light shadow information to the effect for the given mesh.
  69351. * @param light The light containing the generator
  69352. * @param scene The scene the lights belongs to
  69353. * @param mesh The mesh we are binding the information to render
  69354. * @param lightIndex The light index in the effect used to render the mesh
  69355. * @param effect The effect we are binding the data to
  69356. */
  69357. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69358. /**
  69359. * Binds the light information to the effect.
  69360. * @param light The light containing the generator
  69361. * @param effect The effect we are binding the data to
  69362. * @param lightIndex The light index in the effect used to render
  69363. */
  69364. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69365. /**
  69366. * Binds the lights information from the scene to the effect for the given mesh.
  69367. * @param scene The scene the lights belongs to
  69368. * @param mesh The mesh we are binding the information to render
  69369. * @param effect The effect we are binding the data to
  69370. * @param defines The generated defines for the effect
  69371. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69372. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69373. */
  69374. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69375. private static _tempFogColor;
  69376. /**
  69377. * Binds the fog information from the scene to the effect for the given mesh.
  69378. * @param scene The scene the lights belongs to
  69379. * @param mesh The mesh we are binding the information to render
  69380. * @param effect The effect we are binding the data to
  69381. * @param linearSpace Defines if the fog effect is applied in linear space
  69382. */
  69383. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69384. /**
  69385. * Binds the bones information from the mesh to the effect.
  69386. * @param mesh The mesh we are binding the information to render
  69387. * @param effect The effect we are binding the data to
  69388. */
  69389. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69390. /**
  69391. * Binds the morph targets information from the mesh to the effect.
  69392. * @param abstractMesh The mesh we are binding the information to render
  69393. * @param effect The effect we are binding the data to
  69394. */
  69395. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69396. /**
  69397. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69398. * @param defines The generated defines used in the effect
  69399. * @param effect The effect we are binding the data to
  69400. * @param scene The scene we are willing to render with logarithmic scale for
  69401. */
  69402. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69403. /**
  69404. * Binds the clip plane information from the scene to the effect.
  69405. * @param scene The scene the clip plane information are extracted from
  69406. * @param effect The effect we are binding the data to
  69407. */
  69408. static BindClipPlane(effect: Effect, scene: Scene): void;
  69409. }
  69410. }
  69411. declare module BABYLON {
  69412. /** @hidden */
  69413. export var kernelBlurVaryingDeclaration: {
  69414. name: string;
  69415. shader: string;
  69416. };
  69417. }
  69418. declare module BABYLON {
  69419. /** @hidden */
  69420. export var kernelBlurFragment: {
  69421. name: string;
  69422. shader: string;
  69423. };
  69424. }
  69425. declare module BABYLON {
  69426. /** @hidden */
  69427. export var kernelBlurFragment2: {
  69428. name: string;
  69429. shader: string;
  69430. };
  69431. }
  69432. declare module BABYLON {
  69433. /** @hidden */
  69434. export var kernelBlurPixelShader: {
  69435. name: string;
  69436. shader: string;
  69437. };
  69438. }
  69439. declare module BABYLON {
  69440. /** @hidden */
  69441. export var kernelBlurVertex: {
  69442. name: string;
  69443. shader: string;
  69444. };
  69445. }
  69446. declare module BABYLON {
  69447. /** @hidden */
  69448. export var kernelBlurVertexShader: {
  69449. name: string;
  69450. shader: string;
  69451. };
  69452. }
  69453. declare module BABYLON {
  69454. /**
  69455. * The Blur Post Process which blurs an image based on a kernel and direction.
  69456. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69457. */
  69458. export class BlurPostProcess extends PostProcess {
  69459. /** The direction in which to blur the image. */
  69460. direction: Vector2;
  69461. private blockCompilation;
  69462. protected _kernel: number;
  69463. protected _idealKernel: number;
  69464. protected _packedFloat: boolean;
  69465. private _staticDefines;
  69466. /**
  69467. * Sets the length in pixels of the blur sample region
  69468. */
  69469. /**
  69470. * Gets the length in pixels of the blur sample region
  69471. */
  69472. kernel: number;
  69473. /**
  69474. * Sets wether or not the blur needs to unpack/repack floats
  69475. */
  69476. /**
  69477. * Gets wether or not the blur is unpacking/repacking floats
  69478. */
  69479. packedFloat: boolean;
  69480. /**
  69481. * Creates a new instance BlurPostProcess
  69482. * @param name The name of the effect.
  69483. * @param direction The direction in which to blur the image.
  69484. * @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.
  69485. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69486. * @param camera The camera to apply the render pass to.
  69487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69488. * @param engine The engine which the post process will be applied. (default: current engine)
  69489. * @param reusable If the post process can be reused on the same frame. (default: false)
  69490. * @param textureType Type of textures used when performing the post process. (default: 0)
  69491. * @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)
  69492. */
  69493. constructor(name: string,
  69494. /** The direction in which to blur the image. */
  69495. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69496. /**
  69497. * Updates the effect with the current post process compile time values and recompiles the shader.
  69498. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69499. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69500. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69501. * @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
  69502. * @param onCompiled Called when the shader has been compiled.
  69503. * @param onError Called if there is an error when compiling a shader.
  69504. */
  69505. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69506. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69507. /**
  69508. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69509. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69510. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69511. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69512. * The gaps between physical kernels are compensated for in the weighting of the samples
  69513. * @param idealKernel Ideal blur kernel.
  69514. * @return Nearest best kernel.
  69515. */
  69516. protected _nearestBestKernel(idealKernel: number): number;
  69517. /**
  69518. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69519. * @param x The point on the Gaussian distribution to sample.
  69520. * @return the value of the Gaussian function at x.
  69521. */
  69522. protected _gaussianWeight(x: number): number;
  69523. /**
  69524. * Generates a string that can be used as a floating point number in GLSL.
  69525. * @param x Value to print.
  69526. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69527. * @return GLSL float string.
  69528. */
  69529. protected _glslFloat(x: number, decimalFigures?: number): string;
  69530. }
  69531. }
  69532. declare module BABYLON {
  69533. /** @hidden */
  69534. export var shadowMapPixelShader: {
  69535. name: string;
  69536. shader: string;
  69537. };
  69538. }
  69539. declare module BABYLON {
  69540. /** @hidden */
  69541. export var bonesDeclaration: {
  69542. name: string;
  69543. shader: string;
  69544. };
  69545. }
  69546. declare module BABYLON {
  69547. /** @hidden */
  69548. export var morphTargetsVertexGlobalDeclaration: {
  69549. name: string;
  69550. shader: string;
  69551. };
  69552. }
  69553. declare module BABYLON {
  69554. /** @hidden */
  69555. export var morphTargetsVertexDeclaration: {
  69556. name: string;
  69557. shader: string;
  69558. };
  69559. }
  69560. declare module BABYLON {
  69561. /** @hidden */
  69562. export var instancesDeclaration: {
  69563. name: string;
  69564. shader: string;
  69565. };
  69566. }
  69567. declare module BABYLON {
  69568. /** @hidden */
  69569. export var helperFunctions: {
  69570. name: string;
  69571. shader: string;
  69572. };
  69573. }
  69574. declare module BABYLON {
  69575. /** @hidden */
  69576. export var morphTargetsVertex: {
  69577. name: string;
  69578. shader: string;
  69579. };
  69580. }
  69581. declare module BABYLON {
  69582. /** @hidden */
  69583. export var instancesVertex: {
  69584. name: string;
  69585. shader: string;
  69586. };
  69587. }
  69588. declare module BABYLON {
  69589. /** @hidden */
  69590. export var bonesVertex: {
  69591. name: string;
  69592. shader: string;
  69593. };
  69594. }
  69595. declare module BABYLON {
  69596. /** @hidden */
  69597. export var shadowMapVertexShader: {
  69598. name: string;
  69599. shader: string;
  69600. };
  69601. }
  69602. declare module BABYLON {
  69603. /** @hidden */
  69604. export var depthBoxBlurPixelShader: {
  69605. name: string;
  69606. shader: string;
  69607. };
  69608. }
  69609. declare module BABYLON {
  69610. /**
  69611. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69612. */
  69613. export interface ICustomShaderOptions {
  69614. /**
  69615. * Gets or sets the custom shader name to use
  69616. */
  69617. shaderName: string;
  69618. /**
  69619. * The list of attribute names used in the shader
  69620. */
  69621. attributes?: string[];
  69622. /**
  69623. * The list of unifrom names used in the shader
  69624. */
  69625. uniforms?: string[];
  69626. /**
  69627. * The list of sampler names used in the shader
  69628. */
  69629. samplers?: string[];
  69630. /**
  69631. * The list of defines used in the shader
  69632. */
  69633. defines?: string[];
  69634. }
  69635. /**
  69636. * Interface to implement to create a shadow generator compatible with BJS.
  69637. */
  69638. export interface IShadowGenerator {
  69639. /**
  69640. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69641. * @returns The render target texture if present otherwise, null
  69642. */
  69643. getShadowMap(): Nullable<RenderTargetTexture>;
  69644. /**
  69645. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69646. * @returns The render target texture if the shadow map is present otherwise, null
  69647. */
  69648. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69649. /**
  69650. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69651. * @param subMesh The submesh we want to render in the shadow map
  69652. * @param useInstances Defines wether will draw in the map using instances
  69653. * @returns true if ready otherwise, false
  69654. */
  69655. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69656. /**
  69657. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69658. * @param defines Defines of the material we want to update
  69659. * @param lightIndex Index of the light in the enabled light list of the material
  69660. */
  69661. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69662. /**
  69663. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69664. * defined in the generator but impacting the effect).
  69665. * It implies the unifroms available on the materials are the standard BJS ones.
  69666. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69667. * @param effect The effect we are binfing the information for
  69668. */
  69669. bindShadowLight(lightIndex: string, effect: Effect): void;
  69670. /**
  69671. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69672. * (eq to shadow prjection matrix * light transform matrix)
  69673. * @returns The transform matrix used to create the shadow map
  69674. */
  69675. getTransformMatrix(): Matrix;
  69676. /**
  69677. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69678. * Cube and 2D textures for instance.
  69679. */
  69680. recreateShadowMap(): void;
  69681. /**
  69682. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69683. * @param onCompiled Callback triggered at the and of the effects compilation
  69684. * @param options Sets of optional options forcing the compilation with different modes
  69685. */
  69686. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69687. useInstances: boolean;
  69688. }>): void;
  69689. /**
  69690. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69691. * @param options Sets of optional options forcing the compilation with different modes
  69692. * @returns A promise that resolves when the compilation completes
  69693. */
  69694. forceCompilationAsync(options?: Partial<{
  69695. useInstances: boolean;
  69696. }>): Promise<void>;
  69697. /**
  69698. * Serializes the shadow generator setup to a json object.
  69699. * @returns The serialized JSON object
  69700. */
  69701. serialize(): any;
  69702. /**
  69703. * Disposes the Shadow map and related Textures and effects.
  69704. */
  69705. dispose(): void;
  69706. }
  69707. /**
  69708. * Default implementation IShadowGenerator.
  69709. * This is the main object responsible of generating shadows in the framework.
  69710. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69711. */
  69712. export class ShadowGenerator implements IShadowGenerator {
  69713. /**
  69714. * Shadow generator mode None: no filtering applied.
  69715. */
  69716. static readonly FILTER_NONE: number;
  69717. /**
  69718. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69719. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69720. */
  69721. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69722. /**
  69723. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69724. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69725. */
  69726. static readonly FILTER_POISSONSAMPLING: number;
  69727. /**
  69728. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69729. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69730. */
  69731. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69732. /**
  69733. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69734. * edge artifacts on steep falloff.
  69735. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69736. */
  69737. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69738. /**
  69739. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69740. * edge artifacts on steep falloff.
  69741. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69742. */
  69743. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69744. /**
  69745. * Shadow generator mode PCF: Percentage Closer Filtering
  69746. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69747. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69748. */
  69749. static readonly FILTER_PCF: number;
  69750. /**
  69751. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69752. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69753. * Contact Hardening
  69754. */
  69755. static readonly FILTER_PCSS: number;
  69756. /**
  69757. * Reserved for PCF and PCSS
  69758. * Highest Quality.
  69759. *
  69760. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69761. *
  69762. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69763. */
  69764. static readonly QUALITY_HIGH: number;
  69765. /**
  69766. * Reserved for PCF and PCSS
  69767. * Good tradeoff for quality/perf cross devices
  69768. *
  69769. * Execute PCF on a 3*3 kernel.
  69770. *
  69771. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69772. */
  69773. static readonly QUALITY_MEDIUM: number;
  69774. /**
  69775. * Reserved for PCF and PCSS
  69776. * The lowest quality but the fastest.
  69777. *
  69778. * Execute PCF on a 1*1 kernel.
  69779. *
  69780. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69781. */
  69782. static readonly QUALITY_LOW: number;
  69783. /** Gets or sets the custom shader name to use */
  69784. customShaderOptions: ICustomShaderOptions;
  69785. /**
  69786. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69787. */
  69788. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69789. /**
  69790. * Observable triggered before a mesh is rendered in the shadow map.
  69791. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69792. */
  69793. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69794. private _bias;
  69795. /**
  69796. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69797. */
  69798. /**
  69799. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69800. */
  69801. bias: number;
  69802. private _normalBias;
  69803. /**
  69804. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69805. */
  69806. /**
  69807. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69808. */
  69809. normalBias: number;
  69810. private _blurBoxOffset;
  69811. /**
  69812. * Gets the blur box offset: offset applied during the blur pass.
  69813. * Only useful if useKernelBlur = false
  69814. */
  69815. /**
  69816. * Sets the blur box offset: offset applied during the blur pass.
  69817. * Only useful if useKernelBlur = false
  69818. */
  69819. blurBoxOffset: number;
  69820. private _blurScale;
  69821. /**
  69822. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69823. * 2 means half of the size.
  69824. */
  69825. /**
  69826. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69827. * 2 means half of the size.
  69828. */
  69829. blurScale: number;
  69830. private _blurKernel;
  69831. /**
  69832. * Gets the blur kernel: kernel size of the blur pass.
  69833. * Only useful if useKernelBlur = true
  69834. */
  69835. /**
  69836. * Sets the blur kernel: kernel size of the blur pass.
  69837. * Only useful if useKernelBlur = true
  69838. */
  69839. blurKernel: number;
  69840. private _useKernelBlur;
  69841. /**
  69842. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69843. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69844. */
  69845. /**
  69846. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69847. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69848. */
  69849. useKernelBlur: boolean;
  69850. private _depthScale;
  69851. /**
  69852. * Gets the depth scale used in ESM mode.
  69853. */
  69854. /**
  69855. * Sets the depth scale used in ESM mode.
  69856. * This can override the scale stored on the light.
  69857. */
  69858. depthScale: number;
  69859. private _filter;
  69860. /**
  69861. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69862. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69863. */
  69864. /**
  69865. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69866. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69867. */
  69868. filter: number;
  69869. /**
  69870. * Gets if the current filter is set to Poisson Sampling.
  69871. */
  69872. /**
  69873. * Sets the current filter to Poisson Sampling.
  69874. */
  69875. usePoissonSampling: boolean;
  69876. /**
  69877. * Gets if the current filter is set to ESM.
  69878. */
  69879. /**
  69880. * Sets the current filter is to ESM.
  69881. */
  69882. useExponentialShadowMap: boolean;
  69883. /**
  69884. * Gets if the current filter is set to filtered ESM.
  69885. */
  69886. /**
  69887. * Gets if the current filter is set to filtered ESM.
  69888. */
  69889. useBlurExponentialShadowMap: boolean;
  69890. /**
  69891. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69892. * exponential to prevent steep falloff artifacts).
  69893. */
  69894. /**
  69895. * Sets the current filter to "close ESM" (using the inverse of the
  69896. * exponential to prevent steep falloff artifacts).
  69897. */
  69898. useCloseExponentialShadowMap: boolean;
  69899. /**
  69900. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69901. * exponential to prevent steep falloff artifacts).
  69902. */
  69903. /**
  69904. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69905. * exponential to prevent steep falloff artifacts).
  69906. */
  69907. useBlurCloseExponentialShadowMap: boolean;
  69908. /**
  69909. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69910. */
  69911. /**
  69912. * Sets the current filter to "PCF" (percentage closer filtering).
  69913. */
  69914. usePercentageCloserFiltering: boolean;
  69915. private _filteringQuality;
  69916. /**
  69917. * Gets the PCF or PCSS Quality.
  69918. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69919. */
  69920. /**
  69921. * Sets the PCF or PCSS Quality.
  69922. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69923. */
  69924. filteringQuality: number;
  69925. /**
  69926. * Gets if the current filter is set to "PCSS" (contact hardening).
  69927. */
  69928. /**
  69929. * Sets the current filter to "PCSS" (contact hardening).
  69930. */
  69931. useContactHardeningShadow: boolean;
  69932. private _contactHardeningLightSizeUVRatio;
  69933. /**
  69934. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69935. * Using a ratio helps keeping shape stability independently of the map size.
  69936. *
  69937. * It does not account for the light projection as it was having too much
  69938. * instability during the light setup or during light position changes.
  69939. *
  69940. * Only valid if useContactHardeningShadow is true.
  69941. */
  69942. /**
  69943. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69944. * Using a ratio helps keeping shape stability independently of the map size.
  69945. *
  69946. * It does not account for the light projection as it was having too much
  69947. * instability during the light setup or during light position changes.
  69948. *
  69949. * Only valid if useContactHardeningShadow is true.
  69950. */
  69951. contactHardeningLightSizeUVRatio: number;
  69952. private _darkness;
  69953. /**
  69954. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69955. * 0 means strongest and 1 would means no shadow.
  69956. * @returns the darkness.
  69957. */
  69958. getDarkness(): number;
  69959. /**
  69960. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69961. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69962. * @returns the shadow generator allowing fluent coding.
  69963. */
  69964. setDarkness(darkness: number): ShadowGenerator;
  69965. private _transparencyShadow;
  69966. /**
  69967. * Sets the ability to have transparent shadow (boolean).
  69968. * @param transparent True if transparent else False
  69969. * @returns the shadow generator allowing fluent coding
  69970. */
  69971. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69972. private _shadowMap;
  69973. private _shadowMap2;
  69974. /**
  69975. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69976. * @returns The render target texture if present otherwise, null
  69977. */
  69978. getShadowMap(): Nullable<RenderTargetTexture>;
  69979. /**
  69980. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69981. * @returns The render target texture if the shadow map is present otherwise, null
  69982. */
  69983. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69984. /**
  69985. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69986. * @param mesh Mesh to add
  69987. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69988. * @returns the Shadow Generator itself
  69989. */
  69990. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69991. /**
  69992. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69993. * @param mesh Mesh to remove
  69994. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69995. * @returns the Shadow Generator itself
  69996. */
  69997. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69998. /**
  69999. * Controls the extent to which the shadows fade out at the edge of the frustum
  70000. * Used only by directionals and spots
  70001. */
  70002. frustumEdgeFalloff: number;
  70003. private _light;
  70004. /**
  70005. * Returns the associated light object.
  70006. * @returns the light generating the shadow
  70007. */
  70008. getLight(): IShadowLight;
  70009. /**
  70010. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  70011. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  70012. * It might on the other hand introduce peter panning.
  70013. */
  70014. forceBackFacesOnly: boolean;
  70015. private _scene;
  70016. private _lightDirection;
  70017. private _effect;
  70018. private _viewMatrix;
  70019. private _projectionMatrix;
  70020. private _transformMatrix;
  70021. private _cachedPosition;
  70022. private _cachedDirection;
  70023. private _cachedDefines;
  70024. private _currentRenderID;
  70025. private _boxBlurPostprocess;
  70026. private _kernelBlurXPostprocess;
  70027. private _kernelBlurYPostprocess;
  70028. private _blurPostProcesses;
  70029. private _mapSize;
  70030. private _currentFaceIndex;
  70031. private _currentFaceIndexCache;
  70032. private _textureType;
  70033. private _defaultTextureMatrix;
  70034. /** @hidden */
  70035. static _SceneComponentInitialization: (scene: Scene) => void;
  70036. /**
  70037. * Creates a ShadowGenerator object.
  70038. * A ShadowGenerator is the required tool to use the shadows.
  70039. * Each light casting shadows needs to use its own ShadowGenerator.
  70040. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  70041. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  70042. * @param light The light object generating the shadows.
  70043. * @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.
  70044. */
  70045. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  70046. private _initializeGenerator;
  70047. private _initializeShadowMap;
  70048. private _initializeBlurRTTAndPostProcesses;
  70049. private _renderForShadowMap;
  70050. private _renderSubMeshForShadowMap;
  70051. private _applyFilterValues;
  70052. /**
  70053. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70054. * @param onCompiled Callback triggered at the and of the effects compilation
  70055. * @param options Sets of optional options forcing the compilation with different modes
  70056. */
  70057. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  70058. useInstances: boolean;
  70059. }>): void;
  70060. /**
  70061. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70062. * @param options Sets of optional options forcing the compilation with different modes
  70063. * @returns A promise that resolves when the compilation completes
  70064. */
  70065. forceCompilationAsync(options?: Partial<{
  70066. useInstances: boolean;
  70067. }>): Promise<void>;
  70068. /**
  70069. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  70070. * @param subMesh The submesh we want to render in the shadow map
  70071. * @param useInstances Defines wether will draw in the map using instances
  70072. * @returns true if ready otherwise, false
  70073. */
  70074. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70075. /**
  70076. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  70077. * @param defines Defines of the material we want to update
  70078. * @param lightIndex Index of the light in the enabled light list of the material
  70079. */
  70080. prepareDefines(defines: any, lightIndex: number): void;
  70081. /**
  70082. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  70083. * defined in the generator but impacting the effect).
  70084. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  70085. * @param effect The effect we are binfing the information for
  70086. */
  70087. bindShadowLight(lightIndex: string, effect: Effect): void;
  70088. /**
  70089. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  70090. * (eq to shadow prjection matrix * light transform matrix)
  70091. * @returns The transform matrix used to create the shadow map
  70092. */
  70093. getTransformMatrix(): Matrix;
  70094. /**
  70095. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  70096. * Cube and 2D textures for instance.
  70097. */
  70098. recreateShadowMap(): void;
  70099. private _disposeBlurPostProcesses;
  70100. private _disposeRTTandPostProcesses;
  70101. /**
  70102. * Disposes the ShadowGenerator.
  70103. * Returns nothing.
  70104. */
  70105. dispose(): void;
  70106. /**
  70107. * Serializes the shadow generator setup to a json object.
  70108. * @returns The serialized JSON object
  70109. */
  70110. serialize(): any;
  70111. /**
  70112. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  70113. * @param parsedShadowGenerator The JSON object to parse
  70114. * @param scene The scene to create the shadow map for
  70115. * @returns The parsed shadow generator
  70116. */
  70117. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  70118. }
  70119. }
  70120. declare module BABYLON {
  70121. /**
  70122. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  70123. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  70124. * 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.
  70125. */
  70126. export abstract class Light extends Node {
  70127. /**
  70128. * Falloff Default: light is falling off following the material specification:
  70129. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  70130. */
  70131. static readonly FALLOFF_DEFAULT: number;
  70132. /**
  70133. * Falloff Physical: light is falling off following the inverse squared distance law.
  70134. */
  70135. static readonly FALLOFF_PHYSICAL: number;
  70136. /**
  70137. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  70138. * to enhance interoperability with other engines.
  70139. */
  70140. static readonly FALLOFF_GLTF: number;
  70141. /**
  70142. * Falloff Standard: light is falling off like in the standard material
  70143. * to enhance interoperability with other materials.
  70144. */
  70145. static readonly FALLOFF_STANDARD: number;
  70146. /**
  70147. * If every light affecting the material is in this lightmapMode,
  70148. * material.lightmapTexture adds or multiplies
  70149. * (depends on material.useLightmapAsShadowmap)
  70150. * after every other light calculations.
  70151. */
  70152. static readonly LIGHTMAP_DEFAULT: number;
  70153. /**
  70154. * material.lightmapTexture as only diffuse lighting from this light
  70155. * adds only specular lighting from this light
  70156. * adds dynamic shadows
  70157. */
  70158. static readonly LIGHTMAP_SPECULAR: number;
  70159. /**
  70160. * material.lightmapTexture as only lighting
  70161. * no light calculation from this light
  70162. * only adds dynamic shadows from this light
  70163. */
  70164. static readonly LIGHTMAP_SHADOWSONLY: number;
  70165. /**
  70166. * Each light type uses the default quantity according to its type:
  70167. * point/spot lights use luminous intensity
  70168. * directional lights use illuminance
  70169. */
  70170. static readonly INTENSITYMODE_AUTOMATIC: number;
  70171. /**
  70172. * lumen (lm)
  70173. */
  70174. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  70175. /**
  70176. * candela (lm/sr)
  70177. */
  70178. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  70179. /**
  70180. * lux (lm/m^2)
  70181. */
  70182. static readonly INTENSITYMODE_ILLUMINANCE: number;
  70183. /**
  70184. * nit (cd/m^2)
  70185. */
  70186. static readonly INTENSITYMODE_LUMINANCE: number;
  70187. /**
  70188. * Light type const id of the point light.
  70189. */
  70190. static readonly LIGHTTYPEID_POINTLIGHT: number;
  70191. /**
  70192. * Light type const id of the directional light.
  70193. */
  70194. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  70195. /**
  70196. * Light type const id of the spot light.
  70197. */
  70198. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  70199. /**
  70200. * Light type const id of the hemispheric light.
  70201. */
  70202. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  70203. /**
  70204. * Diffuse gives the basic color to an object.
  70205. */
  70206. diffuse: Color3;
  70207. /**
  70208. * Specular produces a highlight color on an object.
  70209. * Note: This is note affecting PBR materials.
  70210. */
  70211. specular: Color3;
  70212. /**
  70213. * Defines the falloff type for this light. This lets overrriding how punctual light are
  70214. * falling off base on range or angle.
  70215. * This can be set to any values in Light.FALLOFF_x.
  70216. *
  70217. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  70218. * other types of materials.
  70219. */
  70220. falloffType: number;
  70221. /**
  70222. * Strength of the light.
  70223. * Note: By default it is define in the framework own unit.
  70224. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  70225. */
  70226. intensity: number;
  70227. private _range;
  70228. protected _inverseSquaredRange: number;
  70229. /**
  70230. * Defines how far from the source the light is impacting in scene units.
  70231. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70232. */
  70233. /**
  70234. * Defines how far from the source the light is impacting in scene units.
  70235. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70236. */
  70237. range: number;
  70238. /**
  70239. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  70240. * of light.
  70241. */
  70242. private _photometricScale;
  70243. private _intensityMode;
  70244. /**
  70245. * Gets the photometric scale used to interpret the intensity.
  70246. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70247. */
  70248. /**
  70249. * Sets the photometric scale used to interpret the intensity.
  70250. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70251. */
  70252. intensityMode: number;
  70253. private _radius;
  70254. /**
  70255. * Gets the light radius used by PBR Materials to simulate soft area lights.
  70256. */
  70257. /**
  70258. * sets the light radius used by PBR Materials to simulate soft area lights.
  70259. */
  70260. radius: number;
  70261. private _renderPriority;
  70262. /**
  70263. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  70264. * exceeding the number allowed of the materials.
  70265. */
  70266. renderPriority: number;
  70267. private _shadowEnabled;
  70268. /**
  70269. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70270. * the current shadow generator.
  70271. */
  70272. /**
  70273. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70274. * the current shadow generator.
  70275. */
  70276. shadowEnabled: boolean;
  70277. private _includedOnlyMeshes;
  70278. /**
  70279. * Gets the only meshes impacted by this light.
  70280. */
  70281. /**
  70282. * Sets the only meshes impacted by this light.
  70283. */
  70284. includedOnlyMeshes: AbstractMesh[];
  70285. private _excludedMeshes;
  70286. /**
  70287. * Gets the meshes not impacted by this light.
  70288. */
  70289. /**
  70290. * Sets the meshes not impacted by this light.
  70291. */
  70292. excludedMeshes: AbstractMesh[];
  70293. private _excludeWithLayerMask;
  70294. /**
  70295. * Gets the layer id use to find what meshes are not impacted by the light.
  70296. * Inactive if 0
  70297. */
  70298. /**
  70299. * Sets the layer id use to find what meshes are not impacted by the light.
  70300. * Inactive if 0
  70301. */
  70302. excludeWithLayerMask: number;
  70303. private _includeOnlyWithLayerMask;
  70304. /**
  70305. * Gets the layer id use to find what meshes are impacted by the light.
  70306. * Inactive if 0
  70307. */
  70308. /**
  70309. * Sets the layer id use to find what meshes are impacted by the light.
  70310. * Inactive if 0
  70311. */
  70312. includeOnlyWithLayerMask: number;
  70313. private _lightmapMode;
  70314. /**
  70315. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70316. */
  70317. /**
  70318. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70319. */
  70320. lightmapMode: number;
  70321. /**
  70322. * Shadow generator associted to the light.
  70323. * @hidden Internal use only.
  70324. */
  70325. _shadowGenerator: Nullable<IShadowGenerator>;
  70326. /**
  70327. * @hidden Internal use only.
  70328. */
  70329. _excludedMeshesIds: string[];
  70330. /**
  70331. * @hidden Internal use only.
  70332. */
  70333. _includedOnlyMeshesIds: string[];
  70334. /**
  70335. * The current light unifom buffer.
  70336. * @hidden Internal use only.
  70337. */
  70338. _uniformBuffer: UniformBuffer;
  70339. /**
  70340. * Creates a Light object in the scene.
  70341. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70342. * @param name The firendly name of the light
  70343. * @param scene The scene the light belongs too
  70344. */
  70345. constructor(name: string, scene: Scene);
  70346. protected abstract _buildUniformLayout(): void;
  70347. /**
  70348. * Sets the passed Effect "effect" with the Light information.
  70349. * @param effect The effect to update
  70350. * @param lightIndex The index of the light in the effect to update
  70351. * @returns The light
  70352. */
  70353. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70354. /**
  70355. * Returns the string "Light".
  70356. * @returns the class name
  70357. */
  70358. getClassName(): string;
  70359. /** @hidden */
  70360. readonly _isLight: boolean;
  70361. /**
  70362. * Converts the light information to a readable string for debug purpose.
  70363. * @param fullDetails Supports for multiple levels of logging within scene loading
  70364. * @returns the human readable light info
  70365. */
  70366. toString(fullDetails?: boolean): string;
  70367. /** @hidden */
  70368. protected _syncParentEnabledState(): void;
  70369. /**
  70370. * Set the enabled state of this node.
  70371. * @param value - the new enabled state
  70372. */
  70373. setEnabled(value: boolean): void;
  70374. /**
  70375. * Returns the Light associated shadow generator if any.
  70376. * @return the associated shadow generator.
  70377. */
  70378. getShadowGenerator(): Nullable<IShadowGenerator>;
  70379. /**
  70380. * Returns a Vector3, the absolute light position in the World.
  70381. * @returns the world space position of the light
  70382. */
  70383. getAbsolutePosition(): Vector3;
  70384. /**
  70385. * Specifies if the light will affect the passed mesh.
  70386. * @param mesh The mesh to test against the light
  70387. * @return true the mesh is affected otherwise, false.
  70388. */
  70389. canAffectMesh(mesh: AbstractMesh): boolean;
  70390. /**
  70391. * Sort function to order lights for rendering.
  70392. * @param a First Light object to compare to second.
  70393. * @param b Second Light object to compare first.
  70394. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70395. */
  70396. static CompareLightsPriority(a: Light, b: Light): number;
  70397. /**
  70398. * Releases resources associated with this node.
  70399. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70400. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70401. */
  70402. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70403. /**
  70404. * Returns the light type ID (integer).
  70405. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70406. */
  70407. getTypeID(): number;
  70408. /**
  70409. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70410. * @returns the scaled intensity in intensity mode unit
  70411. */
  70412. getScaledIntensity(): number;
  70413. /**
  70414. * Returns a new Light object, named "name", from the current one.
  70415. * @param name The name of the cloned light
  70416. * @returns the new created light
  70417. */
  70418. clone(name: string): Nullable<Light>;
  70419. /**
  70420. * Serializes the current light into a Serialization object.
  70421. * @returns the serialized object.
  70422. */
  70423. serialize(): any;
  70424. /**
  70425. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70426. * This new light is named "name" and added to the passed scene.
  70427. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70428. * @param name The friendly name of the light
  70429. * @param scene The scene the new light will belong to
  70430. * @returns the constructor function
  70431. */
  70432. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70433. /**
  70434. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70435. * @param parsedLight The JSON representation of the light
  70436. * @param scene The scene to create the parsed light in
  70437. * @returns the created light after parsing
  70438. */
  70439. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70440. private _hookArrayForExcluded;
  70441. private _hookArrayForIncludedOnly;
  70442. private _resyncMeshes;
  70443. /**
  70444. * Forces the meshes to update their light related information in their rendering used effects
  70445. * @hidden Internal Use Only
  70446. */
  70447. _markMeshesAsLightDirty(): void;
  70448. /**
  70449. * Recomputes the cached photometric scale if needed.
  70450. */
  70451. private _computePhotometricScale;
  70452. /**
  70453. * Returns the Photometric Scale according to the light type and intensity mode.
  70454. */
  70455. private _getPhotometricScale;
  70456. /**
  70457. * Reorder the light in the scene according to their defined priority.
  70458. * @hidden Internal Use Only
  70459. */
  70460. _reorderLightsInScene(): void;
  70461. /**
  70462. * Prepares the list of defines specific to the light type.
  70463. * @param defines the list of defines
  70464. * @param lightIndex defines the index of the light for the effect
  70465. */
  70466. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70467. }
  70468. }
  70469. declare module BABYLON {
  70470. /**
  70471. * Interface used to define Action
  70472. */
  70473. export interface IAction {
  70474. /**
  70475. * Trigger for the action
  70476. */
  70477. trigger: number;
  70478. /** Options of the trigger */
  70479. triggerOptions: any;
  70480. /**
  70481. * Gets the trigger parameters
  70482. * @returns the trigger parameters
  70483. */
  70484. getTriggerParameter(): any;
  70485. /**
  70486. * Internal only - executes current action event
  70487. * @hidden
  70488. */
  70489. _executeCurrent(evt?: ActionEvent): void;
  70490. /**
  70491. * Serialize placeholder for child classes
  70492. * @param parent of child
  70493. * @returns the serialized object
  70494. */
  70495. serialize(parent: any): any;
  70496. /**
  70497. * Internal only
  70498. * @hidden
  70499. */
  70500. _prepare(): void;
  70501. /**
  70502. * Internal only - manager for action
  70503. * @hidden
  70504. */
  70505. _actionManager: AbstractActionManager;
  70506. }
  70507. /**
  70508. * The action to be carried out following a trigger
  70509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70510. */
  70511. export class Action implements IAction {
  70512. /** the trigger, with or without parameters, for the action */
  70513. triggerOptions: any;
  70514. /**
  70515. * Trigger for the action
  70516. */
  70517. trigger: number;
  70518. /**
  70519. * Internal only - manager for action
  70520. * @hidden
  70521. */
  70522. _actionManager: ActionManager;
  70523. private _nextActiveAction;
  70524. private _child;
  70525. private _condition?;
  70526. private _triggerParameter;
  70527. /**
  70528. * An event triggered prior to action being executed.
  70529. */
  70530. onBeforeExecuteObservable: Observable<Action>;
  70531. /**
  70532. * Creates a new Action
  70533. * @param triggerOptions the trigger, with or without parameters, for the action
  70534. * @param condition an optional determinant of action
  70535. */
  70536. constructor(
  70537. /** the trigger, with or without parameters, for the action */
  70538. triggerOptions: any, condition?: Condition);
  70539. /**
  70540. * Internal only
  70541. * @hidden
  70542. */
  70543. _prepare(): void;
  70544. /**
  70545. * Gets the trigger parameters
  70546. * @returns the trigger parameters
  70547. */
  70548. getTriggerParameter(): any;
  70549. /**
  70550. * Internal only - executes current action event
  70551. * @hidden
  70552. */
  70553. _executeCurrent(evt?: ActionEvent): void;
  70554. /**
  70555. * Execute placeholder for child classes
  70556. * @param evt optional action event
  70557. */
  70558. execute(evt?: ActionEvent): void;
  70559. /**
  70560. * Skips to next active action
  70561. */
  70562. skipToNextActiveAction(): void;
  70563. /**
  70564. * Adds action to chain of actions, may be a DoNothingAction
  70565. * @param action defines the next action to execute
  70566. * @returns The action passed in
  70567. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70568. */
  70569. then(action: Action): Action;
  70570. /**
  70571. * Internal only
  70572. * @hidden
  70573. */
  70574. _getProperty(propertyPath: string): string;
  70575. /**
  70576. * Internal only
  70577. * @hidden
  70578. */
  70579. _getEffectiveTarget(target: any, propertyPath: string): any;
  70580. /**
  70581. * Serialize placeholder for child classes
  70582. * @param parent of child
  70583. * @returns the serialized object
  70584. */
  70585. serialize(parent: any): any;
  70586. /**
  70587. * Internal only called by serialize
  70588. * @hidden
  70589. */
  70590. protected _serialize(serializedAction: any, parent?: any): any;
  70591. /**
  70592. * Internal only
  70593. * @hidden
  70594. */
  70595. static _SerializeValueAsString: (value: any) => string;
  70596. /**
  70597. * Internal only
  70598. * @hidden
  70599. */
  70600. static _GetTargetProperty: (target: Scene | Node) => {
  70601. name: string;
  70602. targetType: string;
  70603. value: string;
  70604. };
  70605. }
  70606. }
  70607. declare module BABYLON {
  70608. /**
  70609. * A Condition applied to an Action
  70610. */
  70611. export class Condition {
  70612. /**
  70613. * Internal only - manager for action
  70614. * @hidden
  70615. */
  70616. _actionManager: ActionManager;
  70617. /**
  70618. * Internal only
  70619. * @hidden
  70620. */
  70621. _evaluationId: number;
  70622. /**
  70623. * Internal only
  70624. * @hidden
  70625. */
  70626. _currentResult: boolean;
  70627. /**
  70628. * Creates a new Condition
  70629. * @param actionManager the manager of the action the condition is applied to
  70630. */
  70631. constructor(actionManager: ActionManager);
  70632. /**
  70633. * Check if the current condition is valid
  70634. * @returns a boolean
  70635. */
  70636. isValid(): boolean;
  70637. /**
  70638. * Internal only
  70639. * @hidden
  70640. */
  70641. _getProperty(propertyPath: string): string;
  70642. /**
  70643. * Internal only
  70644. * @hidden
  70645. */
  70646. _getEffectiveTarget(target: any, propertyPath: string): any;
  70647. /**
  70648. * Serialize placeholder for child classes
  70649. * @returns the serialized object
  70650. */
  70651. serialize(): any;
  70652. /**
  70653. * Internal only
  70654. * @hidden
  70655. */
  70656. protected _serialize(serializedCondition: any): any;
  70657. }
  70658. /**
  70659. * Defines specific conditional operators as extensions of Condition
  70660. */
  70661. export class ValueCondition extends Condition {
  70662. /** path to specify the property of the target the conditional operator uses */
  70663. propertyPath: string;
  70664. /** the value compared by the conditional operator against the current value of the property */
  70665. value: any;
  70666. /** the conditional operator, default ValueCondition.IsEqual */
  70667. operator: number;
  70668. /**
  70669. * Internal only
  70670. * @hidden
  70671. */
  70672. private static _IsEqual;
  70673. /**
  70674. * Internal only
  70675. * @hidden
  70676. */
  70677. private static _IsDifferent;
  70678. /**
  70679. * Internal only
  70680. * @hidden
  70681. */
  70682. private static _IsGreater;
  70683. /**
  70684. * Internal only
  70685. * @hidden
  70686. */
  70687. private static _IsLesser;
  70688. /**
  70689. * returns the number for IsEqual
  70690. */
  70691. static readonly IsEqual: number;
  70692. /**
  70693. * Returns the number for IsDifferent
  70694. */
  70695. static readonly IsDifferent: number;
  70696. /**
  70697. * Returns the number for IsGreater
  70698. */
  70699. static readonly IsGreater: number;
  70700. /**
  70701. * Returns the number for IsLesser
  70702. */
  70703. static readonly IsLesser: number;
  70704. /**
  70705. * Internal only The action manager for the condition
  70706. * @hidden
  70707. */
  70708. _actionManager: ActionManager;
  70709. /**
  70710. * Internal only
  70711. * @hidden
  70712. */
  70713. private _target;
  70714. /**
  70715. * Internal only
  70716. * @hidden
  70717. */
  70718. private _effectiveTarget;
  70719. /**
  70720. * Internal only
  70721. * @hidden
  70722. */
  70723. private _property;
  70724. /**
  70725. * Creates a new ValueCondition
  70726. * @param actionManager manager for the action the condition applies to
  70727. * @param target for the action
  70728. * @param propertyPath path to specify the property of the target the conditional operator uses
  70729. * @param value the value compared by the conditional operator against the current value of the property
  70730. * @param operator the conditional operator, default ValueCondition.IsEqual
  70731. */
  70732. constructor(actionManager: ActionManager, target: any,
  70733. /** path to specify the property of the target the conditional operator uses */
  70734. propertyPath: string,
  70735. /** the value compared by the conditional operator against the current value of the property */
  70736. value: any,
  70737. /** the conditional operator, default ValueCondition.IsEqual */
  70738. operator?: number);
  70739. /**
  70740. * Compares the given value with the property value for the specified conditional operator
  70741. * @returns the result of the comparison
  70742. */
  70743. isValid(): boolean;
  70744. /**
  70745. * Serialize the ValueCondition into a JSON compatible object
  70746. * @returns serialization object
  70747. */
  70748. serialize(): any;
  70749. /**
  70750. * Gets the name of the conditional operator for the ValueCondition
  70751. * @param operator the conditional operator
  70752. * @returns the name
  70753. */
  70754. static GetOperatorName(operator: number): string;
  70755. }
  70756. /**
  70757. * Defines a predicate condition as an extension of Condition
  70758. */
  70759. export class PredicateCondition extends Condition {
  70760. /** defines the predicate function used to validate the condition */
  70761. predicate: () => boolean;
  70762. /**
  70763. * Internal only - manager for action
  70764. * @hidden
  70765. */
  70766. _actionManager: ActionManager;
  70767. /**
  70768. * Creates a new PredicateCondition
  70769. * @param actionManager manager for the action the condition applies to
  70770. * @param predicate defines the predicate function used to validate the condition
  70771. */
  70772. constructor(actionManager: ActionManager,
  70773. /** defines the predicate function used to validate the condition */
  70774. predicate: () => boolean);
  70775. /**
  70776. * @returns the validity of the predicate condition
  70777. */
  70778. isValid(): boolean;
  70779. }
  70780. /**
  70781. * Defines a state condition as an extension of Condition
  70782. */
  70783. export class StateCondition extends Condition {
  70784. /** Value to compare with target state */
  70785. value: string;
  70786. /**
  70787. * Internal only - manager for action
  70788. * @hidden
  70789. */
  70790. _actionManager: ActionManager;
  70791. /**
  70792. * Internal only
  70793. * @hidden
  70794. */
  70795. private _target;
  70796. /**
  70797. * Creates a new StateCondition
  70798. * @param actionManager manager for the action the condition applies to
  70799. * @param target of the condition
  70800. * @param value to compare with target state
  70801. */
  70802. constructor(actionManager: ActionManager, target: any,
  70803. /** Value to compare with target state */
  70804. value: string);
  70805. /**
  70806. * Gets a boolean indicating if the current condition is met
  70807. * @returns the validity of the state
  70808. */
  70809. isValid(): boolean;
  70810. /**
  70811. * Serialize the StateCondition into a JSON compatible object
  70812. * @returns serialization object
  70813. */
  70814. serialize(): any;
  70815. }
  70816. }
  70817. declare module BABYLON {
  70818. /**
  70819. * This defines an action responsible to toggle a boolean once triggered.
  70820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70821. */
  70822. export class SwitchBooleanAction extends Action {
  70823. /**
  70824. * The path to the boolean property in the target object
  70825. */
  70826. propertyPath: string;
  70827. private _target;
  70828. private _effectiveTarget;
  70829. private _property;
  70830. /**
  70831. * Instantiate the action
  70832. * @param triggerOptions defines the trigger options
  70833. * @param target defines the object containing the boolean
  70834. * @param propertyPath defines the path to the boolean property in the target object
  70835. * @param condition defines the trigger related conditions
  70836. */
  70837. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70838. /** @hidden */
  70839. _prepare(): void;
  70840. /**
  70841. * Execute the action toggle the boolean value.
  70842. */
  70843. execute(): void;
  70844. /**
  70845. * Serializes the actions and its related information.
  70846. * @param parent defines the object to serialize in
  70847. * @returns the serialized object
  70848. */
  70849. serialize(parent: any): any;
  70850. }
  70851. /**
  70852. * This defines an action responsible to set a the state field of the target
  70853. * to a desired value once triggered.
  70854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70855. */
  70856. export class SetStateAction extends Action {
  70857. /**
  70858. * The value to store in the state field.
  70859. */
  70860. value: string;
  70861. private _target;
  70862. /**
  70863. * Instantiate the action
  70864. * @param triggerOptions defines the trigger options
  70865. * @param target defines the object containing the state property
  70866. * @param value defines the value to store in the state field
  70867. * @param condition defines the trigger related conditions
  70868. */
  70869. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70870. /**
  70871. * Execute the action and store the value on the target state property.
  70872. */
  70873. execute(): void;
  70874. /**
  70875. * Serializes the actions and its related information.
  70876. * @param parent defines the object to serialize in
  70877. * @returns the serialized object
  70878. */
  70879. serialize(parent: any): any;
  70880. }
  70881. /**
  70882. * This defines an action responsible to set a property of the target
  70883. * to a desired value once triggered.
  70884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70885. */
  70886. export class SetValueAction extends Action {
  70887. /**
  70888. * The path of the property to set in the target.
  70889. */
  70890. propertyPath: string;
  70891. /**
  70892. * The value to set in the property
  70893. */
  70894. value: any;
  70895. private _target;
  70896. private _effectiveTarget;
  70897. private _property;
  70898. /**
  70899. * Instantiate the action
  70900. * @param triggerOptions defines the trigger options
  70901. * @param target defines the object containing the property
  70902. * @param propertyPath defines the path of the property to set in the target
  70903. * @param value defines the value to set in the property
  70904. * @param condition defines the trigger related conditions
  70905. */
  70906. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70907. /** @hidden */
  70908. _prepare(): void;
  70909. /**
  70910. * Execute the action and set the targetted property to the desired value.
  70911. */
  70912. execute(): void;
  70913. /**
  70914. * Serializes the actions and its related information.
  70915. * @param parent defines the object to serialize in
  70916. * @returns the serialized object
  70917. */
  70918. serialize(parent: any): any;
  70919. }
  70920. /**
  70921. * This defines an action responsible to increment the target value
  70922. * to a desired value once triggered.
  70923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70924. */
  70925. export class IncrementValueAction extends Action {
  70926. /**
  70927. * The path of the property to increment in the target.
  70928. */
  70929. propertyPath: string;
  70930. /**
  70931. * The value we should increment the property by.
  70932. */
  70933. value: any;
  70934. private _target;
  70935. private _effectiveTarget;
  70936. private _property;
  70937. /**
  70938. * Instantiate the action
  70939. * @param triggerOptions defines the trigger options
  70940. * @param target defines the object containing the property
  70941. * @param propertyPath defines the path of the property to increment in the target
  70942. * @param value defines the value value we should increment the property by
  70943. * @param condition defines the trigger related conditions
  70944. */
  70945. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70946. /** @hidden */
  70947. _prepare(): void;
  70948. /**
  70949. * Execute the action and increment the target of the value amount.
  70950. */
  70951. execute(): void;
  70952. /**
  70953. * Serializes the actions and its related information.
  70954. * @param parent defines the object to serialize in
  70955. * @returns the serialized object
  70956. */
  70957. serialize(parent: any): any;
  70958. }
  70959. /**
  70960. * This defines an action responsible to start an animation once triggered.
  70961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70962. */
  70963. export class PlayAnimationAction extends Action {
  70964. /**
  70965. * Where the animation should start (animation frame)
  70966. */
  70967. from: number;
  70968. /**
  70969. * Where the animation should stop (animation frame)
  70970. */
  70971. to: number;
  70972. /**
  70973. * Define if the animation should loop or stop after the first play.
  70974. */
  70975. loop?: boolean;
  70976. private _target;
  70977. /**
  70978. * Instantiate the action
  70979. * @param triggerOptions defines the trigger options
  70980. * @param target defines the target animation or animation name
  70981. * @param from defines from where the animation should start (animation frame)
  70982. * @param end defines where the animation should stop (animation frame)
  70983. * @param loop defines if the animation should loop or stop after the first play
  70984. * @param condition defines the trigger related conditions
  70985. */
  70986. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70987. /** @hidden */
  70988. _prepare(): void;
  70989. /**
  70990. * Execute the action and play the animation.
  70991. */
  70992. execute(): void;
  70993. /**
  70994. * Serializes the actions and its related information.
  70995. * @param parent defines the object to serialize in
  70996. * @returns the serialized object
  70997. */
  70998. serialize(parent: any): any;
  70999. }
  71000. /**
  71001. * This defines an action responsible to stop an animation once triggered.
  71002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71003. */
  71004. export class StopAnimationAction extends Action {
  71005. private _target;
  71006. /**
  71007. * Instantiate the action
  71008. * @param triggerOptions defines the trigger options
  71009. * @param target defines the target animation or animation name
  71010. * @param condition defines the trigger related conditions
  71011. */
  71012. constructor(triggerOptions: any, target: any, condition?: Condition);
  71013. /** @hidden */
  71014. _prepare(): void;
  71015. /**
  71016. * Execute the action and stop the animation.
  71017. */
  71018. execute(): void;
  71019. /**
  71020. * Serializes the actions and its related information.
  71021. * @param parent defines the object to serialize in
  71022. * @returns the serialized object
  71023. */
  71024. serialize(parent: any): any;
  71025. }
  71026. /**
  71027. * This defines an action responsible that does nothing once triggered.
  71028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71029. */
  71030. export class DoNothingAction extends Action {
  71031. /**
  71032. * Instantiate the action
  71033. * @param triggerOptions defines the trigger options
  71034. * @param condition defines the trigger related conditions
  71035. */
  71036. constructor(triggerOptions?: any, condition?: Condition);
  71037. /**
  71038. * Execute the action and do nothing.
  71039. */
  71040. execute(): void;
  71041. /**
  71042. * Serializes the actions and its related information.
  71043. * @param parent defines the object to serialize in
  71044. * @returns the serialized object
  71045. */
  71046. serialize(parent: any): any;
  71047. }
  71048. /**
  71049. * This defines an action responsible to trigger several actions once triggered.
  71050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71051. */
  71052. export class CombineAction extends Action {
  71053. /**
  71054. * The list of aggregated animations to run.
  71055. */
  71056. children: Action[];
  71057. /**
  71058. * Instantiate the action
  71059. * @param triggerOptions defines the trigger options
  71060. * @param children defines the list of aggregated animations to run
  71061. * @param condition defines the trigger related conditions
  71062. */
  71063. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  71064. /** @hidden */
  71065. _prepare(): void;
  71066. /**
  71067. * Execute the action and executes all the aggregated actions.
  71068. */
  71069. execute(evt: ActionEvent): void;
  71070. /**
  71071. * Serializes the actions and its related information.
  71072. * @param parent defines the object to serialize in
  71073. * @returns the serialized object
  71074. */
  71075. serialize(parent: any): any;
  71076. }
  71077. /**
  71078. * This defines an action responsible to run code (external event) once triggered.
  71079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71080. */
  71081. export class ExecuteCodeAction extends Action {
  71082. /**
  71083. * The callback function to run.
  71084. */
  71085. func: (evt: ActionEvent) => void;
  71086. /**
  71087. * Instantiate the action
  71088. * @param triggerOptions defines the trigger options
  71089. * @param func defines the callback function to run
  71090. * @param condition defines the trigger related conditions
  71091. */
  71092. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  71093. /**
  71094. * Execute the action and run the attached code.
  71095. */
  71096. execute(evt: ActionEvent): void;
  71097. }
  71098. /**
  71099. * This defines an action responsible to set the parent property of the target once triggered.
  71100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71101. */
  71102. export class SetParentAction extends Action {
  71103. private _parent;
  71104. private _target;
  71105. /**
  71106. * Instantiate the action
  71107. * @param triggerOptions defines the trigger options
  71108. * @param target defines the target containing the parent property
  71109. * @param parent defines from where the animation should start (animation frame)
  71110. * @param condition defines the trigger related conditions
  71111. */
  71112. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  71113. /** @hidden */
  71114. _prepare(): void;
  71115. /**
  71116. * Execute the action and set the parent property.
  71117. */
  71118. execute(): void;
  71119. /**
  71120. * Serializes the actions and its related information.
  71121. * @param parent defines the object to serialize in
  71122. * @returns the serialized object
  71123. */
  71124. serialize(parent: any): any;
  71125. }
  71126. }
  71127. declare module BABYLON {
  71128. /**
  71129. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  71130. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  71131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71132. */
  71133. export class ActionManager extends AbstractActionManager {
  71134. /**
  71135. * Nothing
  71136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71137. */
  71138. static readonly NothingTrigger: number;
  71139. /**
  71140. * On pick
  71141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71142. */
  71143. static readonly OnPickTrigger: number;
  71144. /**
  71145. * On left pick
  71146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71147. */
  71148. static readonly OnLeftPickTrigger: number;
  71149. /**
  71150. * On right pick
  71151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71152. */
  71153. static readonly OnRightPickTrigger: number;
  71154. /**
  71155. * On center pick
  71156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71157. */
  71158. static readonly OnCenterPickTrigger: number;
  71159. /**
  71160. * On pick down
  71161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71162. */
  71163. static readonly OnPickDownTrigger: number;
  71164. /**
  71165. * On double pick
  71166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71167. */
  71168. static readonly OnDoublePickTrigger: number;
  71169. /**
  71170. * On pick up
  71171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71172. */
  71173. static readonly OnPickUpTrigger: number;
  71174. /**
  71175. * On pick out.
  71176. * This trigger will only be raised if you also declared a OnPickDown
  71177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71178. */
  71179. static readonly OnPickOutTrigger: number;
  71180. /**
  71181. * On long press
  71182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71183. */
  71184. static readonly OnLongPressTrigger: number;
  71185. /**
  71186. * On pointer over
  71187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71188. */
  71189. static readonly OnPointerOverTrigger: number;
  71190. /**
  71191. * On pointer out
  71192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71193. */
  71194. static readonly OnPointerOutTrigger: number;
  71195. /**
  71196. * On every frame
  71197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71198. */
  71199. static readonly OnEveryFrameTrigger: number;
  71200. /**
  71201. * On intersection enter
  71202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71203. */
  71204. static readonly OnIntersectionEnterTrigger: number;
  71205. /**
  71206. * On intersection exit
  71207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71208. */
  71209. static readonly OnIntersectionExitTrigger: number;
  71210. /**
  71211. * On key down
  71212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71213. */
  71214. static readonly OnKeyDownTrigger: number;
  71215. /**
  71216. * On key up
  71217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71218. */
  71219. static readonly OnKeyUpTrigger: number;
  71220. private _scene;
  71221. /**
  71222. * Creates a new action manager
  71223. * @param scene defines the hosting scene
  71224. */
  71225. constructor(scene: Scene);
  71226. /**
  71227. * Releases all associated resources
  71228. */
  71229. dispose(): void;
  71230. /**
  71231. * Gets hosting scene
  71232. * @returns the hosting scene
  71233. */
  71234. getScene(): Scene;
  71235. /**
  71236. * Does this action manager handles actions of any of the given triggers
  71237. * @param triggers defines the triggers to be tested
  71238. * @return a boolean indicating whether one (or more) of the triggers is handled
  71239. */
  71240. hasSpecificTriggers(triggers: number[]): boolean;
  71241. /**
  71242. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  71243. * speed.
  71244. * @param triggerA defines the trigger to be tested
  71245. * @param triggerB defines the trigger to be tested
  71246. * @return a boolean indicating whether one (or more) of the triggers is handled
  71247. */
  71248. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  71249. /**
  71250. * Does this action manager handles actions of a given trigger
  71251. * @param trigger defines the trigger to be tested
  71252. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  71253. * @return whether the trigger is handled
  71254. */
  71255. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  71256. /**
  71257. * Does this action manager has pointer triggers
  71258. */
  71259. readonly hasPointerTriggers: boolean;
  71260. /**
  71261. * Does this action manager has pick triggers
  71262. */
  71263. readonly hasPickTriggers: boolean;
  71264. /**
  71265. * Registers an action to this action manager
  71266. * @param action defines the action to be registered
  71267. * @return the action amended (prepared) after registration
  71268. */
  71269. registerAction(action: IAction): Nullable<IAction>;
  71270. /**
  71271. * Unregisters an action to this action manager
  71272. * @param action defines the action to be unregistered
  71273. * @return a boolean indicating whether the action has been unregistered
  71274. */
  71275. unregisterAction(action: IAction): Boolean;
  71276. /**
  71277. * Process a specific trigger
  71278. * @param trigger defines the trigger to process
  71279. * @param evt defines the event details to be processed
  71280. */
  71281. processTrigger(trigger: number, evt?: IActionEvent): void;
  71282. /** @hidden */
  71283. _getEffectiveTarget(target: any, propertyPath: string): any;
  71284. /** @hidden */
  71285. _getProperty(propertyPath: string): string;
  71286. /**
  71287. * Serialize this manager to a JSON object
  71288. * @param name defines the property name to store this manager
  71289. * @returns a JSON representation of this manager
  71290. */
  71291. serialize(name: string): any;
  71292. /**
  71293. * Creates a new ActionManager from a JSON data
  71294. * @param parsedActions defines the JSON data to read from
  71295. * @param object defines the hosting mesh
  71296. * @param scene defines the hosting scene
  71297. */
  71298. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  71299. /**
  71300. * Get a trigger name by index
  71301. * @param trigger defines the trigger index
  71302. * @returns a trigger name
  71303. */
  71304. static GetTriggerName(trigger: number): string;
  71305. }
  71306. }
  71307. declare module BABYLON {
  71308. /**
  71309. * Class representing a ray with position and direction
  71310. */
  71311. export class Ray {
  71312. /** origin point */
  71313. origin: Vector3;
  71314. /** direction */
  71315. direction: Vector3;
  71316. /** length of the ray */
  71317. length: number;
  71318. private static readonly TmpVector3;
  71319. private _tmpRay;
  71320. /**
  71321. * Creates a new ray
  71322. * @param origin origin point
  71323. * @param direction direction
  71324. * @param length length of the ray
  71325. */
  71326. constructor(
  71327. /** origin point */
  71328. origin: Vector3,
  71329. /** direction */
  71330. direction: Vector3,
  71331. /** length of the ray */
  71332. length?: number);
  71333. /**
  71334. * Checks if the ray intersects a box
  71335. * @param minimum bound of the box
  71336. * @param maximum bound of the box
  71337. * @param intersectionTreshold extra extend to be added to the box in all direction
  71338. * @returns if the box was hit
  71339. */
  71340. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  71341. /**
  71342. * Checks if the ray intersects a box
  71343. * @param box the bounding box to check
  71344. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  71345. * @returns if the box was hit
  71346. */
  71347. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  71348. /**
  71349. * If the ray hits a sphere
  71350. * @param sphere the bounding sphere to check
  71351. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71352. * @returns true if it hits the sphere
  71353. */
  71354. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71355. /**
  71356. * If the ray hits a triange
  71357. * @param vertex0 triangle vertex
  71358. * @param vertex1 triangle vertex
  71359. * @param vertex2 triangle vertex
  71360. * @returns intersection information if hit
  71361. */
  71362. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71363. /**
  71364. * Checks if ray intersects a plane
  71365. * @param plane the plane to check
  71366. * @returns the distance away it was hit
  71367. */
  71368. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71369. /**
  71370. * Checks if ray intersects a mesh
  71371. * @param mesh the mesh to check
  71372. * @param fastCheck if only the bounding box should checked
  71373. * @returns picking info of the intersecton
  71374. */
  71375. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71376. /**
  71377. * Checks if ray intersects a mesh
  71378. * @param meshes the meshes to check
  71379. * @param fastCheck if only the bounding box should checked
  71380. * @param results array to store result in
  71381. * @returns Array of picking infos
  71382. */
  71383. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71384. private _comparePickingInfo;
  71385. private static smallnum;
  71386. private static rayl;
  71387. /**
  71388. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71389. * @param sega the first point of the segment to test the intersection against
  71390. * @param segb the second point of the segment to test the intersection against
  71391. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71392. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71393. */
  71394. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71395. /**
  71396. * Update the ray from viewport position
  71397. * @param x position
  71398. * @param y y position
  71399. * @param viewportWidth viewport width
  71400. * @param viewportHeight viewport height
  71401. * @param world world matrix
  71402. * @param view view matrix
  71403. * @param projection projection matrix
  71404. * @returns this ray updated
  71405. */
  71406. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71407. /**
  71408. * Creates a ray with origin and direction of 0,0,0
  71409. * @returns the new ray
  71410. */
  71411. static Zero(): Ray;
  71412. /**
  71413. * Creates a new ray from screen space and viewport
  71414. * @param x position
  71415. * @param y y position
  71416. * @param viewportWidth viewport width
  71417. * @param viewportHeight viewport height
  71418. * @param world world matrix
  71419. * @param view view matrix
  71420. * @param projection projection matrix
  71421. * @returns new ray
  71422. */
  71423. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71424. /**
  71425. * 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
  71426. * transformed to the given world matrix.
  71427. * @param origin The origin point
  71428. * @param end The end point
  71429. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71430. * @returns the new ray
  71431. */
  71432. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71433. /**
  71434. * Transforms a ray by a matrix
  71435. * @param ray ray to transform
  71436. * @param matrix matrix to apply
  71437. * @returns the resulting new ray
  71438. */
  71439. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71440. /**
  71441. * Transforms a ray by a matrix
  71442. * @param ray ray to transform
  71443. * @param matrix matrix to apply
  71444. * @param result ray to store result in
  71445. */
  71446. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71447. /**
  71448. * Unproject a ray from screen space to object space
  71449. * @param sourceX defines the screen space x coordinate to use
  71450. * @param sourceY defines the screen space y coordinate to use
  71451. * @param viewportWidth defines the current width of the viewport
  71452. * @param viewportHeight defines the current height of the viewport
  71453. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71454. * @param view defines the view matrix to use
  71455. * @param projection defines the projection matrix to use
  71456. */
  71457. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71458. }
  71459. /**
  71460. * Type used to define predicate used to select faces when a mesh intersection is detected
  71461. */
  71462. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71463. interface Scene {
  71464. /** @hidden */
  71465. _tempPickingRay: Nullable<Ray>;
  71466. /** @hidden */
  71467. _cachedRayForTransform: Ray;
  71468. /** @hidden */
  71469. _pickWithRayInverseMatrix: Matrix;
  71470. /** @hidden */
  71471. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71472. /** @hidden */
  71473. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71474. }
  71475. }
  71476. declare module BABYLON {
  71477. /**
  71478. * Groups all the scene component constants in one place to ease maintenance.
  71479. * @hidden
  71480. */
  71481. export class SceneComponentConstants {
  71482. static readonly NAME_EFFECTLAYER: string;
  71483. static readonly NAME_LAYER: string;
  71484. static readonly NAME_LENSFLARESYSTEM: string;
  71485. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71486. static readonly NAME_PARTICLESYSTEM: string;
  71487. static readonly NAME_GAMEPAD: string;
  71488. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71489. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71490. static readonly NAME_DEPTHRENDERER: string;
  71491. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71492. static readonly NAME_SPRITE: string;
  71493. static readonly NAME_OUTLINERENDERER: string;
  71494. static readonly NAME_PROCEDURALTEXTURE: string;
  71495. static readonly NAME_SHADOWGENERATOR: string;
  71496. static readonly NAME_OCTREE: string;
  71497. static readonly NAME_PHYSICSENGINE: string;
  71498. static readonly NAME_AUDIO: string;
  71499. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71500. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71501. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71502. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71503. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71504. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71505. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71506. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71507. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71508. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71509. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71510. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71511. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71512. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71513. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71514. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71515. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71516. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71517. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71518. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71519. static readonly STEP_AFTERRENDER_AUDIO: number;
  71520. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71521. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71522. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71523. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71524. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71525. static readonly STEP_POINTERMOVE_SPRITE: number;
  71526. static readonly STEP_POINTERDOWN_SPRITE: number;
  71527. static readonly STEP_POINTERUP_SPRITE: number;
  71528. }
  71529. /**
  71530. * This represents a scene component.
  71531. *
  71532. * This is used to decouple the dependency the scene is having on the different workloads like
  71533. * layers, post processes...
  71534. */
  71535. export interface ISceneComponent {
  71536. /**
  71537. * The name of the component. Each component must have a unique name.
  71538. */
  71539. name: string;
  71540. /**
  71541. * The scene the component belongs to.
  71542. */
  71543. scene: Scene;
  71544. /**
  71545. * Register the component to one instance of a scene.
  71546. */
  71547. register(): void;
  71548. /**
  71549. * Rebuilds the elements related to this component in case of
  71550. * context lost for instance.
  71551. */
  71552. rebuild(): void;
  71553. /**
  71554. * Disposes the component and the associated ressources.
  71555. */
  71556. dispose(): void;
  71557. }
  71558. /**
  71559. * This represents a SERIALIZABLE scene component.
  71560. *
  71561. * This extends Scene Component to add Serialization methods on top.
  71562. */
  71563. export interface ISceneSerializableComponent extends ISceneComponent {
  71564. /**
  71565. * Adds all the element from the container to the scene
  71566. * @param container the container holding the elements
  71567. */
  71568. addFromContainer(container: AbstractScene): void;
  71569. /**
  71570. * Removes all the elements in the container from the scene
  71571. * @param container contains the elements to remove
  71572. * @param dispose if the removed element should be disposed (default: false)
  71573. */
  71574. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71575. /**
  71576. * Serializes the component data to the specified json object
  71577. * @param serializationObject The object to serialize to
  71578. */
  71579. serialize(serializationObject: any): void;
  71580. }
  71581. /**
  71582. * Strong typing of a Mesh related stage step action
  71583. */
  71584. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71585. /**
  71586. * Strong typing of a Evaluate Sub Mesh related stage step action
  71587. */
  71588. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71589. /**
  71590. * Strong typing of a Active Mesh related stage step action
  71591. */
  71592. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71593. /**
  71594. * Strong typing of a Camera related stage step action
  71595. */
  71596. export type CameraStageAction = (camera: Camera) => void;
  71597. /**
  71598. * Strong typing of a Camera Frame buffer related stage step action
  71599. */
  71600. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71601. /**
  71602. * Strong typing of a Render Target related stage step action
  71603. */
  71604. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71605. /**
  71606. * Strong typing of a RenderingGroup related stage step action
  71607. */
  71608. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71609. /**
  71610. * Strong typing of a Mesh Render related stage step action
  71611. */
  71612. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71613. /**
  71614. * Strong typing of a simple stage step action
  71615. */
  71616. export type SimpleStageAction = () => void;
  71617. /**
  71618. * Strong typing of a render target action.
  71619. */
  71620. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71621. /**
  71622. * Strong typing of a pointer move action.
  71623. */
  71624. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71625. /**
  71626. * Strong typing of a pointer up/down action.
  71627. */
  71628. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71629. /**
  71630. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71631. * @hidden
  71632. */
  71633. export class Stage<T extends Function> extends Array<{
  71634. index: number;
  71635. component: ISceneComponent;
  71636. action: T;
  71637. }> {
  71638. /**
  71639. * Hide ctor from the rest of the world.
  71640. * @param items The items to add.
  71641. */
  71642. private constructor();
  71643. /**
  71644. * Creates a new Stage.
  71645. * @returns A new instance of a Stage
  71646. */
  71647. static Create<T extends Function>(): Stage<T>;
  71648. /**
  71649. * Registers a step in an ordered way in the targeted stage.
  71650. * @param index Defines the position to register the step in
  71651. * @param component Defines the component attached to the step
  71652. * @param action Defines the action to launch during the step
  71653. */
  71654. registerStep(index: number, component: ISceneComponent, action: T): void;
  71655. /**
  71656. * Clears all the steps from the stage.
  71657. */
  71658. clear(): void;
  71659. }
  71660. }
  71661. declare module BABYLON {
  71662. interface Scene {
  71663. /** @hidden */
  71664. _pointerOverSprite: Nullable<Sprite>;
  71665. /** @hidden */
  71666. _pickedDownSprite: Nullable<Sprite>;
  71667. /** @hidden */
  71668. _tempSpritePickingRay: Nullable<Ray>;
  71669. /**
  71670. * All of the sprite managers added to this scene
  71671. * @see http://doc.babylonjs.com/babylon101/sprites
  71672. */
  71673. spriteManagers: Array<ISpriteManager>;
  71674. /**
  71675. * An event triggered when sprites rendering is about to start
  71676. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71677. */
  71678. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71679. /**
  71680. * An event triggered when sprites rendering is done
  71681. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71682. */
  71683. onAfterSpritesRenderingObservable: Observable<Scene>;
  71684. /** @hidden */
  71685. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71686. /** Launch a ray to try to pick a sprite in the scene
  71687. * @param x position on screen
  71688. * @param y position on screen
  71689. * @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
  71690. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71691. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71692. * @returns a PickingInfo
  71693. */
  71694. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71695. /** Use the given ray to pick a sprite in the scene
  71696. * @param ray The ray (in world space) to use to pick meshes
  71697. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  71698. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71699. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71700. * @returns a PickingInfo
  71701. */
  71702. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71703. /**
  71704. * Force the sprite under the pointer
  71705. * @param sprite defines the sprite to use
  71706. */
  71707. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71708. /**
  71709. * Gets the sprite under the pointer
  71710. * @returns a Sprite or null if no sprite is under the pointer
  71711. */
  71712. getPointerOverSprite(): Nullable<Sprite>;
  71713. }
  71714. /**
  71715. * Defines the sprite scene component responsible to manage sprites
  71716. * in a given scene.
  71717. */
  71718. export class SpriteSceneComponent implements ISceneComponent {
  71719. /**
  71720. * The component name helpfull to identify the component in the list of scene components.
  71721. */
  71722. readonly name: string;
  71723. /**
  71724. * The scene the component belongs to.
  71725. */
  71726. scene: Scene;
  71727. /** @hidden */
  71728. private _spritePredicate;
  71729. /**
  71730. * Creates a new instance of the component for the given scene
  71731. * @param scene Defines the scene to register the component in
  71732. */
  71733. constructor(scene: Scene);
  71734. /**
  71735. * Registers the component in a given scene
  71736. */
  71737. register(): void;
  71738. /**
  71739. * Rebuilds the elements related to this component in case of
  71740. * context lost for instance.
  71741. */
  71742. rebuild(): void;
  71743. /**
  71744. * Disposes the component and the associated ressources.
  71745. */
  71746. dispose(): void;
  71747. private _pickSpriteButKeepRay;
  71748. private _pointerMove;
  71749. private _pointerDown;
  71750. private _pointerUp;
  71751. }
  71752. }
  71753. declare module BABYLON {
  71754. /** @hidden */
  71755. export var fogFragmentDeclaration: {
  71756. name: string;
  71757. shader: string;
  71758. };
  71759. }
  71760. declare module BABYLON {
  71761. /** @hidden */
  71762. export var fogFragment: {
  71763. name: string;
  71764. shader: string;
  71765. };
  71766. }
  71767. declare module BABYLON {
  71768. /** @hidden */
  71769. export var spritesPixelShader: {
  71770. name: string;
  71771. shader: string;
  71772. };
  71773. }
  71774. declare module BABYLON {
  71775. /** @hidden */
  71776. export var fogVertexDeclaration: {
  71777. name: string;
  71778. shader: string;
  71779. };
  71780. }
  71781. declare module BABYLON {
  71782. /** @hidden */
  71783. export var spritesVertexShader: {
  71784. name: string;
  71785. shader: string;
  71786. };
  71787. }
  71788. declare module BABYLON {
  71789. /**
  71790. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71791. */
  71792. export interface ISpriteManager extends IDisposable {
  71793. /**
  71794. * Restricts the camera to viewing objects with the same layerMask.
  71795. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71796. */
  71797. layerMask: number;
  71798. /**
  71799. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71800. */
  71801. isPickable: boolean;
  71802. /**
  71803. * Specifies the rendering group id for this mesh (0 by default)
  71804. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71805. */
  71806. renderingGroupId: number;
  71807. /**
  71808. * Defines the list of sprites managed by the manager.
  71809. */
  71810. sprites: Array<Sprite>;
  71811. /**
  71812. * Tests the intersection of a sprite with a specific ray.
  71813. * @param ray The ray we are sending to test the collision
  71814. * @param camera The camera space we are sending rays in
  71815. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71816. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71817. * @returns picking info or null.
  71818. */
  71819. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71820. /**
  71821. * Renders the list of sprites on screen.
  71822. */
  71823. render(): void;
  71824. }
  71825. /**
  71826. * Class used to manage multiple sprites on the same spritesheet
  71827. * @see http://doc.babylonjs.com/babylon101/sprites
  71828. */
  71829. export class SpriteManager implements ISpriteManager {
  71830. /** defines the manager's name */
  71831. name: string;
  71832. /** Gets the list of sprites */
  71833. sprites: Sprite[];
  71834. /** Gets or sets the rendering group id (0 by default) */
  71835. renderingGroupId: number;
  71836. /** Gets or sets camera layer mask */
  71837. layerMask: number;
  71838. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71839. fogEnabled: boolean;
  71840. /** Gets or sets a boolean indicating if the sprites are pickable */
  71841. isPickable: boolean;
  71842. /** Defines the default width of a cell in the spritesheet */
  71843. cellWidth: number;
  71844. /** Defines the default height of a cell in the spritesheet */
  71845. cellHeight: number;
  71846. /**
  71847. * An event triggered when the manager is disposed.
  71848. */
  71849. onDisposeObservable: Observable<SpriteManager>;
  71850. private _onDisposeObserver;
  71851. /**
  71852. * Callback called when the manager is disposed
  71853. */
  71854. onDispose: () => void;
  71855. private _capacity;
  71856. private _spriteTexture;
  71857. private _epsilon;
  71858. private _scene;
  71859. private _vertexData;
  71860. private _buffer;
  71861. private _vertexBuffers;
  71862. private _indexBuffer;
  71863. private _effectBase;
  71864. private _effectFog;
  71865. /**
  71866. * Gets or sets the spritesheet texture
  71867. */
  71868. texture: Texture;
  71869. /**
  71870. * Creates a new sprite manager
  71871. * @param name defines the manager's name
  71872. * @param imgUrl defines the sprite sheet url
  71873. * @param capacity defines the maximum allowed number of sprites
  71874. * @param cellSize defines the size of a sprite cell
  71875. * @param scene defines the hosting scene
  71876. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71877. * @param samplingMode defines the smapling mode to use with spritesheet
  71878. */
  71879. constructor(
  71880. /** defines the manager's name */
  71881. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71882. private _appendSpriteVertex;
  71883. /**
  71884. * Intersects the sprites with a ray
  71885. * @param ray defines the ray to intersect with
  71886. * @param camera defines the current active camera
  71887. * @param predicate defines a predicate used to select candidate sprites
  71888. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71889. * @returns null if no hit or a PickingInfo
  71890. */
  71891. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71892. /**
  71893. * Render all child sprites
  71894. */
  71895. render(): void;
  71896. /**
  71897. * Release associated resources
  71898. */
  71899. dispose(): void;
  71900. }
  71901. }
  71902. declare module BABYLON {
  71903. /**
  71904. * Class used to represent a sprite
  71905. * @see http://doc.babylonjs.com/babylon101/sprites
  71906. */
  71907. export class Sprite {
  71908. /** defines the name */
  71909. name: string;
  71910. /** Gets or sets the current world position */
  71911. position: Vector3;
  71912. /** Gets or sets the main color */
  71913. color: Color4;
  71914. /** Gets or sets the width */
  71915. width: number;
  71916. /** Gets or sets the height */
  71917. height: number;
  71918. /** Gets or sets rotation angle */
  71919. angle: number;
  71920. /** Gets or sets the cell index in the sprite sheet */
  71921. cellIndex: number;
  71922. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71923. invertU: number;
  71924. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71925. invertV: number;
  71926. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71927. disposeWhenFinishedAnimating: boolean;
  71928. /** Gets the list of attached animations */
  71929. animations: Animation[];
  71930. /** Gets or sets a boolean indicating if the sprite can be picked */
  71931. isPickable: boolean;
  71932. /**
  71933. * Gets or sets the associated action manager
  71934. */
  71935. actionManager: Nullable<ActionManager>;
  71936. private _animationStarted;
  71937. private _loopAnimation;
  71938. private _fromIndex;
  71939. private _toIndex;
  71940. private _delay;
  71941. private _direction;
  71942. private _manager;
  71943. private _time;
  71944. private _onAnimationEnd;
  71945. /**
  71946. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71947. */
  71948. isVisible: boolean;
  71949. /**
  71950. * Gets or sets the sprite size
  71951. */
  71952. size: number;
  71953. /**
  71954. * Creates a new Sprite
  71955. * @param name defines the name
  71956. * @param manager defines the manager
  71957. */
  71958. constructor(
  71959. /** defines the name */
  71960. name: string, manager: ISpriteManager);
  71961. /**
  71962. * Starts an animation
  71963. * @param from defines the initial key
  71964. * @param to defines the end key
  71965. * @param loop defines if the animation must loop
  71966. * @param delay defines the start delay (in ms)
  71967. * @param onAnimationEnd defines a callback to call when animation ends
  71968. */
  71969. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71970. /** Stops current animation (if any) */
  71971. stopAnimation(): void;
  71972. /** @hidden */
  71973. _animate(deltaTime: number): void;
  71974. /** Release associated resources */
  71975. dispose(): void;
  71976. }
  71977. }
  71978. declare module BABYLON {
  71979. /**
  71980. * Information about the result of picking within a scene
  71981. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71982. */
  71983. export class PickingInfo {
  71984. /** @hidden */
  71985. _pickingUnavailable: boolean;
  71986. /**
  71987. * If the pick collided with an object
  71988. */
  71989. hit: boolean;
  71990. /**
  71991. * Distance away where the pick collided
  71992. */
  71993. distance: number;
  71994. /**
  71995. * The location of pick collision
  71996. */
  71997. pickedPoint: Nullable<Vector3>;
  71998. /**
  71999. * The mesh corresponding the the pick collision
  72000. */
  72001. pickedMesh: Nullable<AbstractMesh>;
  72002. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  72003. bu: number;
  72004. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  72005. bv: number;
  72006. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  72007. faceId: number;
  72008. /** Id of the the submesh that was picked */
  72009. subMeshId: number;
  72010. /** If a sprite was picked, this will be the sprite the pick collided with */
  72011. pickedSprite: Nullable<Sprite>;
  72012. /**
  72013. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  72014. */
  72015. originMesh: Nullable<AbstractMesh>;
  72016. /**
  72017. * The ray that was used to perform the picking.
  72018. */
  72019. ray: Nullable<Ray>;
  72020. /**
  72021. * Gets the normal correspodning to the face the pick collided with
  72022. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  72023. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  72024. * @returns The normal correspodning to the face the pick collided with
  72025. */
  72026. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  72027. /**
  72028. * Gets the texture coordinates of where the pick occured
  72029. * @returns the vector containing the coordnates of the texture
  72030. */
  72031. getTextureCoordinates(): Nullable<Vector2>;
  72032. }
  72033. }
  72034. declare module BABYLON {
  72035. /**
  72036. * Gather the list of pointer event types as constants.
  72037. */
  72038. export class PointerEventTypes {
  72039. /**
  72040. * 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.
  72041. */
  72042. static readonly POINTERDOWN: number;
  72043. /**
  72044. * The pointerup event is fired when a pointer is no longer active.
  72045. */
  72046. static readonly POINTERUP: number;
  72047. /**
  72048. * The pointermove event is fired when a pointer changes coordinates.
  72049. */
  72050. static readonly POINTERMOVE: number;
  72051. /**
  72052. * The pointerwheel event is fired when a mouse wheel has been rotated.
  72053. */
  72054. static readonly POINTERWHEEL: number;
  72055. /**
  72056. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  72057. */
  72058. static readonly POINTERPICK: number;
  72059. /**
  72060. * The pointertap event is fired when a the object has been touched and released without drag.
  72061. */
  72062. static readonly POINTERTAP: number;
  72063. /**
  72064. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  72065. */
  72066. static readonly POINTERDOUBLETAP: number;
  72067. }
  72068. /**
  72069. * Base class of pointer info types.
  72070. */
  72071. export class PointerInfoBase {
  72072. /**
  72073. * Defines the type of event (PointerEventTypes)
  72074. */
  72075. type: number;
  72076. /**
  72077. * Defines the related dom event
  72078. */
  72079. event: PointerEvent | MouseWheelEvent;
  72080. /**
  72081. * Instantiates the base class of pointers info.
  72082. * @param type Defines the type of event (PointerEventTypes)
  72083. * @param event Defines the related dom event
  72084. */
  72085. constructor(
  72086. /**
  72087. * Defines the type of event (PointerEventTypes)
  72088. */
  72089. type: number,
  72090. /**
  72091. * Defines the related dom event
  72092. */
  72093. event: PointerEvent | MouseWheelEvent);
  72094. }
  72095. /**
  72096. * This class is used to store pointer related info for the onPrePointerObservable event.
  72097. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  72098. */
  72099. export class PointerInfoPre extends PointerInfoBase {
  72100. /**
  72101. * Ray from a pointer if availible (eg. 6dof controller)
  72102. */
  72103. ray: Nullable<Ray>;
  72104. /**
  72105. * Defines the local position of the pointer on the canvas.
  72106. */
  72107. localPosition: Vector2;
  72108. /**
  72109. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  72110. */
  72111. skipOnPointerObservable: boolean;
  72112. /**
  72113. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  72114. * @param type Defines the type of event (PointerEventTypes)
  72115. * @param event Defines the related dom event
  72116. * @param localX Defines the local x coordinates of the pointer when the event occured
  72117. * @param localY Defines the local y coordinates of the pointer when the event occured
  72118. */
  72119. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  72120. }
  72121. /**
  72122. * This type contains all the data related to a pointer event in Babylon.js.
  72123. * 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.
  72124. */
  72125. export class PointerInfo extends PointerInfoBase {
  72126. /**
  72127. * Defines the picking info associated to the info (if any)\
  72128. */
  72129. pickInfo: Nullable<PickingInfo>;
  72130. /**
  72131. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  72132. * @param type Defines the type of event (PointerEventTypes)
  72133. * @param event Defines the related dom event
  72134. * @param pickInfo Defines the picking info associated to the info (if any)\
  72135. */
  72136. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  72137. /**
  72138. * Defines the picking info associated to the info (if any)\
  72139. */
  72140. pickInfo: Nullable<PickingInfo>);
  72141. }
  72142. /**
  72143. * Data relating to a touch event on the screen.
  72144. */
  72145. export interface PointerTouch {
  72146. /**
  72147. * X coordinate of touch.
  72148. */
  72149. x: number;
  72150. /**
  72151. * Y coordinate of touch.
  72152. */
  72153. y: number;
  72154. /**
  72155. * Id of touch. Unique for each finger.
  72156. */
  72157. pointerId: number;
  72158. /**
  72159. * Event type passed from DOM.
  72160. */
  72161. type: any;
  72162. }
  72163. }
  72164. declare module BABYLON {
  72165. /**
  72166. * Manage the mouse inputs to control the movement of a free camera.
  72167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72168. */
  72169. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  72170. /**
  72171. * Define if touch is enabled in the mouse input
  72172. */
  72173. touchEnabled: boolean;
  72174. /**
  72175. * Defines the camera the input is attached to.
  72176. */
  72177. camera: FreeCamera;
  72178. /**
  72179. * Defines the buttons associated with the input to handle camera move.
  72180. */
  72181. buttons: number[];
  72182. /**
  72183. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  72184. */
  72185. angularSensibility: number;
  72186. private _pointerInput;
  72187. private _onMouseMove;
  72188. private _observer;
  72189. private previousPosition;
  72190. /**
  72191. * Observable for when a pointer move event occurs containing the move offset
  72192. */
  72193. onPointerMovedObservable: Observable<{
  72194. offsetX: number;
  72195. offsetY: number;
  72196. }>;
  72197. /**
  72198. * @hidden
  72199. * If the camera should be rotated automatically based on pointer movement
  72200. */
  72201. _allowCameraRotation: boolean;
  72202. /**
  72203. * Manage the mouse inputs to control the movement of a free camera.
  72204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72205. * @param touchEnabled Defines if touch is enabled or not
  72206. */
  72207. constructor(
  72208. /**
  72209. * Define if touch is enabled in the mouse input
  72210. */
  72211. touchEnabled?: boolean);
  72212. /**
  72213. * Attach the input controls to a specific dom element to get the input from.
  72214. * @param element Defines the element the controls should be listened from
  72215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72216. */
  72217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72218. /**
  72219. * Called on JS contextmenu event.
  72220. * Override this method to provide functionality.
  72221. */
  72222. protected onContextMenu(evt: PointerEvent): void;
  72223. /**
  72224. * Detach the current controls from the specified dom element.
  72225. * @param element Defines the element to stop listening the inputs from
  72226. */
  72227. detachControl(element: Nullable<HTMLElement>): void;
  72228. /**
  72229. * Gets the class name of the current intput.
  72230. * @returns the class name
  72231. */
  72232. getClassName(): string;
  72233. /**
  72234. * Get the friendly name associated with the input class.
  72235. * @returns the input friendly name
  72236. */
  72237. getSimpleName(): string;
  72238. }
  72239. }
  72240. declare module BABYLON {
  72241. /**
  72242. * Manage the touch inputs to control the movement of a free camera.
  72243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72244. */
  72245. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  72246. /**
  72247. * Defines the camera the input is attached to.
  72248. */
  72249. camera: FreeCamera;
  72250. /**
  72251. * Defines the touch sensibility for rotation.
  72252. * The higher the faster.
  72253. */
  72254. touchAngularSensibility: number;
  72255. /**
  72256. * Defines the touch sensibility for move.
  72257. * The higher the faster.
  72258. */
  72259. touchMoveSensibility: number;
  72260. private _offsetX;
  72261. private _offsetY;
  72262. private _pointerPressed;
  72263. private _pointerInput;
  72264. private _observer;
  72265. private _onLostFocus;
  72266. /**
  72267. * Attach the input controls to a specific dom element to get the input from.
  72268. * @param element Defines the element the controls should be listened from
  72269. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72270. */
  72271. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72272. /**
  72273. * Detach the current controls from the specified dom element.
  72274. * @param element Defines the element to stop listening the inputs from
  72275. */
  72276. detachControl(element: Nullable<HTMLElement>): void;
  72277. /**
  72278. * Update the current camera state depending on the inputs that have been used this frame.
  72279. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72280. */
  72281. checkInputs(): void;
  72282. /**
  72283. * Gets the class name of the current intput.
  72284. * @returns the class name
  72285. */
  72286. getClassName(): string;
  72287. /**
  72288. * Get the friendly name associated with the input class.
  72289. * @returns the input friendly name
  72290. */
  72291. getSimpleName(): string;
  72292. }
  72293. }
  72294. declare module BABYLON {
  72295. /**
  72296. * Default Inputs manager for the FreeCamera.
  72297. * It groups all the default supported inputs for ease of use.
  72298. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72299. */
  72300. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  72301. /**
  72302. * @hidden
  72303. */
  72304. _mouseInput: Nullable<FreeCameraMouseInput>;
  72305. /**
  72306. * Instantiates a new FreeCameraInputsManager.
  72307. * @param camera Defines the camera the inputs belong to
  72308. */
  72309. constructor(camera: FreeCamera);
  72310. /**
  72311. * Add keyboard input support to the input manager.
  72312. * @returns the current input manager
  72313. */
  72314. addKeyboard(): FreeCameraInputsManager;
  72315. /**
  72316. * Add mouse input support to the input manager.
  72317. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  72318. * @returns the current input manager
  72319. */
  72320. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  72321. /**
  72322. * Removes the mouse input support from the manager
  72323. * @returns the current input manager
  72324. */
  72325. removeMouse(): FreeCameraInputsManager;
  72326. /**
  72327. * Add touch input support to the input manager.
  72328. * @returns the current input manager
  72329. */
  72330. addTouch(): FreeCameraInputsManager;
  72331. /**
  72332. * Remove all attached input methods from a camera
  72333. */
  72334. clear(): void;
  72335. }
  72336. }
  72337. declare module BABYLON {
  72338. /**
  72339. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72340. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  72341. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72342. */
  72343. export class FreeCamera extends TargetCamera {
  72344. /**
  72345. * Define the collision ellipsoid of the camera.
  72346. * This is helpful to simulate a camera body like the player body around the camera
  72347. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  72348. */
  72349. ellipsoid: Vector3;
  72350. /**
  72351. * Define an offset for the position of the ellipsoid around the camera.
  72352. * This can be helpful to determine the center of the body near the gravity center of the body
  72353. * instead of its head.
  72354. */
  72355. ellipsoidOffset: Vector3;
  72356. /**
  72357. * Enable or disable collisions of the camera with the rest of the scene objects.
  72358. */
  72359. checkCollisions: boolean;
  72360. /**
  72361. * Enable or disable gravity on the camera.
  72362. */
  72363. applyGravity: boolean;
  72364. /**
  72365. * Define the input manager associated to the camera.
  72366. */
  72367. inputs: FreeCameraInputsManager;
  72368. /**
  72369. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72370. * Higher values reduce sensitivity.
  72371. */
  72372. /**
  72373. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72374. * Higher values reduce sensitivity.
  72375. */
  72376. angularSensibility: number;
  72377. /**
  72378. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72379. */
  72380. keysUp: number[];
  72381. /**
  72382. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72383. */
  72384. keysDown: number[];
  72385. /**
  72386. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72387. */
  72388. keysLeft: number[];
  72389. /**
  72390. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72391. */
  72392. keysRight: number[];
  72393. /**
  72394. * Event raised when the camera collide with a mesh in the scene.
  72395. */
  72396. onCollide: (collidedMesh: AbstractMesh) => void;
  72397. private _collider;
  72398. private _needMoveForGravity;
  72399. private _oldPosition;
  72400. private _diffPosition;
  72401. private _newPosition;
  72402. /** @hidden */
  72403. _localDirection: Vector3;
  72404. /** @hidden */
  72405. _transformedDirection: Vector3;
  72406. /**
  72407. * Instantiates a Free Camera.
  72408. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72409. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72410. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72411. * @param name Define the name of the camera in the scene
  72412. * @param position Define the start position of the camera in the scene
  72413. * @param scene Define the scene the camera belongs to
  72414. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72415. */
  72416. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72417. /**
  72418. * Attached controls to the current camera.
  72419. * @param element Defines the element the controls should be listened from
  72420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72421. */
  72422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72423. /**
  72424. * Detach the current controls from the camera.
  72425. * The camera will stop reacting to inputs.
  72426. * @param element Defines the element to stop listening the inputs from
  72427. */
  72428. detachControl(element: HTMLElement): void;
  72429. private _collisionMask;
  72430. /**
  72431. * Define a collision mask to limit the list of object the camera can collide with
  72432. */
  72433. collisionMask: number;
  72434. /** @hidden */
  72435. _collideWithWorld(displacement: Vector3): void;
  72436. private _onCollisionPositionChange;
  72437. /** @hidden */
  72438. _checkInputs(): void;
  72439. /** @hidden */
  72440. _decideIfNeedsToMove(): boolean;
  72441. /** @hidden */
  72442. _updatePosition(): void;
  72443. /**
  72444. * Destroy the camera and release the current resources hold by it.
  72445. */
  72446. dispose(): void;
  72447. /**
  72448. * Gets the current object class name.
  72449. * @return the class name
  72450. */
  72451. getClassName(): string;
  72452. }
  72453. }
  72454. declare module BABYLON {
  72455. /**
  72456. * Represents a gamepad control stick position
  72457. */
  72458. export class StickValues {
  72459. /**
  72460. * The x component of the control stick
  72461. */
  72462. x: number;
  72463. /**
  72464. * The y component of the control stick
  72465. */
  72466. y: number;
  72467. /**
  72468. * Initializes the gamepad x and y control stick values
  72469. * @param x The x component of the gamepad control stick value
  72470. * @param y The y component of the gamepad control stick value
  72471. */
  72472. constructor(
  72473. /**
  72474. * The x component of the control stick
  72475. */
  72476. x: number,
  72477. /**
  72478. * The y component of the control stick
  72479. */
  72480. y: number);
  72481. }
  72482. /**
  72483. * An interface which manages callbacks for gamepad button changes
  72484. */
  72485. export interface GamepadButtonChanges {
  72486. /**
  72487. * Called when a gamepad has been changed
  72488. */
  72489. changed: boolean;
  72490. /**
  72491. * Called when a gamepad press event has been triggered
  72492. */
  72493. pressChanged: boolean;
  72494. /**
  72495. * Called when a touch event has been triggered
  72496. */
  72497. touchChanged: boolean;
  72498. /**
  72499. * Called when a value has changed
  72500. */
  72501. valueChanged: boolean;
  72502. }
  72503. /**
  72504. * Represents a gamepad
  72505. */
  72506. export class Gamepad {
  72507. /**
  72508. * The id of the gamepad
  72509. */
  72510. id: string;
  72511. /**
  72512. * The index of the gamepad
  72513. */
  72514. index: number;
  72515. /**
  72516. * The browser gamepad
  72517. */
  72518. browserGamepad: any;
  72519. /**
  72520. * Specifies what type of gamepad this represents
  72521. */
  72522. type: number;
  72523. private _leftStick;
  72524. private _rightStick;
  72525. /** @hidden */
  72526. _isConnected: boolean;
  72527. private _leftStickAxisX;
  72528. private _leftStickAxisY;
  72529. private _rightStickAxisX;
  72530. private _rightStickAxisY;
  72531. /**
  72532. * Triggered when the left control stick has been changed
  72533. */
  72534. private _onleftstickchanged;
  72535. /**
  72536. * Triggered when the right control stick has been changed
  72537. */
  72538. private _onrightstickchanged;
  72539. /**
  72540. * Represents a gamepad controller
  72541. */
  72542. static GAMEPAD: number;
  72543. /**
  72544. * Represents a generic controller
  72545. */
  72546. static GENERIC: number;
  72547. /**
  72548. * Represents an XBox controller
  72549. */
  72550. static XBOX: number;
  72551. /**
  72552. * Represents a pose-enabled controller
  72553. */
  72554. static POSE_ENABLED: number;
  72555. /**
  72556. * Specifies whether the left control stick should be Y-inverted
  72557. */
  72558. protected _invertLeftStickY: boolean;
  72559. /**
  72560. * Specifies if the gamepad has been connected
  72561. */
  72562. readonly isConnected: boolean;
  72563. /**
  72564. * Initializes the gamepad
  72565. * @param id The id of the gamepad
  72566. * @param index The index of the gamepad
  72567. * @param browserGamepad The browser gamepad
  72568. * @param leftStickX The x component of the left joystick
  72569. * @param leftStickY The y component of the left joystick
  72570. * @param rightStickX The x component of the right joystick
  72571. * @param rightStickY The y component of the right joystick
  72572. */
  72573. constructor(
  72574. /**
  72575. * The id of the gamepad
  72576. */
  72577. id: string,
  72578. /**
  72579. * The index of the gamepad
  72580. */
  72581. index: number,
  72582. /**
  72583. * The browser gamepad
  72584. */
  72585. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72586. /**
  72587. * Callback triggered when the left joystick has changed
  72588. * @param callback
  72589. */
  72590. onleftstickchanged(callback: (values: StickValues) => void): void;
  72591. /**
  72592. * Callback triggered when the right joystick has changed
  72593. * @param callback
  72594. */
  72595. onrightstickchanged(callback: (values: StickValues) => void): void;
  72596. /**
  72597. * Gets the left joystick
  72598. */
  72599. /**
  72600. * Sets the left joystick values
  72601. */
  72602. leftStick: StickValues;
  72603. /**
  72604. * Gets the right joystick
  72605. */
  72606. /**
  72607. * Sets the right joystick value
  72608. */
  72609. rightStick: StickValues;
  72610. /**
  72611. * Updates the gamepad joystick positions
  72612. */
  72613. update(): void;
  72614. /**
  72615. * Disposes the gamepad
  72616. */
  72617. dispose(): void;
  72618. }
  72619. /**
  72620. * Represents a generic gamepad
  72621. */
  72622. export class GenericPad extends Gamepad {
  72623. private _buttons;
  72624. private _onbuttondown;
  72625. private _onbuttonup;
  72626. /**
  72627. * Observable triggered when a button has been pressed
  72628. */
  72629. onButtonDownObservable: Observable<number>;
  72630. /**
  72631. * Observable triggered when a button has been released
  72632. */
  72633. onButtonUpObservable: Observable<number>;
  72634. /**
  72635. * Callback triggered when a button has been pressed
  72636. * @param callback Called when a button has been pressed
  72637. */
  72638. onbuttondown(callback: (buttonPressed: number) => void): void;
  72639. /**
  72640. * Callback triggered when a button has been released
  72641. * @param callback Called when a button has been released
  72642. */
  72643. onbuttonup(callback: (buttonReleased: number) => void): void;
  72644. /**
  72645. * Initializes the generic gamepad
  72646. * @param id The id of the generic gamepad
  72647. * @param index The index of the generic gamepad
  72648. * @param browserGamepad The browser gamepad
  72649. */
  72650. constructor(id: string, index: number, browserGamepad: any);
  72651. private _setButtonValue;
  72652. /**
  72653. * Updates the generic gamepad
  72654. */
  72655. update(): void;
  72656. /**
  72657. * Disposes the generic gamepad
  72658. */
  72659. dispose(): void;
  72660. }
  72661. }
  72662. declare module BABYLON {
  72663. /**
  72664. * Defines the types of pose enabled controllers that are supported
  72665. */
  72666. export enum PoseEnabledControllerType {
  72667. /**
  72668. * HTC Vive
  72669. */
  72670. VIVE = 0,
  72671. /**
  72672. * Oculus Rift
  72673. */
  72674. OCULUS = 1,
  72675. /**
  72676. * Windows mixed reality
  72677. */
  72678. WINDOWS = 2,
  72679. /**
  72680. * Samsung gear VR
  72681. */
  72682. GEAR_VR = 3,
  72683. /**
  72684. * Google Daydream
  72685. */
  72686. DAYDREAM = 4,
  72687. /**
  72688. * Generic
  72689. */
  72690. GENERIC = 5
  72691. }
  72692. /**
  72693. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72694. */
  72695. export interface MutableGamepadButton {
  72696. /**
  72697. * Value of the button/trigger
  72698. */
  72699. value: number;
  72700. /**
  72701. * If the button/trigger is currently touched
  72702. */
  72703. touched: boolean;
  72704. /**
  72705. * If the button/trigger is currently pressed
  72706. */
  72707. pressed: boolean;
  72708. }
  72709. /**
  72710. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72711. * @hidden
  72712. */
  72713. export interface ExtendedGamepadButton extends GamepadButton {
  72714. /**
  72715. * If the button/trigger is currently pressed
  72716. */
  72717. readonly pressed: boolean;
  72718. /**
  72719. * If the button/trigger is currently touched
  72720. */
  72721. readonly touched: boolean;
  72722. /**
  72723. * Value of the button/trigger
  72724. */
  72725. readonly value: number;
  72726. }
  72727. /** @hidden */
  72728. export interface _GamePadFactory {
  72729. /**
  72730. * Returns wether or not the current gamepad can be created for this type of controller.
  72731. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72732. * @returns true if it can be created, otherwise false
  72733. */
  72734. canCreate(gamepadInfo: any): boolean;
  72735. /**
  72736. * Creates a new instance of the Gamepad.
  72737. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72738. * @returns the new gamepad instance
  72739. */
  72740. create(gamepadInfo: any): Gamepad;
  72741. }
  72742. /**
  72743. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72744. */
  72745. export class PoseEnabledControllerHelper {
  72746. /** @hidden */
  72747. static _ControllerFactories: _GamePadFactory[];
  72748. /** @hidden */
  72749. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72750. /**
  72751. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72752. * @param vrGamepad the gamepad to initialized
  72753. * @returns a vr controller of the type the gamepad identified as
  72754. */
  72755. static InitiateController(vrGamepad: any): Gamepad;
  72756. }
  72757. /**
  72758. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72759. */
  72760. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72761. private _deviceRoomPosition;
  72762. private _deviceRoomRotationQuaternion;
  72763. /**
  72764. * The device position in babylon space
  72765. */
  72766. devicePosition: Vector3;
  72767. /**
  72768. * The device rotation in babylon space
  72769. */
  72770. deviceRotationQuaternion: Quaternion;
  72771. /**
  72772. * The scale factor of the device in babylon space
  72773. */
  72774. deviceScaleFactor: number;
  72775. /**
  72776. * (Likely devicePosition should be used instead) The device position in its room space
  72777. */
  72778. position: Vector3;
  72779. /**
  72780. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72781. */
  72782. rotationQuaternion: Quaternion;
  72783. /**
  72784. * The type of controller (Eg. Windows mixed reality)
  72785. */
  72786. controllerType: PoseEnabledControllerType;
  72787. protected _calculatedPosition: Vector3;
  72788. private _calculatedRotation;
  72789. /**
  72790. * The raw pose from the device
  72791. */
  72792. rawPose: DevicePose;
  72793. private _trackPosition;
  72794. private _maxRotationDistFromHeadset;
  72795. private _draggedRoomRotation;
  72796. /**
  72797. * @hidden
  72798. */
  72799. _disableTrackPosition(fixedPosition: Vector3): void;
  72800. /**
  72801. * Internal, the mesh attached to the controller
  72802. * @hidden
  72803. */
  72804. _mesh: Nullable<AbstractMesh>;
  72805. private _poseControlledCamera;
  72806. private _leftHandSystemQuaternion;
  72807. /**
  72808. * Internal, matrix used to convert room space to babylon space
  72809. * @hidden
  72810. */
  72811. _deviceToWorld: Matrix;
  72812. /**
  72813. * Node to be used when casting a ray from the controller
  72814. * @hidden
  72815. */
  72816. _pointingPoseNode: Nullable<TransformNode>;
  72817. /**
  72818. * Name of the child mesh that can be used to cast a ray from the controller
  72819. */
  72820. static readonly POINTING_POSE: string;
  72821. /**
  72822. * Creates a new PoseEnabledController from a gamepad
  72823. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72824. */
  72825. constructor(browserGamepad: any);
  72826. private _workingMatrix;
  72827. /**
  72828. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72829. */
  72830. update(): void;
  72831. /**
  72832. * Updates only the pose device and mesh without doing any button event checking
  72833. */
  72834. protected _updatePoseAndMesh(): void;
  72835. /**
  72836. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72837. * @param poseData raw pose fromthe device
  72838. */
  72839. updateFromDevice(poseData: DevicePose): void;
  72840. /**
  72841. * @hidden
  72842. */
  72843. _meshAttachedObservable: Observable<AbstractMesh>;
  72844. /**
  72845. * Attaches a mesh to the controller
  72846. * @param mesh the mesh to be attached
  72847. */
  72848. attachToMesh(mesh: AbstractMesh): void;
  72849. /**
  72850. * Attaches the controllers mesh to a camera
  72851. * @param camera the camera the mesh should be attached to
  72852. */
  72853. attachToPoseControlledCamera(camera: TargetCamera): void;
  72854. /**
  72855. * Disposes of the controller
  72856. */
  72857. dispose(): void;
  72858. /**
  72859. * The mesh that is attached to the controller
  72860. */
  72861. readonly mesh: Nullable<AbstractMesh>;
  72862. /**
  72863. * Gets the ray of the controller in the direction the controller is pointing
  72864. * @param length the length the resulting ray should be
  72865. * @returns a ray in the direction the controller is pointing
  72866. */
  72867. getForwardRay(length?: number): Ray;
  72868. }
  72869. }
  72870. declare module BABYLON {
  72871. /**
  72872. * Defines the WebVRController object that represents controllers tracked in 3D space
  72873. */
  72874. export abstract class WebVRController extends PoseEnabledController {
  72875. /**
  72876. * Internal, the default controller model for the controller
  72877. */
  72878. protected _defaultModel: AbstractMesh;
  72879. /**
  72880. * Fired when the trigger state has changed
  72881. */
  72882. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72883. /**
  72884. * Fired when the main button state has changed
  72885. */
  72886. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72887. /**
  72888. * Fired when the secondary button state has changed
  72889. */
  72890. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72891. /**
  72892. * Fired when the pad state has changed
  72893. */
  72894. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72895. /**
  72896. * Fired when controllers stick values have changed
  72897. */
  72898. onPadValuesChangedObservable: Observable<StickValues>;
  72899. /**
  72900. * Array of button availible on the controller
  72901. */
  72902. protected _buttons: Array<MutableGamepadButton>;
  72903. private _onButtonStateChange;
  72904. /**
  72905. * Fired when a controller button's state has changed
  72906. * @param callback the callback containing the button that was modified
  72907. */
  72908. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72909. /**
  72910. * X and Y axis corrisponding to the controllers joystick
  72911. */
  72912. pad: StickValues;
  72913. /**
  72914. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72915. */
  72916. hand: string;
  72917. /**
  72918. * The default controller model for the controller
  72919. */
  72920. readonly defaultModel: AbstractMesh;
  72921. /**
  72922. * Creates a new WebVRController from a gamepad
  72923. * @param vrGamepad the gamepad that the WebVRController should be created from
  72924. */
  72925. constructor(vrGamepad: any);
  72926. /**
  72927. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72928. */
  72929. update(): void;
  72930. /**
  72931. * Function to be called when a button is modified
  72932. */
  72933. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72934. /**
  72935. * Loads a mesh and attaches it to the controller
  72936. * @param scene the scene the mesh should be added to
  72937. * @param meshLoaded callback for when the mesh has been loaded
  72938. */
  72939. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72940. private _setButtonValue;
  72941. private _changes;
  72942. private _checkChanges;
  72943. /**
  72944. * Disposes of th webVRCOntroller
  72945. */
  72946. dispose(): void;
  72947. }
  72948. }
  72949. declare module BABYLON {
  72950. /**
  72951. * The HemisphericLight simulates the ambient environment light,
  72952. * so the passed direction is the light reflection direction, not the incoming direction.
  72953. */
  72954. export class HemisphericLight extends Light {
  72955. /**
  72956. * The groundColor is the light in the opposite direction to the one specified during creation.
  72957. * 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.
  72958. */
  72959. groundColor: Color3;
  72960. /**
  72961. * The light reflection direction, not the incoming direction.
  72962. */
  72963. direction: Vector3;
  72964. /**
  72965. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72966. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72967. * The HemisphericLight can't cast shadows.
  72968. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72969. * @param name The friendly name of the light
  72970. * @param direction The direction of the light reflection
  72971. * @param scene The scene the light belongs to
  72972. */
  72973. constructor(name: string, direction: Vector3, scene: Scene);
  72974. protected _buildUniformLayout(): void;
  72975. /**
  72976. * Returns the string "HemisphericLight".
  72977. * @return The class name
  72978. */
  72979. getClassName(): string;
  72980. /**
  72981. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72982. * Returns the updated direction.
  72983. * @param target The target the direction should point to
  72984. * @return The computed direction
  72985. */
  72986. setDirectionToTarget(target: Vector3): Vector3;
  72987. /**
  72988. * Returns the shadow generator associated to the light.
  72989. * @returns Always null for hemispheric lights because it does not support shadows.
  72990. */
  72991. getShadowGenerator(): Nullable<IShadowGenerator>;
  72992. /**
  72993. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72994. * @param effect The effect to update
  72995. * @param lightIndex The index of the light in the effect to update
  72996. * @returns The hemispheric light
  72997. */
  72998. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72999. /**
  73000. * Computes the world matrix of the node
  73001. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73002. * @param useWasUpdatedFlag defines a reserved property
  73003. * @returns the world matrix
  73004. */
  73005. computeWorldMatrix(): Matrix;
  73006. /**
  73007. * Returns the integer 3.
  73008. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73009. */
  73010. getTypeID(): number;
  73011. /**
  73012. * Prepares the list of defines specific to the light type.
  73013. * @param defines the list of defines
  73014. * @param lightIndex defines the index of the light for the effect
  73015. */
  73016. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73017. }
  73018. }
  73019. declare module BABYLON {
  73020. /** @hidden */
  73021. export var vrMultiviewToSingleviewPixelShader: {
  73022. name: string;
  73023. shader: string;
  73024. };
  73025. }
  73026. declare module BABYLON {
  73027. /**
  73028. * Renders to multiple views with a single draw call
  73029. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  73030. */
  73031. export class MultiviewRenderTarget extends RenderTargetTexture {
  73032. /**
  73033. * Creates a multiview render target
  73034. * @param scene scene used with the render target
  73035. * @param size the size of the render target (used for each view)
  73036. */
  73037. constructor(scene: Scene, size?: number | {
  73038. width: number;
  73039. height: number;
  73040. } | {
  73041. ratio: number;
  73042. });
  73043. /**
  73044. * @hidden
  73045. * @param faceIndex the face index, if its a cube texture
  73046. */
  73047. _bindFrameBuffer(faceIndex?: number): void;
  73048. /**
  73049. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  73050. * @returns the view count
  73051. */
  73052. getViewCount(): number;
  73053. }
  73054. }
  73055. declare module BABYLON {
  73056. interface Engine {
  73057. /**
  73058. * Creates a new multiview render target
  73059. * @param width defines the width of the texture
  73060. * @param height defines the height of the texture
  73061. * @returns the created multiview texture
  73062. */
  73063. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  73064. /**
  73065. * Binds a multiview framebuffer to be drawn to
  73066. * @param multiviewTexture texture to bind
  73067. */
  73068. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  73069. }
  73070. interface Camera {
  73071. /**
  73072. * @hidden
  73073. * 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)
  73074. */
  73075. _useMultiviewToSingleView: boolean;
  73076. /**
  73077. * @hidden
  73078. * 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)
  73079. */
  73080. _multiviewTexture: Nullable<RenderTargetTexture>;
  73081. /**
  73082. * @hidden
  73083. * ensures the multiview texture of the camera exists and has the specified width/height
  73084. * @param width height to set on the multiview texture
  73085. * @param height width to set on the multiview texture
  73086. */
  73087. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  73088. }
  73089. interface Scene {
  73090. /** @hidden */
  73091. _transformMatrixR: Matrix;
  73092. /** @hidden */
  73093. _multiviewSceneUbo: Nullable<UniformBuffer>;
  73094. /** @hidden */
  73095. _createMultiviewUbo(): void;
  73096. /** @hidden */
  73097. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  73098. /** @hidden */
  73099. _renderMultiviewToSingleView(camera: Camera): void;
  73100. }
  73101. }
  73102. declare module BABYLON {
  73103. /**
  73104. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  73105. * This will not be used for webXR as it supports displaying texture arrays directly
  73106. */
  73107. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  73108. /**
  73109. * Initializes a VRMultiviewToSingleview
  73110. * @param name name of the post process
  73111. * @param camera camera to be applied to
  73112. * @param scaleFactor scaling factor to the size of the output texture
  73113. */
  73114. constructor(name: string, camera: Camera, scaleFactor: number);
  73115. }
  73116. }
  73117. declare module BABYLON {
  73118. /**
  73119. * Defines the interface used by display changed events
  73120. */
  73121. interface IDisplayChangedEventArgs {
  73122. /** Gets the vrDisplay object (if any) */
  73123. vrDisplay: Nullable<any>;
  73124. /** Gets a boolean indicating if webVR is supported */
  73125. vrSupported: boolean;
  73126. }
  73127. interface Engine {
  73128. /** @hidden */
  73129. _vrDisplay: any;
  73130. /** @hidden */
  73131. _vrSupported: boolean;
  73132. /** @hidden */
  73133. _oldSize: Size;
  73134. /** @hidden */
  73135. _oldHardwareScaleFactor: number;
  73136. /** @hidden */
  73137. _vrExclusivePointerMode: boolean;
  73138. /** @hidden */
  73139. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  73140. /** @hidden */
  73141. _onVRDisplayPointerRestricted: () => void;
  73142. /** @hidden */
  73143. _onVRDisplayPointerUnrestricted: () => void;
  73144. /** @hidden */
  73145. _onVrDisplayConnect: Nullable<(display: any) => void>;
  73146. /** @hidden */
  73147. _onVrDisplayDisconnect: Nullable<() => void>;
  73148. /** @hidden */
  73149. _onVrDisplayPresentChange: Nullable<() => void>;
  73150. /**
  73151. * Observable signaled when VR display mode changes
  73152. */
  73153. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  73154. /**
  73155. * Observable signaled when VR request present is complete
  73156. */
  73157. onVRRequestPresentComplete: Observable<boolean>;
  73158. /**
  73159. * Observable signaled when VR request present starts
  73160. */
  73161. onVRRequestPresentStart: Observable<Engine>;
  73162. /**
  73163. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  73164. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  73165. */
  73166. isInVRExclusivePointerMode: boolean;
  73167. /**
  73168. * Gets a boolean indicating if a webVR device was detected
  73169. * @returns true if a webVR device was detected
  73170. */
  73171. isVRDevicePresent(): boolean;
  73172. /**
  73173. * Gets the current webVR device
  73174. * @returns the current webVR device (or null)
  73175. */
  73176. getVRDevice(): any;
  73177. /**
  73178. * Initializes a webVR display and starts listening to display change events
  73179. * The onVRDisplayChangedObservable will be notified upon these changes
  73180. * @returns A promise containing a VRDisplay and if vr is supported
  73181. */
  73182. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  73183. /** @hidden */
  73184. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  73185. /**
  73186. * Call this function to switch to webVR mode
  73187. * Will do nothing if webVR is not supported or if there is no webVR device
  73188. * @see http://doc.babylonjs.com/how_to/webvr_camera
  73189. */
  73190. enableVR(): void;
  73191. /** @hidden */
  73192. _onVRFullScreenTriggered(): void;
  73193. }
  73194. }
  73195. declare module BABYLON {
  73196. /**
  73197. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  73198. * IMPORTANT!! The data is right-hand data.
  73199. * @export
  73200. * @interface DevicePose
  73201. */
  73202. export interface DevicePose {
  73203. /**
  73204. * The position of the device, values in array are [x,y,z].
  73205. */
  73206. readonly position: Nullable<Float32Array>;
  73207. /**
  73208. * The linearVelocity of the device, values in array are [x,y,z].
  73209. */
  73210. readonly linearVelocity: Nullable<Float32Array>;
  73211. /**
  73212. * The linearAcceleration of the device, values in array are [x,y,z].
  73213. */
  73214. readonly linearAcceleration: Nullable<Float32Array>;
  73215. /**
  73216. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  73217. */
  73218. readonly orientation: Nullable<Float32Array>;
  73219. /**
  73220. * The angularVelocity of the device, values in array are [x,y,z].
  73221. */
  73222. readonly angularVelocity: Nullable<Float32Array>;
  73223. /**
  73224. * The angularAcceleration of the device, values in array are [x,y,z].
  73225. */
  73226. readonly angularAcceleration: Nullable<Float32Array>;
  73227. }
  73228. /**
  73229. * Interface representing a pose controlled object in Babylon.
  73230. * A pose controlled object has both regular pose values as well as pose values
  73231. * from an external device such as a VR head mounted display
  73232. */
  73233. export interface PoseControlled {
  73234. /**
  73235. * The position of the object in babylon space.
  73236. */
  73237. position: Vector3;
  73238. /**
  73239. * The rotation quaternion of the object in babylon space.
  73240. */
  73241. rotationQuaternion: Quaternion;
  73242. /**
  73243. * The position of the device in babylon space.
  73244. */
  73245. devicePosition?: Vector3;
  73246. /**
  73247. * The rotation quaternion of the device in babylon space.
  73248. */
  73249. deviceRotationQuaternion: Quaternion;
  73250. /**
  73251. * The raw pose coming from the device.
  73252. */
  73253. rawPose: Nullable<DevicePose>;
  73254. /**
  73255. * The scale of the device to be used when translating from device space to babylon space.
  73256. */
  73257. deviceScaleFactor: number;
  73258. /**
  73259. * Updates the poseControlled values based on the input device pose.
  73260. * @param poseData the pose data to update the object with
  73261. */
  73262. updateFromDevice(poseData: DevicePose): void;
  73263. }
  73264. /**
  73265. * Set of options to customize the webVRCamera
  73266. */
  73267. export interface WebVROptions {
  73268. /**
  73269. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  73270. */
  73271. trackPosition?: boolean;
  73272. /**
  73273. * Sets the scale of the vrDevice in babylon space. (default: 1)
  73274. */
  73275. positionScale?: number;
  73276. /**
  73277. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  73278. */
  73279. displayName?: string;
  73280. /**
  73281. * Should the native controller meshes be initialized. (default: true)
  73282. */
  73283. controllerMeshes?: boolean;
  73284. /**
  73285. * Creating a default HemiLight only on controllers. (default: true)
  73286. */
  73287. defaultLightingOnControllers?: boolean;
  73288. /**
  73289. * If you don't want to use the default VR button of the helper. (default: false)
  73290. */
  73291. useCustomVRButton?: boolean;
  73292. /**
  73293. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  73294. */
  73295. customVRButton?: HTMLButtonElement;
  73296. /**
  73297. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  73298. */
  73299. rayLength?: number;
  73300. /**
  73301. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  73302. */
  73303. defaultHeight?: number;
  73304. /**
  73305. * If multiview should be used if availible (default: false)
  73306. */
  73307. useMultiview?: boolean;
  73308. }
  73309. /**
  73310. * This represents a WebVR camera.
  73311. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  73312. * @example http://doc.babylonjs.com/how_to/webvr_camera
  73313. */
  73314. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  73315. private webVROptions;
  73316. /**
  73317. * @hidden
  73318. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  73319. */
  73320. _vrDevice: any;
  73321. /**
  73322. * The rawPose of the vrDevice.
  73323. */
  73324. rawPose: Nullable<DevicePose>;
  73325. private _onVREnabled;
  73326. private _specsVersion;
  73327. private _attached;
  73328. private _frameData;
  73329. protected _descendants: Array<Node>;
  73330. private _deviceRoomPosition;
  73331. /** @hidden */
  73332. _deviceRoomRotationQuaternion: Quaternion;
  73333. private _standingMatrix;
  73334. /**
  73335. * Represents device position in babylon space.
  73336. */
  73337. devicePosition: Vector3;
  73338. /**
  73339. * Represents device rotation in babylon space.
  73340. */
  73341. deviceRotationQuaternion: Quaternion;
  73342. /**
  73343. * The scale of the device to be used when translating from device space to babylon space.
  73344. */
  73345. deviceScaleFactor: number;
  73346. private _deviceToWorld;
  73347. private _worldToDevice;
  73348. /**
  73349. * References to the webVR controllers for the vrDevice.
  73350. */
  73351. controllers: Array<WebVRController>;
  73352. /**
  73353. * Emits an event when a controller is attached.
  73354. */
  73355. onControllersAttachedObservable: Observable<WebVRController[]>;
  73356. /**
  73357. * Emits an event when a controller's mesh has been loaded;
  73358. */
  73359. onControllerMeshLoadedObservable: Observable<WebVRController>;
  73360. /**
  73361. * Emits an event when the HMD's pose has been updated.
  73362. */
  73363. onPoseUpdatedFromDeviceObservable: Observable<any>;
  73364. private _poseSet;
  73365. /**
  73366. * If the rig cameras be used as parent instead of this camera.
  73367. */
  73368. rigParenting: boolean;
  73369. private _lightOnControllers;
  73370. private _defaultHeight?;
  73371. /**
  73372. * Instantiates a WebVRFreeCamera.
  73373. * @param name The name of the WebVRFreeCamera
  73374. * @param position The starting anchor position for the camera
  73375. * @param scene The scene the camera belongs to
  73376. * @param webVROptions a set of customizable options for the webVRCamera
  73377. */
  73378. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  73379. /**
  73380. * Gets the device distance from the ground in meters.
  73381. * @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.
  73382. */
  73383. deviceDistanceToRoomGround(): number;
  73384. /**
  73385. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73386. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  73387. */
  73388. useStandingMatrix(callback?: (bool: boolean) => void): void;
  73389. /**
  73390. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73391. * @returns A promise with a boolean set to if the standing matrix is supported.
  73392. */
  73393. useStandingMatrixAsync(): Promise<boolean>;
  73394. /**
  73395. * Disposes the camera
  73396. */
  73397. dispose(): void;
  73398. /**
  73399. * Gets a vrController by name.
  73400. * @param name The name of the controller to retreive
  73401. * @returns the controller matching the name specified or null if not found
  73402. */
  73403. getControllerByName(name: string): Nullable<WebVRController>;
  73404. private _leftController;
  73405. /**
  73406. * The controller corrisponding to the users left hand.
  73407. */
  73408. readonly leftController: Nullable<WebVRController>;
  73409. private _rightController;
  73410. /**
  73411. * The controller corrisponding to the users right hand.
  73412. */
  73413. readonly rightController: Nullable<WebVRController>;
  73414. /**
  73415. * Casts a ray forward from the vrCamera's gaze.
  73416. * @param length Length of the ray (default: 100)
  73417. * @returns the ray corrisponding to the gaze
  73418. */
  73419. getForwardRay(length?: number): Ray;
  73420. /**
  73421. * @hidden
  73422. * Updates the camera based on device's frame data
  73423. */
  73424. _checkInputs(): void;
  73425. /**
  73426. * Updates the poseControlled values based on the input device pose.
  73427. * @param poseData Pose coming from the device
  73428. */
  73429. updateFromDevice(poseData: DevicePose): void;
  73430. private _htmlElementAttached;
  73431. private _detachIfAttached;
  73432. /**
  73433. * WebVR's attach control will start broadcasting frames to the device.
  73434. * Note that in certain browsers (chrome for example) this function must be called
  73435. * within a user-interaction callback. Example:
  73436. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73437. *
  73438. * @param element html element to attach the vrDevice to
  73439. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73440. */
  73441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73442. /**
  73443. * Detaches the camera from the html element and disables VR
  73444. *
  73445. * @param element html element to detach from
  73446. */
  73447. detachControl(element: HTMLElement): void;
  73448. /**
  73449. * @returns the name of this class
  73450. */
  73451. getClassName(): string;
  73452. /**
  73453. * Calls resetPose on the vrDisplay
  73454. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73455. */
  73456. resetToCurrentRotation(): void;
  73457. /**
  73458. * @hidden
  73459. * Updates the rig cameras (left and right eye)
  73460. */
  73461. _updateRigCameras(): void;
  73462. private _workingVector;
  73463. private _oneVector;
  73464. private _workingMatrix;
  73465. private updateCacheCalled;
  73466. private _correctPositionIfNotTrackPosition;
  73467. /**
  73468. * @hidden
  73469. * Updates the cached values of the camera
  73470. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73471. */
  73472. _updateCache(ignoreParentClass?: boolean): void;
  73473. /**
  73474. * @hidden
  73475. * Get current device position in babylon world
  73476. */
  73477. _computeDevicePosition(): void;
  73478. /**
  73479. * Updates the current device position and rotation in the babylon world
  73480. */
  73481. update(): void;
  73482. /**
  73483. * @hidden
  73484. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73485. * @returns an identity matrix
  73486. */
  73487. _getViewMatrix(): Matrix;
  73488. private _tmpMatrix;
  73489. /**
  73490. * This function is called by the two RIG cameras.
  73491. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73492. * @hidden
  73493. */
  73494. _getWebVRViewMatrix(): Matrix;
  73495. /** @hidden */
  73496. _getWebVRProjectionMatrix(): Matrix;
  73497. private _onGamepadConnectedObserver;
  73498. private _onGamepadDisconnectedObserver;
  73499. private _updateCacheWhenTrackingDisabledObserver;
  73500. /**
  73501. * Initializes the controllers and their meshes
  73502. */
  73503. initControllers(): void;
  73504. }
  73505. }
  73506. declare module BABYLON {
  73507. /**
  73508. * Size options for a post process
  73509. */
  73510. export type PostProcessOptions = {
  73511. width: number;
  73512. height: number;
  73513. };
  73514. /**
  73515. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73516. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73517. */
  73518. export class PostProcess {
  73519. /** Name of the PostProcess. */
  73520. name: string;
  73521. /**
  73522. * Gets or sets the unique id of the post process
  73523. */
  73524. uniqueId: number;
  73525. /**
  73526. * Width of the texture to apply the post process on
  73527. */
  73528. width: number;
  73529. /**
  73530. * Height of the texture to apply the post process on
  73531. */
  73532. height: number;
  73533. /**
  73534. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73535. * @hidden
  73536. */
  73537. _outputTexture: Nullable<InternalTexture>;
  73538. /**
  73539. * Sampling mode used by the shader
  73540. * See https://doc.babylonjs.com/classes/3.1/texture
  73541. */
  73542. renderTargetSamplingMode: number;
  73543. /**
  73544. * Clear color to use when screen clearing
  73545. */
  73546. clearColor: Color4;
  73547. /**
  73548. * If the buffer needs to be cleared before applying the post process. (default: true)
  73549. * Should be set to false if shader will overwrite all previous pixels.
  73550. */
  73551. autoClear: boolean;
  73552. /**
  73553. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73554. */
  73555. alphaMode: number;
  73556. /**
  73557. * Sets the setAlphaBlendConstants of the babylon engine
  73558. */
  73559. alphaConstants: Color4;
  73560. /**
  73561. * Animations to be used for the post processing
  73562. */
  73563. animations: Animation[];
  73564. /**
  73565. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73566. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73567. */
  73568. enablePixelPerfectMode: boolean;
  73569. /**
  73570. * Force the postprocess to be applied without taking in account viewport
  73571. */
  73572. forceFullscreenViewport: boolean;
  73573. /**
  73574. * List of inspectable custom properties (used by the Inspector)
  73575. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73576. */
  73577. inspectableCustomProperties: IInspectable[];
  73578. /**
  73579. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73580. *
  73581. * | Value | Type | Description |
  73582. * | ----- | ----------------------------------- | ----------- |
  73583. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73584. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73585. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73586. *
  73587. */
  73588. scaleMode: number;
  73589. /**
  73590. * Force textures to be a power of two (default: false)
  73591. */
  73592. alwaysForcePOT: boolean;
  73593. private _samples;
  73594. /**
  73595. * Number of sample textures (default: 1)
  73596. */
  73597. samples: number;
  73598. /**
  73599. * Modify the scale of the post process to be the same as the viewport (default: false)
  73600. */
  73601. adaptScaleToCurrentViewport: boolean;
  73602. private _camera;
  73603. private _scene;
  73604. private _engine;
  73605. private _options;
  73606. private _reusable;
  73607. private _textureType;
  73608. /**
  73609. * Smart array of input and output textures for the post process.
  73610. * @hidden
  73611. */
  73612. _textures: SmartArray<InternalTexture>;
  73613. /**
  73614. * The index in _textures that corresponds to the output texture.
  73615. * @hidden
  73616. */
  73617. _currentRenderTextureInd: number;
  73618. private _effect;
  73619. private _samplers;
  73620. private _fragmentUrl;
  73621. private _vertexUrl;
  73622. private _parameters;
  73623. private _scaleRatio;
  73624. protected _indexParameters: any;
  73625. private _shareOutputWithPostProcess;
  73626. private _texelSize;
  73627. private _forcedOutputTexture;
  73628. /**
  73629. * Returns the fragment url or shader name used in the post process.
  73630. * @returns the fragment url or name in the shader store.
  73631. */
  73632. getEffectName(): string;
  73633. /**
  73634. * An event triggered when the postprocess is activated.
  73635. */
  73636. onActivateObservable: Observable<Camera>;
  73637. private _onActivateObserver;
  73638. /**
  73639. * A function that is added to the onActivateObservable
  73640. */
  73641. onActivate: Nullable<(camera: Camera) => void>;
  73642. /**
  73643. * An event triggered when the postprocess changes its size.
  73644. */
  73645. onSizeChangedObservable: Observable<PostProcess>;
  73646. private _onSizeChangedObserver;
  73647. /**
  73648. * A function that is added to the onSizeChangedObservable
  73649. */
  73650. onSizeChanged: (postProcess: PostProcess) => void;
  73651. /**
  73652. * An event triggered when the postprocess applies its effect.
  73653. */
  73654. onApplyObservable: Observable<Effect>;
  73655. private _onApplyObserver;
  73656. /**
  73657. * A function that is added to the onApplyObservable
  73658. */
  73659. onApply: (effect: Effect) => void;
  73660. /**
  73661. * An event triggered before rendering the postprocess
  73662. */
  73663. onBeforeRenderObservable: Observable<Effect>;
  73664. private _onBeforeRenderObserver;
  73665. /**
  73666. * A function that is added to the onBeforeRenderObservable
  73667. */
  73668. onBeforeRender: (effect: Effect) => void;
  73669. /**
  73670. * An event triggered after rendering the postprocess
  73671. */
  73672. onAfterRenderObservable: Observable<Effect>;
  73673. private _onAfterRenderObserver;
  73674. /**
  73675. * A function that is added to the onAfterRenderObservable
  73676. */
  73677. onAfterRender: (efect: Effect) => void;
  73678. /**
  73679. * 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
  73680. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73681. */
  73682. inputTexture: InternalTexture;
  73683. /**
  73684. * Gets the camera which post process is applied to.
  73685. * @returns The camera the post process is applied to.
  73686. */
  73687. getCamera(): Camera;
  73688. /**
  73689. * Gets the texel size of the postprocess.
  73690. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73691. */
  73692. readonly texelSize: Vector2;
  73693. /**
  73694. * Creates a new instance PostProcess
  73695. * @param name The name of the PostProcess.
  73696. * @param fragmentUrl The url of the fragment shader to be used.
  73697. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73698. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73699. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73700. * @param camera The camera to apply the render pass to.
  73701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73702. * @param engine The engine which the post process will be applied. (default: current engine)
  73703. * @param reusable If the post process can be reused on the same frame. (default: false)
  73704. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73705. * @param textureType Type of textures used when performing the post process. (default: 0)
  73706. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73707. * @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
  73708. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73709. */
  73710. constructor(
  73711. /** Name of the PostProcess. */
  73712. 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);
  73713. /**
  73714. * Gets a string idenfifying the name of the class
  73715. * @returns "PostProcess" string
  73716. */
  73717. getClassName(): string;
  73718. /**
  73719. * Gets the engine which this post process belongs to.
  73720. * @returns The engine the post process was enabled with.
  73721. */
  73722. getEngine(): Engine;
  73723. /**
  73724. * The effect that is created when initializing the post process.
  73725. * @returns The created effect corrisponding the the postprocess.
  73726. */
  73727. getEffect(): Effect;
  73728. /**
  73729. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73730. * @param postProcess The post process to share the output with.
  73731. * @returns This post process.
  73732. */
  73733. shareOutputWith(postProcess: PostProcess): PostProcess;
  73734. /**
  73735. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73736. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73737. */
  73738. useOwnOutput(): void;
  73739. /**
  73740. * Updates the effect with the current post process compile time values and recompiles the shader.
  73741. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73742. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73743. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73744. * @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
  73745. * @param onCompiled Called when the shader has been compiled.
  73746. * @param onError Called if there is an error when compiling a shader.
  73747. */
  73748. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73749. /**
  73750. * The post process is reusable if it can be used multiple times within one frame.
  73751. * @returns If the post process is reusable
  73752. */
  73753. isReusable(): boolean;
  73754. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73755. markTextureDirty(): void;
  73756. /**
  73757. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73758. * 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.
  73759. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73760. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73761. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73762. * @returns The target texture that was bound to be written to.
  73763. */
  73764. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73765. /**
  73766. * If the post process is supported.
  73767. */
  73768. readonly isSupported: boolean;
  73769. /**
  73770. * The aspect ratio of the output texture.
  73771. */
  73772. readonly aspectRatio: number;
  73773. /**
  73774. * Get a value indicating if the post-process is ready to be used
  73775. * @returns true if the post-process is ready (shader is compiled)
  73776. */
  73777. isReady(): boolean;
  73778. /**
  73779. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73780. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73781. */
  73782. apply(): Nullable<Effect>;
  73783. private _disposeTextures;
  73784. /**
  73785. * Disposes the post process.
  73786. * @param camera The camera to dispose the post process on.
  73787. */
  73788. dispose(camera?: Camera): void;
  73789. }
  73790. }
  73791. declare module BABYLON {
  73792. /**
  73793. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73794. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73795. */
  73796. export class PostProcessManager {
  73797. private _scene;
  73798. private _indexBuffer;
  73799. private _vertexBuffers;
  73800. /**
  73801. * Creates a new instance PostProcess
  73802. * @param scene The scene that the post process is associated with.
  73803. */
  73804. constructor(scene: Scene);
  73805. private _prepareBuffers;
  73806. private _buildIndexBuffer;
  73807. /**
  73808. * Rebuilds the vertex buffers of the manager.
  73809. * @hidden
  73810. */
  73811. _rebuild(): void;
  73812. /**
  73813. * Prepares a frame to be run through a post process.
  73814. * @param sourceTexture The input texture to the post procesess. (default: null)
  73815. * @param postProcesses An array of post processes to be run. (default: null)
  73816. * @returns True if the post processes were able to be run.
  73817. * @hidden
  73818. */
  73819. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73820. /**
  73821. * Manually render a set of post processes to a texture.
  73822. * @param postProcesses An array of post processes to be run.
  73823. * @param targetTexture The target texture to render to.
  73824. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73825. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73826. * @param lodLevel defines which lod of the texture to render to
  73827. */
  73828. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73829. /**
  73830. * Finalize the result of the output of the postprocesses.
  73831. * @param doNotPresent If true the result will not be displayed to the screen.
  73832. * @param targetTexture The target texture to render to.
  73833. * @param faceIndex The index of the face to bind the target texture to.
  73834. * @param postProcesses The array of post processes to render.
  73835. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73836. * @hidden
  73837. */
  73838. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73839. /**
  73840. * Disposes of the post process manager.
  73841. */
  73842. dispose(): void;
  73843. }
  73844. }
  73845. declare module BABYLON {
  73846. interface AbstractScene {
  73847. /**
  73848. * The list of layers (background and foreground) of the scene
  73849. */
  73850. layers: Array<Layer>;
  73851. }
  73852. /**
  73853. * Defines the layer scene component responsible to manage any layers
  73854. * in a given scene.
  73855. */
  73856. export class LayerSceneComponent implements ISceneComponent {
  73857. /**
  73858. * The component name helpfull to identify the component in the list of scene components.
  73859. */
  73860. readonly name: string;
  73861. /**
  73862. * The scene the component belongs to.
  73863. */
  73864. scene: Scene;
  73865. private _engine;
  73866. /**
  73867. * Creates a new instance of the component for the given scene
  73868. * @param scene Defines the scene to register the component in
  73869. */
  73870. constructor(scene: Scene);
  73871. /**
  73872. * Registers the component in a given scene
  73873. */
  73874. register(): void;
  73875. /**
  73876. * Rebuilds the elements related to this component in case of
  73877. * context lost for instance.
  73878. */
  73879. rebuild(): void;
  73880. /**
  73881. * Disposes the component and the associated ressources.
  73882. */
  73883. dispose(): void;
  73884. private _draw;
  73885. private _drawCameraPredicate;
  73886. private _drawCameraBackground;
  73887. private _drawCameraForeground;
  73888. private _drawRenderTargetPredicate;
  73889. private _drawRenderTargetBackground;
  73890. private _drawRenderTargetForeground;
  73891. }
  73892. }
  73893. declare module BABYLON {
  73894. /** @hidden */
  73895. export var layerPixelShader: {
  73896. name: string;
  73897. shader: string;
  73898. };
  73899. }
  73900. declare module BABYLON {
  73901. /** @hidden */
  73902. export var layerVertexShader: {
  73903. name: string;
  73904. shader: string;
  73905. };
  73906. }
  73907. declare module BABYLON {
  73908. /**
  73909. * This represents a full screen 2d layer.
  73910. * This can be useful to display a picture in the background of your scene for instance.
  73911. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73912. */
  73913. export class Layer {
  73914. /**
  73915. * Define the name of the layer.
  73916. */
  73917. name: string;
  73918. /**
  73919. * Define the texture the layer should display.
  73920. */
  73921. texture: Nullable<Texture>;
  73922. /**
  73923. * Is the layer in background or foreground.
  73924. */
  73925. isBackground: boolean;
  73926. /**
  73927. * Define the color of the layer (instead of texture).
  73928. */
  73929. color: Color4;
  73930. /**
  73931. * Define the scale of the layer in order to zoom in out of the texture.
  73932. */
  73933. scale: Vector2;
  73934. /**
  73935. * Define an offset for the layer in order to shift the texture.
  73936. */
  73937. offset: Vector2;
  73938. /**
  73939. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73940. */
  73941. alphaBlendingMode: number;
  73942. /**
  73943. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73944. * Alpha test will not mix with the background color in case of transparency.
  73945. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73946. */
  73947. alphaTest: boolean;
  73948. /**
  73949. * Define a mask to restrict the layer to only some of the scene cameras.
  73950. */
  73951. layerMask: number;
  73952. /**
  73953. * Define the list of render target the layer is visible into.
  73954. */
  73955. renderTargetTextures: RenderTargetTexture[];
  73956. /**
  73957. * Define if the layer is only used in renderTarget or if it also
  73958. * renders in the main frame buffer of the canvas.
  73959. */
  73960. renderOnlyInRenderTargetTextures: boolean;
  73961. private _scene;
  73962. private _vertexBuffers;
  73963. private _indexBuffer;
  73964. private _effect;
  73965. private _alphaTestEffect;
  73966. /**
  73967. * An event triggered when the layer is disposed.
  73968. */
  73969. onDisposeObservable: Observable<Layer>;
  73970. private _onDisposeObserver;
  73971. /**
  73972. * Back compatibility with callback before the onDisposeObservable existed.
  73973. * The set callback will be triggered when the layer has been disposed.
  73974. */
  73975. onDispose: () => void;
  73976. /**
  73977. * An event triggered before rendering the scene
  73978. */
  73979. onBeforeRenderObservable: Observable<Layer>;
  73980. private _onBeforeRenderObserver;
  73981. /**
  73982. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73983. * The set callback will be triggered just before rendering the layer.
  73984. */
  73985. onBeforeRender: () => void;
  73986. /**
  73987. * An event triggered after rendering the scene
  73988. */
  73989. onAfterRenderObservable: Observable<Layer>;
  73990. private _onAfterRenderObserver;
  73991. /**
  73992. * Back compatibility with callback before the onAfterRenderObservable existed.
  73993. * The set callback will be triggered just after rendering the layer.
  73994. */
  73995. onAfterRender: () => void;
  73996. /**
  73997. * Instantiates a new layer.
  73998. * This represents a full screen 2d layer.
  73999. * This can be useful to display a picture in the background of your scene for instance.
  74000. * @see https://www.babylonjs-playground.com/#08A2BS#1
  74001. * @param name Define the name of the layer in the scene
  74002. * @param imgUrl Define the url of the texture to display in the layer
  74003. * @param scene Define the scene the layer belongs to
  74004. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  74005. * @param color Defines a color for the layer
  74006. */
  74007. constructor(
  74008. /**
  74009. * Define the name of the layer.
  74010. */
  74011. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  74012. private _createIndexBuffer;
  74013. /** @hidden */
  74014. _rebuild(): void;
  74015. /**
  74016. * Renders the layer in the scene.
  74017. */
  74018. render(): void;
  74019. /**
  74020. * Disposes and releases the associated ressources.
  74021. */
  74022. dispose(): void;
  74023. }
  74024. }
  74025. declare module BABYLON {
  74026. interface AbstractScene {
  74027. /**
  74028. * The list of procedural textures added to the scene
  74029. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74030. */
  74031. proceduralTextures: Array<ProceduralTexture>;
  74032. }
  74033. /**
  74034. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  74035. * in a given scene.
  74036. */
  74037. export class ProceduralTextureSceneComponent implements ISceneComponent {
  74038. /**
  74039. * The component name helpfull to identify the component in the list of scene components.
  74040. */
  74041. readonly name: string;
  74042. /**
  74043. * The scene the component belongs to.
  74044. */
  74045. scene: Scene;
  74046. /**
  74047. * Creates a new instance of the component for the given scene
  74048. * @param scene Defines the scene to register the component in
  74049. */
  74050. constructor(scene: Scene);
  74051. /**
  74052. * Registers the component in a given scene
  74053. */
  74054. register(): void;
  74055. /**
  74056. * Rebuilds the elements related to this component in case of
  74057. * context lost for instance.
  74058. */
  74059. rebuild(): void;
  74060. /**
  74061. * Disposes the component and the associated ressources.
  74062. */
  74063. dispose(): void;
  74064. private _beforeClear;
  74065. }
  74066. }
  74067. declare module BABYLON {
  74068. interface Engine {
  74069. /**
  74070. * Creates a new render target cube texture
  74071. * @param size defines the size of the texture
  74072. * @param options defines the options used to create the texture
  74073. * @returns a new render target cube texture stored in an InternalTexture
  74074. */
  74075. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  74076. }
  74077. }
  74078. declare module BABYLON {
  74079. /** @hidden */
  74080. export var proceduralVertexShader: {
  74081. name: string;
  74082. shader: string;
  74083. };
  74084. }
  74085. declare module BABYLON {
  74086. /**
  74087. * 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.
  74088. * This is the base class of any Procedural texture and contains most of the shareable code.
  74089. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74090. */
  74091. export class ProceduralTexture extends Texture {
  74092. isCube: boolean;
  74093. /**
  74094. * Define if the texture is enabled or not (disabled texture will not render)
  74095. */
  74096. isEnabled: boolean;
  74097. /**
  74098. * Define if the texture must be cleared before rendering (default is true)
  74099. */
  74100. autoClear: boolean;
  74101. /**
  74102. * Callback called when the texture is generated
  74103. */
  74104. onGenerated: () => void;
  74105. /**
  74106. * Event raised when the texture is generated
  74107. */
  74108. onGeneratedObservable: Observable<ProceduralTexture>;
  74109. /** @hidden */
  74110. _generateMipMaps: boolean;
  74111. /** @hidden **/
  74112. _effect: Effect;
  74113. /** @hidden */
  74114. _textures: {
  74115. [key: string]: Texture;
  74116. };
  74117. private _size;
  74118. private _currentRefreshId;
  74119. private _refreshRate;
  74120. private _vertexBuffers;
  74121. private _indexBuffer;
  74122. private _uniforms;
  74123. private _samplers;
  74124. private _fragment;
  74125. private _floats;
  74126. private _ints;
  74127. private _floatsArrays;
  74128. private _colors3;
  74129. private _colors4;
  74130. private _vectors2;
  74131. private _vectors3;
  74132. private _matrices;
  74133. private _fallbackTexture;
  74134. private _fallbackTextureUsed;
  74135. private _engine;
  74136. private _cachedDefines;
  74137. private _contentUpdateId;
  74138. private _contentData;
  74139. /**
  74140. * Instantiates a new procedural texture.
  74141. * 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.
  74142. * This is the base class of any Procedural texture and contains most of the shareable code.
  74143. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74144. * @param name Define the name of the texture
  74145. * @param size Define the size of the texture to create
  74146. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  74147. * @param scene Define the scene the texture belongs to
  74148. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  74149. * @param generateMipMaps Define if the texture should creates mip maps or not
  74150. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  74151. */
  74152. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  74153. /**
  74154. * The effect that is created when initializing the post process.
  74155. * @returns The created effect corrisponding the the postprocess.
  74156. */
  74157. getEffect(): Effect;
  74158. /**
  74159. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  74160. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  74161. */
  74162. getContent(): Nullable<ArrayBufferView>;
  74163. private _createIndexBuffer;
  74164. /** @hidden */
  74165. _rebuild(): void;
  74166. /**
  74167. * Resets the texture in order to recreate its associated resources.
  74168. * This can be called in case of context loss
  74169. */
  74170. reset(): void;
  74171. protected _getDefines(): string;
  74172. /**
  74173. * Is the texture ready to be used ? (rendered at least once)
  74174. * @returns true if ready, otherwise, false.
  74175. */
  74176. isReady(): boolean;
  74177. /**
  74178. * Resets the refresh counter of the texture and start bak from scratch.
  74179. * Could be useful to regenerate the texture if it is setup to render only once.
  74180. */
  74181. resetRefreshCounter(): void;
  74182. /**
  74183. * Set the fragment shader to use in order to render the texture.
  74184. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  74185. */
  74186. setFragment(fragment: any): void;
  74187. /**
  74188. * Define the refresh rate of the texture or the rendering frequency.
  74189. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74190. */
  74191. refreshRate: number;
  74192. /** @hidden */
  74193. _shouldRender(): boolean;
  74194. /**
  74195. * Get the size the texture is rendering at.
  74196. * @returns the size (texture is always squared)
  74197. */
  74198. getRenderSize(): number;
  74199. /**
  74200. * Resize the texture to new value.
  74201. * @param size Define the new size the texture should have
  74202. * @param generateMipMaps Define whether the new texture should create mip maps
  74203. */
  74204. resize(size: number, generateMipMaps: boolean): void;
  74205. private _checkUniform;
  74206. /**
  74207. * Set a texture in the shader program used to render.
  74208. * @param name Define the name of the uniform samplers as defined in the shader
  74209. * @param texture Define the texture to bind to this sampler
  74210. * @return the texture itself allowing "fluent" like uniform updates
  74211. */
  74212. setTexture(name: string, texture: Texture): ProceduralTexture;
  74213. /**
  74214. * Set a float in the shader.
  74215. * @param name Define the name of the uniform as defined in the shader
  74216. * @param value Define the value to give to the uniform
  74217. * @return the texture itself allowing "fluent" like uniform updates
  74218. */
  74219. setFloat(name: string, value: number): ProceduralTexture;
  74220. /**
  74221. * Set a int in the shader.
  74222. * @param name Define the name of the uniform as defined in the shader
  74223. * @param value Define the value to give to the uniform
  74224. * @return the texture itself allowing "fluent" like uniform updates
  74225. */
  74226. setInt(name: string, value: number): ProceduralTexture;
  74227. /**
  74228. * Set an array of floats in the shader.
  74229. * @param name Define the name of the uniform as defined in the shader
  74230. * @param value Define the value to give to the uniform
  74231. * @return the texture itself allowing "fluent" like uniform updates
  74232. */
  74233. setFloats(name: string, value: number[]): ProceduralTexture;
  74234. /**
  74235. * Set a vec3 in the shader from a Color3.
  74236. * @param name Define the name of the uniform as defined in the shader
  74237. * @param value Define the value to give to the uniform
  74238. * @return the texture itself allowing "fluent" like uniform updates
  74239. */
  74240. setColor3(name: string, value: Color3): ProceduralTexture;
  74241. /**
  74242. * Set a vec4 in the shader from a Color4.
  74243. * @param name Define the name of the uniform as defined in the shader
  74244. * @param value Define the value to give to the uniform
  74245. * @return the texture itself allowing "fluent" like uniform updates
  74246. */
  74247. setColor4(name: string, value: Color4): ProceduralTexture;
  74248. /**
  74249. * Set a vec2 in the shader from a Vector2.
  74250. * @param name Define the name of the uniform as defined in the shader
  74251. * @param value Define the value to give to the uniform
  74252. * @return the texture itself allowing "fluent" like uniform updates
  74253. */
  74254. setVector2(name: string, value: Vector2): ProceduralTexture;
  74255. /**
  74256. * Set a vec3 in the shader from a Vector3.
  74257. * @param name Define the name of the uniform as defined in the shader
  74258. * @param value Define the value to give to the uniform
  74259. * @return the texture itself allowing "fluent" like uniform updates
  74260. */
  74261. setVector3(name: string, value: Vector3): ProceduralTexture;
  74262. /**
  74263. * Set a mat4 in the shader from a MAtrix.
  74264. * @param name Define the name of the uniform as defined in the shader
  74265. * @param value Define the value to give to the uniform
  74266. * @return the texture itself allowing "fluent" like uniform updates
  74267. */
  74268. setMatrix(name: string, value: Matrix): ProceduralTexture;
  74269. /**
  74270. * Render the texture to its associated render target.
  74271. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  74272. */
  74273. render(useCameraPostProcess?: boolean): void;
  74274. /**
  74275. * Clone the texture.
  74276. * @returns the cloned texture
  74277. */
  74278. clone(): ProceduralTexture;
  74279. /**
  74280. * Dispose the texture and release its asoociated resources.
  74281. */
  74282. dispose(): void;
  74283. }
  74284. }
  74285. declare module BABYLON {
  74286. /**
  74287. * This represents the base class for particle system in Babylon.
  74288. * 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.
  74289. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74290. * @example https://doc.babylonjs.com/babylon101/particles
  74291. */
  74292. export class BaseParticleSystem {
  74293. /**
  74294. * Source color is added to the destination color without alpha affecting the result
  74295. */
  74296. static BLENDMODE_ONEONE: number;
  74297. /**
  74298. * Blend current color and particle color using particle’s alpha
  74299. */
  74300. static BLENDMODE_STANDARD: number;
  74301. /**
  74302. * Add current color and particle color multiplied by particle’s alpha
  74303. */
  74304. static BLENDMODE_ADD: number;
  74305. /**
  74306. * Multiply current color with particle color
  74307. */
  74308. static BLENDMODE_MULTIPLY: number;
  74309. /**
  74310. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  74311. */
  74312. static BLENDMODE_MULTIPLYADD: number;
  74313. /**
  74314. * List of animations used by the particle system.
  74315. */
  74316. animations: Animation[];
  74317. /**
  74318. * The id of the Particle system.
  74319. */
  74320. id: string;
  74321. /**
  74322. * The friendly name of the Particle system.
  74323. */
  74324. name: string;
  74325. /**
  74326. * The rendering group used by the Particle system to chose when to render.
  74327. */
  74328. renderingGroupId: number;
  74329. /**
  74330. * The emitter represents the Mesh or position we are attaching the particle system to.
  74331. */
  74332. emitter: Nullable<AbstractMesh | Vector3>;
  74333. /**
  74334. * The maximum number of particles to emit per frame
  74335. */
  74336. emitRate: number;
  74337. /**
  74338. * If you want to launch only a few particles at once, that can be done, as well.
  74339. */
  74340. manualEmitCount: number;
  74341. /**
  74342. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74343. */
  74344. updateSpeed: number;
  74345. /**
  74346. * The amount of time the particle system is running (depends of the overall update speed).
  74347. */
  74348. targetStopDuration: number;
  74349. /**
  74350. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74351. */
  74352. disposeOnStop: boolean;
  74353. /**
  74354. * Minimum power of emitting particles.
  74355. */
  74356. minEmitPower: number;
  74357. /**
  74358. * Maximum power of emitting particles.
  74359. */
  74360. maxEmitPower: number;
  74361. /**
  74362. * Minimum life time of emitting particles.
  74363. */
  74364. minLifeTime: number;
  74365. /**
  74366. * Maximum life time of emitting particles.
  74367. */
  74368. maxLifeTime: number;
  74369. /**
  74370. * Minimum Size of emitting particles.
  74371. */
  74372. minSize: number;
  74373. /**
  74374. * Maximum Size of emitting particles.
  74375. */
  74376. maxSize: number;
  74377. /**
  74378. * Minimum scale of emitting particles on X axis.
  74379. */
  74380. minScaleX: number;
  74381. /**
  74382. * Maximum scale of emitting particles on X axis.
  74383. */
  74384. maxScaleX: number;
  74385. /**
  74386. * Minimum scale of emitting particles on Y axis.
  74387. */
  74388. minScaleY: number;
  74389. /**
  74390. * Maximum scale of emitting particles on Y axis.
  74391. */
  74392. maxScaleY: number;
  74393. /**
  74394. * Gets or sets the minimal initial rotation in radians.
  74395. */
  74396. minInitialRotation: number;
  74397. /**
  74398. * Gets or sets the maximal initial rotation in radians.
  74399. */
  74400. maxInitialRotation: number;
  74401. /**
  74402. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74403. */
  74404. minAngularSpeed: number;
  74405. /**
  74406. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74407. */
  74408. maxAngularSpeed: number;
  74409. /**
  74410. * The texture used to render each particle. (this can be a spritesheet)
  74411. */
  74412. particleTexture: Nullable<Texture>;
  74413. /**
  74414. * The layer mask we are rendering the particles through.
  74415. */
  74416. layerMask: number;
  74417. /**
  74418. * This can help using your own shader to render the particle system.
  74419. * The according effect will be created
  74420. */
  74421. customShader: any;
  74422. /**
  74423. * By default particle system starts as soon as they are created. This prevents the
  74424. * automatic start to happen and let you decide when to start emitting particles.
  74425. */
  74426. preventAutoStart: boolean;
  74427. private _noiseTexture;
  74428. /**
  74429. * Gets or sets a texture used to add random noise to particle positions
  74430. */
  74431. noiseTexture: Nullable<ProceduralTexture>;
  74432. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74433. noiseStrength: Vector3;
  74434. /**
  74435. * Callback triggered when the particle animation is ending.
  74436. */
  74437. onAnimationEnd: Nullable<() => void>;
  74438. /**
  74439. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74440. */
  74441. blendMode: number;
  74442. /**
  74443. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74444. * to override the particles.
  74445. */
  74446. forceDepthWrite: boolean;
  74447. /** 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 */
  74448. preWarmCycles: number;
  74449. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74450. preWarmStepOffset: number;
  74451. /**
  74452. * 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)
  74453. */
  74454. spriteCellChangeSpeed: number;
  74455. /**
  74456. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74457. */
  74458. startSpriteCellID: number;
  74459. /**
  74460. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74461. */
  74462. endSpriteCellID: number;
  74463. /**
  74464. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74465. */
  74466. spriteCellWidth: number;
  74467. /**
  74468. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74469. */
  74470. spriteCellHeight: number;
  74471. /**
  74472. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74473. */
  74474. spriteRandomStartCell: boolean;
  74475. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74476. translationPivot: Vector2;
  74477. /** @hidden */
  74478. protected _isAnimationSheetEnabled: boolean;
  74479. /**
  74480. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74481. */
  74482. beginAnimationOnStart: boolean;
  74483. /**
  74484. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74485. */
  74486. beginAnimationFrom: number;
  74487. /**
  74488. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74489. */
  74490. beginAnimationTo: number;
  74491. /**
  74492. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74493. */
  74494. beginAnimationLoop: boolean;
  74495. /**
  74496. * Gets or sets a world offset applied to all particles
  74497. */
  74498. worldOffset: Vector3;
  74499. /**
  74500. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74501. */
  74502. isAnimationSheetEnabled: boolean;
  74503. /**
  74504. * Get hosting scene
  74505. * @returns the scene
  74506. */
  74507. getScene(): Scene;
  74508. /**
  74509. * You can use gravity if you want to give an orientation to your particles.
  74510. */
  74511. gravity: Vector3;
  74512. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74513. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74514. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74515. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74516. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74517. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74518. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74519. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74520. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74521. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74522. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74523. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74524. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74525. /**
  74526. * Defines the delay in milliseconds before starting the system (0 by default)
  74527. */
  74528. startDelay: number;
  74529. /**
  74530. * Gets the current list of drag gradients.
  74531. * You must use addDragGradient and removeDragGradient to udpate this list
  74532. * @returns the list of drag gradients
  74533. */
  74534. getDragGradients(): Nullable<Array<FactorGradient>>;
  74535. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74536. limitVelocityDamping: number;
  74537. /**
  74538. * Gets the current list of limit velocity gradients.
  74539. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74540. * @returns the list of limit velocity gradients
  74541. */
  74542. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74543. /**
  74544. * Gets the current list of color gradients.
  74545. * You must use addColorGradient and removeColorGradient to udpate this list
  74546. * @returns the list of color gradients
  74547. */
  74548. getColorGradients(): Nullable<Array<ColorGradient>>;
  74549. /**
  74550. * Gets the current list of size gradients.
  74551. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74552. * @returns the list of size gradients
  74553. */
  74554. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74555. /**
  74556. * Gets the current list of color remap gradients.
  74557. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74558. * @returns the list of color remap gradients
  74559. */
  74560. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74561. /**
  74562. * Gets the current list of alpha remap gradients.
  74563. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74564. * @returns the list of alpha remap gradients
  74565. */
  74566. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74567. /**
  74568. * Gets the current list of life time gradients.
  74569. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74570. * @returns the list of life time gradients
  74571. */
  74572. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74573. /**
  74574. * Gets the current list of angular speed gradients.
  74575. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74576. * @returns the list of angular speed gradients
  74577. */
  74578. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74579. /**
  74580. * Gets the current list of velocity gradients.
  74581. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74582. * @returns the list of velocity gradients
  74583. */
  74584. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74585. /**
  74586. * Gets the current list of start size gradients.
  74587. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74588. * @returns the list of start size gradients
  74589. */
  74590. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74591. /**
  74592. * Gets the current list of emit rate gradients.
  74593. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74594. * @returns the list of emit rate gradients
  74595. */
  74596. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74597. /**
  74598. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74599. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74600. */
  74601. direction1: Vector3;
  74602. /**
  74603. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74604. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74605. */
  74606. direction2: Vector3;
  74607. /**
  74608. * 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.
  74609. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74610. */
  74611. minEmitBox: Vector3;
  74612. /**
  74613. * 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.
  74614. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74615. */
  74616. maxEmitBox: Vector3;
  74617. /**
  74618. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74619. */
  74620. color1: Color4;
  74621. /**
  74622. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74623. */
  74624. color2: Color4;
  74625. /**
  74626. * Color the particle will have at the end of its lifetime
  74627. */
  74628. colorDead: Color4;
  74629. /**
  74630. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74631. */
  74632. textureMask: Color4;
  74633. /**
  74634. * The particle emitter type defines the emitter used by the particle system.
  74635. * It can be for example box, sphere, or cone...
  74636. */
  74637. particleEmitterType: IParticleEmitterType;
  74638. /** @hidden */
  74639. _isSubEmitter: boolean;
  74640. /**
  74641. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74642. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74643. */
  74644. billboardMode: number;
  74645. protected _isBillboardBased: boolean;
  74646. /**
  74647. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74648. */
  74649. isBillboardBased: boolean;
  74650. /**
  74651. * The scene the particle system belongs to.
  74652. */
  74653. protected _scene: Scene;
  74654. /**
  74655. * Local cache of defines for image processing.
  74656. */
  74657. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74658. /**
  74659. * Default configuration related to image processing available in the standard Material.
  74660. */
  74661. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74662. /**
  74663. * Gets the image processing configuration used either in this material.
  74664. */
  74665. /**
  74666. * Sets the Default image processing configuration used either in the this material.
  74667. *
  74668. * If sets to null, the scene one is in use.
  74669. */
  74670. imageProcessingConfiguration: ImageProcessingConfiguration;
  74671. /**
  74672. * Attaches a new image processing configuration to the Standard Material.
  74673. * @param configuration
  74674. */
  74675. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74676. /** @hidden */
  74677. protected _reset(): void;
  74678. /** @hidden */
  74679. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74680. /**
  74681. * Instantiates a particle system.
  74682. * 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.
  74683. * @param name The name of the particle system
  74684. */
  74685. constructor(name: string);
  74686. /**
  74687. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74688. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74689. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74690. * @returns the emitter
  74691. */
  74692. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74693. /**
  74694. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74695. * @param radius The radius of the hemisphere to emit from
  74696. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74697. * @returns the emitter
  74698. */
  74699. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74700. /**
  74701. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74702. * @param radius The radius of the sphere to emit from
  74703. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74704. * @returns the emitter
  74705. */
  74706. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74707. /**
  74708. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74709. * @param radius The radius of the sphere to emit from
  74710. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74711. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74712. * @returns the emitter
  74713. */
  74714. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74715. /**
  74716. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74717. * @param radius The radius of the emission cylinder
  74718. * @param height The height of the emission cylinder
  74719. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74720. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74721. * @returns the emitter
  74722. */
  74723. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74724. /**
  74725. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74726. * @param radius The radius of the cylinder to emit from
  74727. * @param height The height of the emission cylinder
  74728. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74729. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74730. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74731. * @returns the emitter
  74732. */
  74733. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74734. /**
  74735. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74736. * @param radius The radius of the cone to emit from
  74737. * @param angle The base angle of the cone
  74738. * @returns the emitter
  74739. */
  74740. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74741. /**
  74742. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74743. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74744. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74745. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74746. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74747. * @returns the emitter
  74748. */
  74749. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74750. }
  74751. }
  74752. declare module BABYLON {
  74753. /**
  74754. * Type of sub emitter
  74755. */
  74756. export enum SubEmitterType {
  74757. /**
  74758. * Attached to the particle over it's lifetime
  74759. */
  74760. ATTACHED = 0,
  74761. /**
  74762. * Created when the particle dies
  74763. */
  74764. END = 1
  74765. }
  74766. /**
  74767. * Sub emitter class used to emit particles from an existing particle
  74768. */
  74769. export class SubEmitter {
  74770. /**
  74771. * the particle system to be used by the sub emitter
  74772. */
  74773. particleSystem: ParticleSystem;
  74774. /**
  74775. * Type of the submitter (Default: END)
  74776. */
  74777. type: SubEmitterType;
  74778. /**
  74779. * 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)
  74780. * Note: This only is supported when using an emitter of type Mesh
  74781. */
  74782. inheritDirection: boolean;
  74783. /**
  74784. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74785. */
  74786. inheritedVelocityAmount: number;
  74787. /**
  74788. * Creates a sub emitter
  74789. * @param particleSystem the particle system to be used by the sub emitter
  74790. */
  74791. constructor(
  74792. /**
  74793. * the particle system to be used by the sub emitter
  74794. */
  74795. particleSystem: ParticleSystem);
  74796. /**
  74797. * Clones the sub emitter
  74798. * @returns the cloned sub emitter
  74799. */
  74800. clone(): SubEmitter;
  74801. /**
  74802. * Serialize current object to a JSON object
  74803. * @returns the serialized object
  74804. */
  74805. serialize(): any;
  74806. /** @hidden */
  74807. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74808. /**
  74809. * Creates a new SubEmitter from a serialized JSON version
  74810. * @param serializationObject defines the JSON object to read from
  74811. * @param scene defines the hosting scene
  74812. * @param rootUrl defines the rootUrl for data loading
  74813. * @returns a new SubEmitter
  74814. */
  74815. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74816. /** Release associated resources */
  74817. dispose(): void;
  74818. }
  74819. }
  74820. declare module BABYLON {
  74821. /** @hidden */
  74822. export var clipPlaneFragmentDeclaration: {
  74823. name: string;
  74824. shader: string;
  74825. };
  74826. }
  74827. declare module BABYLON {
  74828. /** @hidden */
  74829. export var imageProcessingDeclaration: {
  74830. name: string;
  74831. shader: string;
  74832. };
  74833. }
  74834. declare module BABYLON {
  74835. /** @hidden */
  74836. export var imageProcessingFunctions: {
  74837. name: string;
  74838. shader: string;
  74839. };
  74840. }
  74841. declare module BABYLON {
  74842. /** @hidden */
  74843. export var clipPlaneFragment: {
  74844. name: string;
  74845. shader: string;
  74846. };
  74847. }
  74848. declare module BABYLON {
  74849. /** @hidden */
  74850. export var particlesPixelShader: {
  74851. name: string;
  74852. shader: string;
  74853. };
  74854. }
  74855. declare module BABYLON {
  74856. /** @hidden */
  74857. export var clipPlaneVertexDeclaration: {
  74858. name: string;
  74859. shader: string;
  74860. };
  74861. }
  74862. declare module BABYLON {
  74863. /** @hidden */
  74864. export var clipPlaneVertex: {
  74865. name: string;
  74866. shader: string;
  74867. };
  74868. }
  74869. declare module BABYLON {
  74870. /** @hidden */
  74871. export var particlesVertexShader: {
  74872. name: string;
  74873. shader: string;
  74874. };
  74875. }
  74876. declare module BABYLON {
  74877. /**
  74878. * This represents a particle system in Babylon.
  74879. * 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.
  74880. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74881. * @example https://doc.babylonjs.com/babylon101/particles
  74882. */
  74883. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74884. /**
  74885. * Billboard mode will only apply to Y axis
  74886. */
  74887. static readonly BILLBOARDMODE_Y: number;
  74888. /**
  74889. * Billboard mode will apply to all axes
  74890. */
  74891. static readonly BILLBOARDMODE_ALL: number;
  74892. /**
  74893. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74894. */
  74895. static readonly BILLBOARDMODE_STRETCHED: number;
  74896. /**
  74897. * This function can be defined to provide custom update for active particles.
  74898. * This function will be called instead of regular update (age, position, color, etc.).
  74899. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74900. */
  74901. updateFunction: (particles: Particle[]) => void;
  74902. private _emitterWorldMatrix;
  74903. /**
  74904. * This function can be defined to specify initial direction for every new particle.
  74905. * It by default use the emitterType defined function
  74906. */
  74907. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74908. /**
  74909. * This function can be defined to specify initial position for every new particle.
  74910. * It by default use the emitterType defined function
  74911. */
  74912. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74913. /**
  74914. * @hidden
  74915. */
  74916. _inheritedVelocityOffset: Vector3;
  74917. /**
  74918. * An event triggered when the system is disposed
  74919. */
  74920. onDisposeObservable: Observable<ParticleSystem>;
  74921. private _onDisposeObserver;
  74922. /**
  74923. * Sets a callback that will be triggered when the system is disposed
  74924. */
  74925. onDispose: () => void;
  74926. private _particles;
  74927. private _epsilon;
  74928. private _capacity;
  74929. private _stockParticles;
  74930. private _newPartsExcess;
  74931. private _vertexData;
  74932. private _vertexBuffer;
  74933. private _vertexBuffers;
  74934. private _spriteBuffer;
  74935. private _indexBuffer;
  74936. private _effect;
  74937. private _customEffect;
  74938. private _cachedDefines;
  74939. private _scaledColorStep;
  74940. private _colorDiff;
  74941. private _scaledDirection;
  74942. private _scaledGravity;
  74943. private _currentRenderId;
  74944. private _alive;
  74945. private _useInstancing;
  74946. private _started;
  74947. private _stopped;
  74948. private _actualFrame;
  74949. private _scaledUpdateSpeed;
  74950. private _vertexBufferSize;
  74951. /** @hidden */
  74952. _currentEmitRateGradient: Nullable<FactorGradient>;
  74953. /** @hidden */
  74954. _currentEmitRate1: number;
  74955. /** @hidden */
  74956. _currentEmitRate2: number;
  74957. /** @hidden */
  74958. _currentStartSizeGradient: Nullable<FactorGradient>;
  74959. /** @hidden */
  74960. _currentStartSize1: number;
  74961. /** @hidden */
  74962. _currentStartSize2: number;
  74963. private readonly _rawTextureWidth;
  74964. private _rampGradientsTexture;
  74965. private _useRampGradients;
  74966. /** Gets or sets a boolean indicating that ramp gradients must be used
  74967. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74968. */
  74969. useRampGradients: boolean;
  74970. /**
  74971. * 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.
  74972. * 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: [])
  74973. */
  74974. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74975. private _subEmitters;
  74976. /**
  74977. * @hidden
  74978. * If the particle systems emitter should be disposed when the particle system is disposed
  74979. */
  74980. _disposeEmitterOnDispose: boolean;
  74981. /**
  74982. * The current active Sub-systems, this property is used by the root particle system only.
  74983. */
  74984. activeSubSystems: Array<ParticleSystem>;
  74985. private _rootParticleSystem;
  74986. /**
  74987. * Gets the current list of active particles
  74988. */
  74989. readonly particles: Particle[];
  74990. /**
  74991. * Returns the string "ParticleSystem"
  74992. * @returns a string containing the class name
  74993. */
  74994. getClassName(): string;
  74995. /**
  74996. * Instantiates a particle system.
  74997. * 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.
  74998. * @param name The name of the particle system
  74999. * @param capacity The max number of particles alive at the same time
  75000. * @param scene The scene the particle system belongs to
  75001. * @param customEffect a custom effect used to change the way particles are rendered by default
  75002. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  75003. * @param epsilon Offset used to render the particles
  75004. */
  75005. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  75006. private _addFactorGradient;
  75007. private _removeFactorGradient;
  75008. /**
  75009. * Adds a new life time gradient
  75010. * @param gradient defines the gradient to use (between 0 and 1)
  75011. * @param factor defines the life time factor to affect to the specified gradient
  75012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75013. * @returns the current particle system
  75014. */
  75015. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75016. /**
  75017. * Remove a specific life time gradient
  75018. * @param gradient defines the gradient to remove
  75019. * @returns the current particle system
  75020. */
  75021. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75022. /**
  75023. * Adds a new size gradient
  75024. * @param gradient defines the gradient to use (between 0 and 1)
  75025. * @param factor defines the size factor to affect to the specified gradient
  75026. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75027. * @returns the current particle system
  75028. */
  75029. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75030. /**
  75031. * Remove a specific size gradient
  75032. * @param gradient defines the gradient to remove
  75033. * @returns the current particle system
  75034. */
  75035. removeSizeGradient(gradient: number): IParticleSystem;
  75036. /**
  75037. * Adds a new color remap gradient
  75038. * @param gradient defines the gradient to use (between 0 and 1)
  75039. * @param min defines the color remap minimal range
  75040. * @param max defines the color remap maximal range
  75041. * @returns the current particle system
  75042. */
  75043. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75044. /**
  75045. * Remove a specific color remap gradient
  75046. * @param gradient defines the gradient to remove
  75047. * @returns the current particle system
  75048. */
  75049. removeColorRemapGradient(gradient: number): IParticleSystem;
  75050. /**
  75051. * Adds a new alpha remap gradient
  75052. * @param gradient defines the gradient to use (between 0 and 1)
  75053. * @param min defines the alpha remap minimal range
  75054. * @param max defines the alpha remap maximal range
  75055. * @returns the current particle system
  75056. */
  75057. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75058. /**
  75059. * Remove a specific alpha remap gradient
  75060. * @param gradient defines the gradient to remove
  75061. * @returns the current particle system
  75062. */
  75063. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  75064. /**
  75065. * Adds a new angular speed gradient
  75066. * @param gradient defines the gradient to use (between 0 and 1)
  75067. * @param factor defines the angular speed to affect to the specified gradient
  75068. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75069. * @returns the current particle system
  75070. */
  75071. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75072. /**
  75073. * Remove a specific angular speed gradient
  75074. * @param gradient defines the gradient to remove
  75075. * @returns the current particle system
  75076. */
  75077. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75078. /**
  75079. * Adds a new velocity gradient
  75080. * @param gradient defines the gradient to use (between 0 and 1)
  75081. * @param factor defines the velocity to affect to the specified gradient
  75082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75083. * @returns the current particle system
  75084. */
  75085. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75086. /**
  75087. * Remove a specific velocity gradient
  75088. * @param gradient defines the gradient to remove
  75089. * @returns the current particle system
  75090. */
  75091. removeVelocityGradient(gradient: number): IParticleSystem;
  75092. /**
  75093. * Adds a new limit velocity gradient
  75094. * @param gradient defines the gradient to use (between 0 and 1)
  75095. * @param factor defines the limit velocity value to affect to the specified gradient
  75096. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75097. * @returns the current particle system
  75098. */
  75099. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75100. /**
  75101. * Remove a specific limit velocity gradient
  75102. * @param gradient defines the gradient to remove
  75103. * @returns the current particle system
  75104. */
  75105. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75106. /**
  75107. * Adds a new drag gradient
  75108. * @param gradient defines the gradient to use (between 0 and 1)
  75109. * @param factor defines the drag value to affect to the specified gradient
  75110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75111. * @returns the current particle system
  75112. */
  75113. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75114. /**
  75115. * Remove a specific drag gradient
  75116. * @param gradient defines the gradient to remove
  75117. * @returns the current particle system
  75118. */
  75119. removeDragGradient(gradient: number): IParticleSystem;
  75120. /**
  75121. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75122. * @param gradient defines the gradient to use (between 0 and 1)
  75123. * @param factor defines the emit rate value to affect to the specified gradient
  75124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75125. * @returns the current particle system
  75126. */
  75127. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75128. /**
  75129. * Remove a specific emit rate gradient
  75130. * @param gradient defines the gradient to remove
  75131. * @returns the current particle system
  75132. */
  75133. removeEmitRateGradient(gradient: number): IParticleSystem;
  75134. /**
  75135. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75136. * @param gradient defines the gradient to use (between 0 and 1)
  75137. * @param factor defines the start size value to affect to the specified gradient
  75138. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75139. * @returns the current particle system
  75140. */
  75141. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75142. /**
  75143. * Remove a specific start size gradient
  75144. * @param gradient defines the gradient to remove
  75145. * @returns the current particle system
  75146. */
  75147. removeStartSizeGradient(gradient: number): IParticleSystem;
  75148. private _createRampGradientTexture;
  75149. /**
  75150. * Gets the current list of ramp gradients.
  75151. * You must use addRampGradient and removeRampGradient to udpate this list
  75152. * @returns the list of ramp gradients
  75153. */
  75154. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75155. /**
  75156. * Adds a new ramp gradient used to remap particle colors
  75157. * @param gradient defines the gradient to use (between 0 and 1)
  75158. * @param color defines the color to affect to the specified gradient
  75159. * @returns the current particle system
  75160. */
  75161. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  75162. /**
  75163. * Remove a specific ramp gradient
  75164. * @param gradient defines the gradient to remove
  75165. * @returns the current particle system
  75166. */
  75167. removeRampGradient(gradient: number): ParticleSystem;
  75168. /**
  75169. * Adds a new color gradient
  75170. * @param gradient defines the gradient to use (between 0 and 1)
  75171. * @param color1 defines the color to affect to the specified gradient
  75172. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75173. * @returns this particle system
  75174. */
  75175. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75176. /**
  75177. * Remove a specific color gradient
  75178. * @param gradient defines the gradient to remove
  75179. * @returns this particle system
  75180. */
  75181. removeColorGradient(gradient: number): IParticleSystem;
  75182. private _fetchR;
  75183. protected _reset(): void;
  75184. private _resetEffect;
  75185. private _createVertexBuffers;
  75186. private _createIndexBuffer;
  75187. /**
  75188. * Gets the maximum number of particles active at the same time.
  75189. * @returns The max number of active particles.
  75190. */
  75191. getCapacity(): number;
  75192. /**
  75193. * Gets whether there are still active particles in the system.
  75194. * @returns True if it is alive, otherwise false.
  75195. */
  75196. isAlive(): boolean;
  75197. /**
  75198. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75199. * @returns True if it has been started, otherwise false.
  75200. */
  75201. isStarted(): boolean;
  75202. private _prepareSubEmitterInternalArray;
  75203. /**
  75204. * Starts the particle system and begins to emit
  75205. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75206. */
  75207. start(delay?: number): void;
  75208. /**
  75209. * Stops the particle system.
  75210. * @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.
  75211. */
  75212. stop(stopSubEmitters?: boolean): void;
  75213. /**
  75214. * Remove all active particles
  75215. */
  75216. reset(): void;
  75217. /**
  75218. * @hidden (for internal use only)
  75219. */
  75220. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  75221. /**
  75222. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  75223. * Its lifetime will start back at 0.
  75224. */
  75225. recycleParticle: (particle: Particle) => void;
  75226. private _stopSubEmitters;
  75227. private _createParticle;
  75228. private _removeFromRoot;
  75229. private _emitFromParticle;
  75230. private _update;
  75231. /** @hidden */
  75232. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  75233. /** @hidden */
  75234. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  75235. /** @hidden */
  75236. private _getEffect;
  75237. /**
  75238. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75239. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  75240. */
  75241. animate(preWarmOnly?: boolean): void;
  75242. private _appendParticleVertices;
  75243. /**
  75244. * Rebuilds the particle system.
  75245. */
  75246. rebuild(): void;
  75247. /**
  75248. * Is this system ready to be used/rendered
  75249. * @return true if the system is ready
  75250. */
  75251. isReady(): boolean;
  75252. private _render;
  75253. /**
  75254. * Renders the particle system in its current state.
  75255. * @returns the current number of particles
  75256. */
  75257. render(): number;
  75258. /**
  75259. * Disposes the particle system and free the associated resources
  75260. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75261. */
  75262. dispose(disposeTexture?: boolean): void;
  75263. /**
  75264. * Clones the particle system.
  75265. * @param name The name of the cloned object
  75266. * @param newEmitter The new emitter to use
  75267. * @returns the cloned particle system
  75268. */
  75269. clone(name: string, newEmitter: any): ParticleSystem;
  75270. /**
  75271. * Serializes the particle system to a JSON object.
  75272. * @returns the JSON object
  75273. */
  75274. serialize(): any;
  75275. /** @hidden */
  75276. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  75277. /** @hidden */
  75278. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  75279. /**
  75280. * Parses a JSON object to create a particle system.
  75281. * @param parsedParticleSystem The JSON object to parse
  75282. * @param scene The scene to create the particle system in
  75283. * @param rootUrl The root url to use to load external dependencies like texture
  75284. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75285. * @returns the Parsed particle system
  75286. */
  75287. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  75288. }
  75289. }
  75290. declare module BABYLON {
  75291. /**
  75292. * A particle represents one of the element emitted by a particle system.
  75293. * This is mainly define by its coordinates, direction, velocity and age.
  75294. */
  75295. export class Particle {
  75296. /**
  75297. * The particle system the particle belongs to.
  75298. */
  75299. particleSystem: ParticleSystem;
  75300. private static _Count;
  75301. /**
  75302. * Unique ID of the particle
  75303. */
  75304. id: number;
  75305. /**
  75306. * The world position of the particle in the scene.
  75307. */
  75308. position: Vector3;
  75309. /**
  75310. * The world direction of the particle in the scene.
  75311. */
  75312. direction: Vector3;
  75313. /**
  75314. * The color of the particle.
  75315. */
  75316. color: Color4;
  75317. /**
  75318. * The color change of the particle per step.
  75319. */
  75320. colorStep: Color4;
  75321. /**
  75322. * Defines how long will the life of the particle be.
  75323. */
  75324. lifeTime: number;
  75325. /**
  75326. * The current age of the particle.
  75327. */
  75328. age: number;
  75329. /**
  75330. * The current size of the particle.
  75331. */
  75332. size: number;
  75333. /**
  75334. * The current scale of the particle.
  75335. */
  75336. scale: Vector2;
  75337. /**
  75338. * The current angle of the particle.
  75339. */
  75340. angle: number;
  75341. /**
  75342. * Defines how fast is the angle changing.
  75343. */
  75344. angularSpeed: number;
  75345. /**
  75346. * Defines the cell index used by the particle to be rendered from a sprite.
  75347. */
  75348. cellIndex: number;
  75349. /**
  75350. * The information required to support color remapping
  75351. */
  75352. remapData: Vector4;
  75353. /** @hidden */
  75354. _randomCellOffset?: number;
  75355. /** @hidden */
  75356. _initialDirection: Nullable<Vector3>;
  75357. /** @hidden */
  75358. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  75359. /** @hidden */
  75360. _initialStartSpriteCellID: number;
  75361. /** @hidden */
  75362. _initialEndSpriteCellID: number;
  75363. /** @hidden */
  75364. _currentColorGradient: Nullable<ColorGradient>;
  75365. /** @hidden */
  75366. _currentColor1: Color4;
  75367. /** @hidden */
  75368. _currentColor2: Color4;
  75369. /** @hidden */
  75370. _currentSizeGradient: Nullable<FactorGradient>;
  75371. /** @hidden */
  75372. _currentSize1: number;
  75373. /** @hidden */
  75374. _currentSize2: number;
  75375. /** @hidden */
  75376. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  75377. /** @hidden */
  75378. _currentAngularSpeed1: number;
  75379. /** @hidden */
  75380. _currentAngularSpeed2: number;
  75381. /** @hidden */
  75382. _currentVelocityGradient: Nullable<FactorGradient>;
  75383. /** @hidden */
  75384. _currentVelocity1: number;
  75385. /** @hidden */
  75386. _currentVelocity2: number;
  75387. /** @hidden */
  75388. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  75389. /** @hidden */
  75390. _currentLimitVelocity1: number;
  75391. /** @hidden */
  75392. _currentLimitVelocity2: number;
  75393. /** @hidden */
  75394. _currentDragGradient: Nullable<FactorGradient>;
  75395. /** @hidden */
  75396. _currentDrag1: number;
  75397. /** @hidden */
  75398. _currentDrag2: number;
  75399. /** @hidden */
  75400. _randomNoiseCoordinates1: Vector3;
  75401. /** @hidden */
  75402. _randomNoiseCoordinates2: Vector3;
  75403. /**
  75404. * Creates a new instance Particle
  75405. * @param particleSystem the particle system the particle belongs to
  75406. */
  75407. constructor(
  75408. /**
  75409. * The particle system the particle belongs to.
  75410. */
  75411. particleSystem: ParticleSystem);
  75412. private updateCellInfoFromSystem;
  75413. /**
  75414. * Defines how the sprite cell index is updated for the particle
  75415. */
  75416. updateCellIndex(): void;
  75417. /** @hidden */
  75418. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  75419. /** @hidden */
  75420. _inheritParticleInfoToSubEmitters(): void;
  75421. /** @hidden */
  75422. _reset(): void;
  75423. /**
  75424. * Copy the properties of particle to another one.
  75425. * @param other the particle to copy the information to.
  75426. */
  75427. copyTo(other: Particle): void;
  75428. }
  75429. }
  75430. declare module BABYLON {
  75431. /**
  75432. * Particle emitter represents a volume emitting particles.
  75433. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75434. */
  75435. export interface IParticleEmitterType {
  75436. /**
  75437. * Called by the particle System when the direction is computed for the created particle.
  75438. * @param worldMatrix is the world matrix of the particle system
  75439. * @param directionToUpdate is the direction vector to update with the result
  75440. * @param particle is the particle we are computed the direction for
  75441. */
  75442. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75443. /**
  75444. * Called by the particle System when the position is computed for the created particle.
  75445. * @param worldMatrix is the world matrix of the particle system
  75446. * @param positionToUpdate is the position vector to update with the result
  75447. * @param particle is the particle we are computed the position for
  75448. */
  75449. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75450. /**
  75451. * Clones the current emitter and returns a copy of it
  75452. * @returns the new emitter
  75453. */
  75454. clone(): IParticleEmitterType;
  75455. /**
  75456. * Called by the GPUParticleSystem to setup the update shader
  75457. * @param effect defines the update shader
  75458. */
  75459. applyToShader(effect: Effect): void;
  75460. /**
  75461. * Returns a string to use to update the GPU particles update shader
  75462. * @returns the effect defines string
  75463. */
  75464. getEffectDefines(): string;
  75465. /**
  75466. * Returns a string representing the class name
  75467. * @returns a string containing the class name
  75468. */
  75469. getClassName(): string;
  75470. /**
  75471. * Serializes the particle system to a JSON object.
  75472. * @returns the JSON object
  75473. */
  75474. serialize(): any;
  75475. /**
  75476. * Parse properties from a JSON object
  75477. * @param serializationObject defines the JSON object
  75478. */
  75479. parse(serializationObject: any): void;
  75480. }
  75481. }
  75482. declare module BABYLON {
  75483. /**
  75484. * Particle emitter emitting particles from the inside of a box.
  75485. * It emits the particles randomly between 2 given directions.
  75486. */
  75487. export class BoxParticleEmitter implements IParticleEmitterType {
  75488. /**
  75489. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75490. */
  75491. direction1: Vector3;
  75492. /**
  75493. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75494. */
  75495. direction2: Vector3;
  75496. /**
  75497. * 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.
  75498. */
  75499. minEmitBox: Vector3;
  75500. /**
  75501. * 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.
  75502. */
  75503. maxEmitBox: Vector3;
  75504. /**
  75505. * Creates a new instance BoxParticleEmitter
  75506. */
  75507. constructor();
  75508. /**
  75509. * Called by the particle System when the direction is computed for the created particle.
  75510. * @param worldMatrix is the world matrix of the particle system
  75511. * @param directionToUpdate is the direction vector to update with the result
  75512. * @param particle is the particle we are computed the direction for
  75513. */
  75514. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75515. /**
  75516. * Called by the particle System when the position is computed for the created particle.
  75517. * @param worldMatrix is the world matrix of the particle system
  75518. * @param positionToUpdate is the position vector to update with the result
  75519. * @param particle is the particle we are computed the position for
  75520. */
  75521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75522. /**
  75523. * Clones the current emitter and returns a copy of it
  75524. * @returns the new emitter
  75525. */
  75526. clone(): BoxParticleEmitter;
  75527. /**
  75528. * Called by the GPUParticleSystem to setup the update shader
  75529. * @param effect defines the update shader
  75530. */
  75531. applyToShader(effect: Effect): void;
  75532. /**
  75533. * Returns a string to use to update the GPU particles update shader
  75534. * @returns a string containng the defines string
  75535. */
  75536. getEffectDefines(): string;
  75537. /**
  75538. * Returns the string "BoxParticleEmitter"
  75539. * @returns a string containing the class name
  75540. */
  75541. getClassName(): string;
  75542. /**
  75543. * Serializes the particle system to a JSON object.
  75544. * @returns the JSON object
  75545. */
  75546. serialize(): any;
  75547. /**
  75548. * Parse properties from a JSON object
  75549. * @param serializationObject defines the JSON object
  75550. */
  75551. parse(serializationObject: any): void;
  75552. }
  75553. }
  75554. declare module BABYLON {
  75555. /**
  75556. * Particle emitter emitting particles from the inside of a cone.
  75557. * It emits the particles alongside the cone volume from the base to the particle.
  75558. * The emission direction might be randomized.
  75559. */
  75560. export class ConeParticleEmitter implements IParticleEmitterType {
  75561. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75562. directionRandomizer: number;
  75563. private _radius;
  75564. private _angle;
  75565. private _height;
  75566. /**
  75567. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75568. */
  75569. radiusRange: number;
  75570. /**
  75571. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75572. */
  75573. heightRange: number;
  75574. /**
  75575. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75576. */
  75577. emitFromSpawnPointOnly: boolean;
  75578. /**
  75579. * Gets or sets the radius of the emission cone
  75580. */
  75581. radius: number;
  75582. /**
  75583. * Gets or sets the angle of the emission cone
  75584. */
  75585. angle: number;
  75586. private _buildHeight;
  75587. /**
  75588. * Creates a new instance ConeParticleEmitter
  75589. * @param radius the radius of the emission cone (1 by default)
  75590. * @param angle the cone base angle (PI by default)
  75591. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75592. */
  75593. constructor(radius?: number, angle?: number,
  75594. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75595. directionRandomizer?: number);
  75596. /**
  75597. * Called by the particle System when the direction is computed for the created particle.
  75598. * @param worldMatrix is the world matrix of the particle system
  75599. * @param directionToUpdate is the direction vector to update with the result
  75600. * @param particle is the particle we are computed the direction for
  75601. */
  75602. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75603. /**
  75604. * Called by the particle System when the position is computed for the created particle.
  75605. * @param worldMatrix is the world matrix of the particle system
  75606. * @param positionToUpdate is the position vector to update with the result
  75607. * @param particle is the particle we are computed the position for
  75608. */
  75609. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75610. /**
  75611. * Clones the current emitter and returns a copy of it
  75612. * @returns the new emitter
  75613. */
  75614. clone(): ConeParticleEmitter;
  75615. /**
  75616. * Called by the GPUParticleSystem to setup the update shader
  75617. * @param effect defines the update shader
  75618. */
  75619. applyToShader(effect: Effect): void;
  75620. /**
  75621. * Returns a string to use to update the GPU particles update shader
  75622. * @returns a string containng the defines string
  75623. */
  75624. getEffectDefines(): string;
  75625. /**
  75626. * Returns the string "ConeParticleEmitter"
  75627. * @returns a string containing the class name
  75628. */
  75629. getClassName(): string;
  75630. /**
  75631. * Serializes the particle system to a JSON object.
  75632. * @returns the JSON object
  75633. */
  75634. serialize(): any;
  75635. /**
  75636. * Parse properties from a JSON object
  75637. * @param serializationObject defines the JSON object
  75638. */
  75639. parse(serializationObject: any): void;
  75640. }
  75641. }
  75642. declare module BABYLON {
  75643. /**
  75644. * Particle emitter emitting particles from the inside of a cylinder.
  75645. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75646. */
  75647. export class CylinderParticleEmitter implements IParticleEmitterType {
  75648. /**
  75649. * The radius of the emission cylinder.
  75650. */
  75651. radius: number;
  75652. /**
  75653. * The height of the emission cylinder.
  75654. */
  75655. height: number;
  75656. /**
  75657. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75658. */
  75659. radiusRange: number;
  75660. /**
  75661. * How much to randomize the particle direction [0-1].
  75662. */
  75663. directionRandomizer: number;
  75664. /**
  75665. * Creates a new instance CylinderParticleEmitter
  75666. * @param radius the radius of the emission cylinder (1 by default)
  75667. * @param height the height of the emission cylinder (1 by default)
  75668. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75669. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75670. */
  75671. constructor(
  75672. /**
  75673. * The radius of the emission cylinder.
  75674. */
  75675. radius?: number,
  75676. /**
  75677. * The height of the emission cylinder.
  75678. */
  75679. height?: number,
  75680. /**
  75681. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75682. */
  75683. radiusRange?: number,
  75684. /**
  75685. * How much to randomize the particle direction [0-1].
  75686. */
  75687. directionRandomizer?: number);
  75688. /**
  75689. * Called by the particle System when the direction is computed for the created particle.
  75690. * @param worldMatrix is the world matrix of the particle system
  75691. * @param directionToUpdate is the direction vector to update with the result
  75692. * @param particle is the particle we are computed the direction for
  75693. */
  75694. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75695. /**
  75696. * Called by the particle System when the position is computed for the created particle.
  75697. * @param worldMatrix is the world matrix of the particle system
  75698. * @param positionToUpdate is the position vector to update with the result
  75699. * @param particle is the particle we are computed the position for
  75700. */
  75701. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75702. /**
  75703. * Clones the current emitter and returns a copy of it
  75704. * @returns the new emitter
  75705. */
  75706. clone(): CylinderParticleEmitter;
  75707. /**
  75708. * Called by the GPUParticleSystem to setup the update shader
  75709. * @param effect defines the update shader
  75710. */
  75711. applyToShader(effect: Effect): void;
  75712. /**
  75713. * Returns a string to use to update the GPU particles update shader
  75714. * @returns a string containng the defines string
  75715. */
  75716. getEffectDefines(): string;
  75717. /**
  75718. * Returns the string "CylinderParticleEmitter"
  75719. * @returns a string containing the class name
  75720. */
  75721. getClassName(): string;
  75722. /**
  75723. * Serializes the particle system to a JSON object.
  75724. * @returns the JSON object
  75725. */
  75726. serialize(): any;
  75727. /**
  75728. * Parse properties from a JSON object
  75729. * @param serializationObject defines the JSON object
  75730. */
  75731. parse(serializationObject: any): void;
  75732. }
  75733. /**
  75734. * Particle emitter emitting particles from the inside of a cylinder.
  75735. * It emits the particles randomly between two vectors.
  75736. */
  75737. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75738. /**
  75739. * The min limit of the emission direction.
  75740. */
  75741. direction1: Vector3;
  75742. /**
  75743. * The max limit of the emission direction.
  75744. */
  75745. direction2: Vector3;
  75746. /**
  75747. * Creates a new instance CylinderDirectedParticleEmitter
  75748. * @param radius the radius of the emission cylinder (1 by default)
  75749. * @param height the height of the emission cylinder (1 by default)
  75750. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75751. * @param direction1 the min limit of the emission direction (up vector by default)
  75752. * @param direction2 the max limit of the emission direction (up vector by default)
  75753. */
  75754. constructor(radius?: number, height?: number, radiusRange?: number,
  75755. /**
  75756. * The min limit of the emission direction.
  75757. */
  75758. direction1?: Vector3,
  75759. /**
  75760. * The max limit of the emission direction.
  75761. */
  75762. direction2?: Vector3);
  75763. /**
  75764. * Called by the particle System when the direction is computed for the created particle.
  75765. * @param worldMatrix is the world matrix of the particle system
  75766. * @param directionToUpdate is the direction vector to update with the result
  75767. * @param particle is the particle we are computed the direction for
  75768. */
  75769. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75770. /**
  75771. * Clones the current emitter and returns a copy of it
  75772. * @returns the new emitter
  75773. */
  75774. clone(): CylinderDirectedParticleEmitter;
  75775. /**
  75776. * Called by the GPUParticleSystem to setup the update shader
  75777. * @param effect defines the update shader
  75778. */
  75779. applyToShader(effect: Effect): void;
  75780. /**
  75781. * Returns a string to use to update the GPU particles update shader
  75782. * @returns a string containng the defines string
  75783. */
  75784. getEffectDefines(): string;
  75785. /**
  75786. * Returns the string "CylinderDirectedParticleEmitter"
  75787. * @returns a string containing the class name
  75788. */
  75789. getClassName(): string;
  75790. /**
  75791. * Serializes the particle system to a JSON object.
  75792. * @returns the JSON object
  75793. */
  75794. serialize(): any;
  75795. /**
  75796. * Parse properties from a JSON object
  75797. * @param serializationObject defines the JSON object
  75798. */
  75799. parse(serializationObject: any): void;
  75800. }
  75801. }
  75802. declare module BABYLON {
  75803. /**
  75804. * Particle emitter emitting particles from the inside of a hemisphere.
  75805. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75806. */
  75807. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75808. /**
  75809. * The radius of the emission hemisphere.
  75810. */
  75811. radius: number;
  75812. /**
  75813. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75814. */
  75815. radiusRange: number;
  75816. /**
  75817. * How much to randomize the particle direction [0-1].
  75818. */
  75819. directionRandomizer: number;
  75820. /**
  75821. * Creates a new instance HemisphericParticleEmitter
  75822. * @param radius the radius of the emission hemisphere (1 by default)
  75823. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75824. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75825. */
  75826. constructor(
  75827. /**
  75828. * The radius of the emission hemisphere.
  75829. */
  75830. radius?: number,
  75831. /**
  75832. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75833. */
  75834. radiusRange?: number,
  75835. /**
  75836. * How much to randomize the particle direction [0-1].
  75837. */
  75838. directionRandomizer?: number);
  75839. /**
  75840. * Called by the particle System when the direction is computed for the created particle.
  75841. * @param worldMatrix is the world matrix of the particle system
  75842. * @param directionToUpdate is the direction vector to update with the result
  75843. * @param particle is the particle we are computed the direction for
  75844. */
  75845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75846. /**
  75847. * Called by the particle System when the position is computed for the created particle.
  75848. * @param worldMatrix is the world matrix of the particle system
  75849. * @param positionToUpdate is the position vector to update with the result
  75850. * @param particle is the particle we are computed the position for
  75851. */
  75852. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75853. /**
  75854. * Clones the current emitter and returns a copy of it
  75855. * @returns the new emitter
  75856. */
  75857. clone(): HemisphericParticleEmitter;
  75858. /**
  75859. * Called by the GPUParticleSystem to setup the update shader
  75860. * @param effect defines the update shader
  75861. */
  75862. applyToShader(effect: Effect): void;
  75863. /**
  75864. * Returns a string to use to update the GPU particles update shader
  75865. * @returns a string containng the defines string
  75866. */
  75867. getEffectDefines(): string;
  75868. /**
  75869. * Returns the string "HemisphericParticleEmitter"
  75870. * @returns a string containing the class name
  75871. */
  75872. getClassName(): string;
  75873. /**
  75874. * Serializes the particle system to a JSON object.
  75875. * @returns the JSON object
  75876. */
  75877. serialize(): any;
  75878. /**
  75879. * Parse properties from a JSON object
  75880. * @param serializationObject defines the JSON object
  75881. */
  75882. parse(serializationObject: any): void;
  75883. }
  75884. }
  75885. declare module BABYLON {
  75886. /**
  75887. * Particle emitter emitting particles from a point.
  75888. * It emits the particles randomly between 2 given directions.
  75889. */
  75890. export class PointParticleEmitter implements IParticleEmitterType {
  75891. /**
  75892. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75893. */
  75894. direction1: Vector3;
  75895. /**
  75896. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75897. */
  75898. direction2: Vector3;
  75899. /**
  75900. * Creates a new instance PointParticleEmitter
  75901. */
  75902. constructor();
  75903. /**
  75904. * Called by the particle System when the direction is computed for the created particle.
  75905. * @param worldMatrix is the world matrix of the particle system
  75906. * @param directionToUpdate is the direction vector to update with the result
  75907. * @param particle is the particle we are computed the direction for
  75908. */
  75909. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75910. /**
  75911. * Called by the particle System when the position is computed for the created particle.
  75912. * @param worldMatrix is the world matrix of the particle system
  75913. * @param positionToUpdate is the position vector to update with the result
  75914. * @param particle is the particle we are computed the position for
  75915. */
  75916. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75917. /**
  75918. * Clones the current emitter and returns a copy of it
  75919. * @returns the new emitter
  75920. */
  75921. clone(): PointParticleEmitter;
  75922. /**
  75923. * Called by the GPUParticleSystem to setup the update shader
  75924. * @param effect defines the update shader
  75925. */
  75926. applyToShader(effect: Effect): void;
  75927. /**
  75928. * Returns a string to use to update the GPU particles update shader
  75929. * @returns a string containng the defines string
  75930. */
  75931. getEffectDefines(): string;
  75932. /**
  75933. * Returns the string "PointParticleEmitter"
  75934. * @returns a string containing the class name
  75935. */
  75936. getClassName(): string;
  75937. /**
  75938. * Serializes the particle system to a JSON object.
  75939. * @returns the JSON object
  75940. */
  75941. serialize(): any;
  75942. /**
  75943. * Parse properties from a JSON object
  75944. * @param serializationObject defines the JSON object
  75945. */
  75946. parse(serializationObject: any): void;
  75947. }
  75948. }
  75949. declare module BABYLON {
  75950. /**
  75951. * Particle emitter emitting particles from the inside of a sphere.
  75952. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75953. */
  75954. export class SphereParticleEmitter implements IParticleEmitterType {
  75955. /**
  75956. * The radius of the emission sphere.
  75957. */
  75958. radius: number;
  75959. /**
  75960. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75961. */
  75962. radiusRange: number;
  75963. /**
  75964. * How much to randomize the particle direction [0-1].
  75965. */
  75966. directionRandomizer: number;
  75967. /**
  75968. * Creates a new instance SphereParticleEmitter
  75969. * @param radius the radius of the emission sphere (1 by default)
  75970. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75971. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75972. */
  75973. constructor(
  75974. /**
  75975. * The radius of the emission sphere.
  75976. */
  75977. radius?: number,
  75978. /**
  75979. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75980. */
  75981. radiusRange?: number,
  75982. /**
  75983. * How much to randomize the particle direction [0-1].
  75984. */
  75985. directionRandomizer?: number);
  75986. /**
  75987. * Called by the particle System when the direction is computed for the created particle.
  75988. * @param worldMatrix is the world matrix of the particle system
  75989. * @param directionToUpdate is the direction vector to update with the result
  75990. * @param particle is the particle we are computed the direction for
  75991. */
  75992. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75993. /**
  75994. * Called by the particle System when the position is computed for the created particle.
  75995. * @param worldMatrix is the world matrix of the particle system
  75996. * @param positionToUpdate is the position vector to update with the result
  75997. * @param particle is the particle we are computed the position for
  75998. */
  75999. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  76000. /**
  76001. * Clones the current emitter and returns a copy of it
  76002. * @returns the new emitter
  76003. */
  76004. clone(): SphereParticleEmitter;
  76005. /**
  76006. * Called by the GPUParticleSystem to setup the update shader
  76007. * @param effect defines the update shader
  76008. */
  76009. applyToShader(effect: Effect): void;
  76010. /**
  76011. * Returns a string to use to update the GPU particles update shader
  76012. * @returns a string containng the defines string
  76013. */
  76014. getEffectDefines(): string;
  76015. /**
  76016. * Returns the string "SphereParticleEmitter"
  76017. * @returns a string containing the class name
  76018. */
  76019. getClassName(): string;
  76020. /**
  76021. * Serializes the particle system to a JSON object.
  76022. * @returns the JSON object
  76023. */
  76024. serialize(): any;
  76025. /**
  76026. * Parse properties from a JSON object
  76027. * @param serializationObject defines the JSON object
  76028. */
  76029. parse(serializationObject: any): void;
  76030. }
  76031. /**
  76032. * Particle emitter emitting particles from the inside of a sphere.
  76033. * It emits the particles randomly between two vectors.
  76034. */
  76035. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  76036. /**
  76037. * The min limit of the emission direction.
  76038. */
  76039. direction1: Vector3;
  76040. /**
  76041. * The max limit of the emission direction.
  76042. */
  76043. direction2: Vector3;
  76044. /**
  76045. * Creates a new instance SphereDirectedParticleEmitter
  76046. * @param radius the radius of the emission sphere (1 by default)
  76047. * @param direction1 the min limit of the emission direction (up vector by default)
  76048. * @param direction2 the max limit of the emission direction (up vector by default)
  76049. */
  76050. constructor(radius?: number,
  76051. /**
  76052. * The min limit of the emission direction.
  76053. */
  76054. direction1?: Vector3,
  76055. /**
  76056. * The max limit of the emission direction.
  76057. */
  76058. direction2?: Vector3);
  76059. /**
  76060. * Called by the particle System when the direction is computed for the created particle.
  76061. * @param worldMatrix is the world matrix of the particle system
  76062. * @param directionToUpdate is the direction vector to update with the result
  76063. * @param particle is the particle we are computed the direction for
  76064. */
  76065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76066. /**
  76067. * Clones the current emitter and returns a copy of it
  76068. * @returns the new emitter
  76069. */
  76070. clone(): SphereDirectedParticleEmitter;
  76071. /**
  76072. * Called by the GPUParticleSystem to setup the update shader
  76073. * @param effect defines the update shader
  76074. */
  76075. applyToShader(effect: Effect): void;
  76076. /**
  76077. * Returns a string to use to update the GPU particles update shader
  76078. * @returns a string containng the defines string
  76079. */
  76080. getEffectDefines(): string;
  76081. /**
  76082. * Returns the string "SphereDirectedParticleEmitter"
  76083. * @returns a string containing the class name
  76084. */
  76085. getClassName(): string;
  76086. /**
  76087. * Serializes the particle system to a JSON object.
  76088. * @returns the JSON object
  76089. */
  76090. serialize(): any;
  76091. /**
  76092. * Parse properties from a JSON object
  76093. * @param serializationObject defines the JSON object
  76094. */
  76095. parse(serializationObject: any): void;
  76096. }
  76097. }
  76098. declare module BABYLON {
  76099. /**
  76100. * Interface representing a particle system in Babylon.js.
  76101. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  76102. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  76103. */
  76104. export interface IParticleSystem {
  76105. /**
  76106. * List of animations used by the particle system.
  76107. */
  76108. animations: Animation[];
  76109. /**
  76110. * The id of the Particle system.
  76111. */
  76112. id: string;
  76113. /**
  76114. * The name of the Particle system.
  76115. */
  76116. name: string;
  76117. /**
  76118. * The emitter represents the Mesh or position we are attaching the particle system to.
  76119. */
  76120. emitter: Nullable<AbstractMesh | Vector3>;
  76121. /**
  76122. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76123. */
  76124. isBillboardBased: boolean;
  76125. /**
  76126. * The rendering group used by the Particle system to chose when to render.
  76127. */
  76128. renderingGroupId: number;
  76129. /**
  76130. * The layer mask we are rendering the particles through.
  76131. */
  76132. layerMask: number;
  76133. /**
  76134. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76135. */
  76136. updateSpeed: number;
  76137. /**
  76138. * The amount of time the particle system is running (depends of the overall update speed).
  76139. */
  76140. targetStopDuration: number;
  76141. /**
  76142. * The texture used to render each particle. (this can be a spritesheet)
  76143. */
  76144. particleTexture: Nullable<Texture>;
  76145. /**
  76146. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  76147. */
  76148. blendMode: number;
  76149. /**
  76150. * Minimum life time of emitting particles.
  76151. */
  76152. minLifeTime: number;
  76153. /**
  76154. * Maximum life time of emitting particles.
  76155. */
  76156. maxLifeTime: number;
  76157. /**
  76158. * Minimum Size of emitting particles.
  76159. */
  76160. minSize: number;
  76161. /**
  76162. * Maximum Size of emitting particles.
  76163. */
  76164. maxSize: number;
  76165. /**
  76166. * Minimum scale of emitting particles on X axis.
  76167. */
  76168. minScaleX: number;
  76169. /**
  76170. * Maximum scale of emitting particles on X axis.
  76171. */
  76172. maxScaleX: number;
  76173. /**
  76174. * Minimum scale of emitting particles on Y axis.
  76175. */
  76176. minScaleY: number;
  76177. /**
  76178. * Maximum scale of emitting particles on Y axis.
  76179. */
  76180. maxScaleY: number;
  76181. /**
  76182. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76183. */
  76184. color1: Color4;
  76185. /**
  76186. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76187. */
  76188. color2: Color4;
  76189. /**
  76190. * Color the particle will have at the end of its lifetime.
  76191. */
  76192. colorDead: Color4;
  76193. /**
  76194. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  76195. */
  76196. emitRate: number;
  76197. /**
  76198. * You can use gravity if you want to give an orientation to your particles.
  76199. */
  76200. gravity: Vector3;
  76201. /**
  76202. * Minimum power of emitting particles.
  76203. */
  76204. minEmitPower: number;
  76205. /**
  76206. * Maximum power of emitting particles.
  76207. */
  76208. maxEmitPower: number;
  76209. /**
  76210. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76211. */
  76212. minAngularSpeed: number;
  76213. /**
  76214. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76215. */
  76216. maxAngularSpeed: number;
  76217. /**
  76218. * Gets or sets the minimal initial rotation in radians.
  76219. */
  76220. minInitialRotation: number;
  76221. /**
  76222. * Gets or sets the maximal initial rotation in radians.
  76223. */
  76224. maxInitialRotation: number;
  76225. /**
  76226. * The particle emitter type defines the emitter used by the particle system.
  76227. * It can be for example box, sphere, or cone...
  76228. */
  76229. particleEmitterType: Nullable<IParticleEmitterType>;
  76230. /**
  76231. * Defines the delay in milliseconds before starting the system (0 by default)
  76232. */
  76233. startDelay: number;
  76234. /**
  76235. * 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
  76236. */
  76237. preWarmCycles: number;
  76238. /**
  76239. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  76240. */
  76241. preWarmStepOffset: number;
  76242. /**
  76243. * 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)
  76244. */
  76245. spriteCellChangeSpeed: number;
  76246. /**
  76247. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76248. */
  76249. startSpriteCellID: number;
  76250. /**
  76251. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76252. */
  76253. endSpriteCellID: number;
  76254. /**
  76255. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76256. */
  76257. spriteCellWidth: number;
  76258. /**
  76259. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76260. */
  76261. spriteCellHeight: number;
  76262. /**
  76263. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76264. */
  76265. spriteRandomStartCell: boolean;
  76266. /**
  76267. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  76268. */
  76269. isAnimationSheetEnabled: boolean;
  76270. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76271. translationPivot: Vector2;
  76272. /**
  76273. * Gets or sets a texture used to add random noise to particle positions
  76274. */
  76275. noiseTexture: Nullable<BaseTexture>;
  76276. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76277. noiseStrength: Vector3;
  76278. /**
  76279. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76280. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76281. */
  76282. billboardMode: number;
  76283. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76284. limitVelocityDamping: number;
  76285. /**
  76286. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76287. */
  76288. beginAnimationOnStart: boolean;
  76289. /**
  76290. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76291. */
  76292. beginAnimationFrom: number;
  76293. /**
  76294. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76295. */
  76296. beginAnimationTo: number;
  76297. /**
  76298. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76299. */
  76300. beginAnimationLoop: boolean;
  76301. /**
  76302. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76303. */
  76304. disposeOnStop: boolean;
  76305. /**
  76306. * Gets the maximum number of particles active at the same time.
  76307. * @returns The max number of active particles.
  76308. */
  76309. getCapacity(): number;
  76310. /**
  76311. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76312. * @returns True if it has been started, otherwise false.
  76313. */
  76314. isStarted(): boolean;
  76315. /**
  76316. * Animates the particle system for this frame.
  76317. */
  76318. animate(): void;
  76319. /**
  76320. * Renders the particle system in its current state.
  76321. * @returns the current number of particles
  76322. */
  76323. render(): number;
  76324. /**
  76325. * Dispose the particle system and frees its associated resources.
  76326. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76327. */
  76328. dispose(disposeTexture?: boolean): void;
  76329. /**
  76330. * Clones the particle system.
  76331. * @param name The name of the cloned object
  76332. * @param newEmitter The new emitter to use
  76333. * @returns the cloned particle system
  76334. */
  76335. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  76336. /**
  76337. * Serializes the particle system to a JSON object.
  76338. * @returns the JSON object
  76339. */
  76340. serialize(): any;
  76341. /**
  76342. * Rebuild the particle system
  76343. */
  76344. rebuild(): void;
  76345. /**
  76346. * Starts the particle system and begins to emit
  76347. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  76348. */
  76349. start(delay?: number): void;
  76350. /**
  76351. * Stops the particle system.
  76352. */
  76353. stop(): void;
  76354. /**
  76355. * Remove all active particles
  76356. */
  76357. reset(): void;
  76358. /**
  76359. * Is this system ready to be used/rendered
  76360. * @return true if the system is ready
  76361. */
  76362. isReady(): boolean;
  76363. /**
  76364. * Adds a new color gradient
  76365. * @param gradient defines the gradient to use (between 0 and 1)
  76366. * @param color1 defines the color to affect to the specified gradient
  76367. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76368. * @returns the current particle system
  76369. */
  76370. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  76371. /**
  76372. * Remove a specific color gradient
  76373. * @param gradient defines the gradient to remove
  76374. * @returns the current particle system
  76375. */
  76376. removeColorGradient(gradient: number): IParticleSystem;
  76377. /**
  76378. * Adds a new size gradient
  76379. * @param gradient defines the gradient to use (between 0 and 1)
  76380. * @param factor defines the size factor to affect to the specified gradient
  76381. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76382. * @returns the current particle system
  76383. */
  76384. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76385. /**
  76386. * Remove a specific size gradient
  76387. * @param gradient defines the gradient to remove
  76388. * @returns the current particle system
  76389. */
  76390. removeSizeGradient(gradient: number): IParticleSystem;
  76391. /**
  76392. * Gets the current list of color gradients.
  76393. * You must use addColorGradient and removeColorGradient to udpate this list
  76394. * @returns the list of color gradients
  76395. */
  76396. getColorGradients(): Nullable<Array<ColorGradient>>;
  76397. /**
  76398. * Gets the current list of size gradients.
  76399. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76400. * @returns the list of size gradients
  76401. */
  76402. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76403. /**
  76404. * Gets the current list of angular speed gradients.
  76405. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76406. * @returns the list of angular speed gradients
  76407. */
  76408. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76409. /**
  76410. * Adds a new angular speed gradient
  76411. * @param gradient defines the gradient to use (between 0 and 1)
  76412. * @param factor defines the angular speed to affect to the specified gradient
  76413. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76414. * @returns the current particle system
  76415. */
  76416. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76417. /**
  76418. * Remove a specific angular speed gradient
  76419. * @param gradient defines the gradient to remove
  76420. * @returns the current particle system
  76421. */
  76422. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  76423. /**
  76424. * Gets the current list of velocity gradients.
  76425. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76426. * @returns the list of velocity gradients
  76427. */
  76428. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76429. /**
  76430. * Adds a new velocity gradient
  76431. * @param gradient defines the gradient to use (between 0 and 1)
  76432. * @param factor defines the velocity to affect to the specified gradient
  76433. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76434. * @returns the current particle system
  76435. */
  76436. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76437. /**
  76438. * Remove a specific velocity gradient
  76439. * @param gradient defines the gradient to remove
  76440. * @returns the current particle system
  76441. */
  76442. removeVelocityGradient(gradient: number): IParticleSystem;
  76443. /**
  76444. * Gets the current list of limit velocity gradients.
  76445. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76446. * @returns the list of limit velocity gradients
  76447. */
  76448. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76449. /**
  76450. * Adds a new limit velocity gradient
  76451. * @param gradient defines the gradient to use (between 0 and 1)
  76452. * @param factor defines the limit velocity to affect to the specified gradient
  76453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76454. * @returns the current particle system
  76455. */
  76456. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76457. /**
  76458. * Remove a specific limit velocity gradient
  76459. * @param gradient defines the gradient to remove
  76460. * @returns the current particle system
  76461. */
  76462. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76463. /**
  76464. * Adds a new drag gradient
  76465. * @param gradient defines the gradient to use (between 0 and 1)
  76466. * @param factor defines the drag to affect to the specified gradient
  76467. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76468. * @returns the current particle system
  76469. */
  76470. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76471. /**
  76472. * Remove a specific drag gradient
  76473. * @param gradient defines the gradient to remove
  76474. * @returns the current particle system
  76475. */
  76476. removeDragGradient(gradient: number): IParticleSystem;
  76477. /**
  76478. * Gets the current list of drag gradients.
  76479. * You must use addDragGradient and removeDragGradient to udpate this list
  76480. * @returns the list of drag gradients
  76481. */
  76482. getDragGradients(): Nullable<Array<FactorGradient>>;
  76483. /**
  76484. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76485. * @param gradient defines the gradient to use (between 0 and 1)
  76486. * @param factor defines the emit rate to affect to the specified gradient
  76487. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76488. * @returns the current particle system
  76489. */
  76490. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76491. /**
  76492. * Remove a specific emit rate gradient
  76493. * @param gradient defines the gradient to remove
  76494. * @returns the current particle system
  76495. */
  76496. removeEmitRateGradient(gradient: number): IParticleSystem;
  76497. /**
  76498. * Gets the current list of emit rate gradients.
  76499. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76500. * @returns the list of emit rate gradients
  76501. */
  76502. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76503. /**
  76504. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76505. * @param gradient defines the gradient to use (between 0 and 1)
  76506. * @param factor defines the start size to affect to the specified gradient
  76507. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76508. * @returns the current particle system
  76509. */
  76510. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76511. /**
  76512. * Remove a specific start size gradient
  76513. * @param gradient defines the gradient to remove
  76514. * @returns the current particle system
  76515. */
  76516. removeStartSizeGradient(gradient: number): IParticleSystem;
  76517. /**
  76518. * Gets the current list of start size gradients.
  76519. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76520. * @returns the list of start size gradients
  76521. */
  76522. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76523. /**
  76524. * Adds a new life time gradient
  76525. * @param gradient defines the gradient to use (between 0 and 1)
  76526. * @param factor defines the life time factor to affect to the specified gradient
  76527. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76528. * @returns the current particle system
  76529. */
  76530. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76531. /**
  76532. * Remove a specific life time gradient
  76533. * @param gradient defines the gradient to remove
  76534. * @returns the current particle system
  76535. */
  76536. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76537. /**
  76538. * Gets the current list of life time gradients.
  76539. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76540. * @returns the list of life time gradients
  76541. */
  76542. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76543. /**
  76544. * Gets the current list of color gradients.
  76545. * You must use addColorGradient and removeColorGradient to udpate this list
  76546. * @returns the list of color gradients
  76547. */
  76548. getColorGradients(): Nullable<Array<ColorGradient>>;
  76549. /**
  76550. * Adds a new ramp gradient used to remap particle colors
  76551. * @param gradient defines the gradient to use (between 0 and 1)
  76552. * @param color defines the color to affect to the specified gradient
  76553. * @returns the current particle system
  76554. */
  76555. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76556. /**
  76557. * Gets the current list of ramp gradients.
  76558. * You must use addRampGradient and removeRampGradient to udpate this list
  76559. * @returns the list of ramp gradients
  76560. */
  76561. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76562. /** Gets or sets a boolean indicating that ramp gradients must be used
  76563. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76564. */
  76565. useRampGradients: boolean;
  76566. /**
  76567. * Adds a new color remap gradient
  76568. * @param gradient defines the gradient to use (between 0 and 1)
  76569. * @param min defines the color remap minimal range
  76570. * @param max defines the color remap maximal range
  76571. * @returns the current particle system
  76572. */
  76573. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76574. /**
  76575. * Gets the current list of color remap gradients.
  76576. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76577. * @returns the list of color remap gradients
  76578. */
  76579. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76580. /**
  76581. * Adds a new alpha remap gradient
  76582. * @param gradient defines the gradient to use (between 0 and 1)
  76583. * @param min defines the alpha remap minimal range
  76584. * @param max defines the alpha remap maximal range
  76585. * @returns the current particle system
  76586. */
  76587. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76588. /**
  76589. * Gets the current list of alpha remap gradients.
  76590. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76591. * @returns the list of alpha remap gradients
  76592. */
  76593. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76594. /**
  76595. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76596. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76597. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76598. * @returns the emitter
  76599. */
  76600. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76601. /**
  76602. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76603. * @param radius The radius of the hemisphere to emit from
  76604. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76605. * @returns the emitter
  76606. */
  76607. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76608. /**
  76609. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76610. * @param radius The radius of the sphere to emit from
  76611. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76612. * @returns the emitter
  76613. */
  76614. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76615. /**
  76616. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76617. * @param radius The radius of the sphere to emit from
  76618. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76619. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76620. * @returns the emitter
  76621. */
  76622. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76623. /**
  76624. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76625. * @param radius The radius of the emission cylinder
  76626. * @param height The height of the emission cylinder
  76627. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76628. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76629. * @returns the emitter
  76630. */
  76631. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76632. /**
  76633. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76634. * @param radius The radius of the cylinder to emit from
  76635. * @param height The height of the emission cylinder
  76636. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76637. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76638. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76639. * @returns the emitter
  76640. */
  76641. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76642. /**
  76643. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76644. * @param radius The radius of the cone to emit from
  76645. * @param angle The base angle of the cone
  76646. * @returns the emitter
  76647. */
  76648. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76649. /**
  76650. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76651. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76652. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76653. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76654. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76655. * @returns the emitter
  76656. */
  76657. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76658. /**
  76659. * Get hosting scene
  76660. * @returns the scene
  76661. */
  76662. getScene(): Scene;
  76663. }
  76664. }
  76665. declare module BABYLON {
  76666. /**
  76667. * Creates an instance based on a source mesh.
  76668. */
  76669. export class InstancedMesh extends AbstractMesh {
  76670. private _sourceMesh;
  76671. private _currentLOD;
  76672. /** @hidden */
  76673. _indexInSourceMeshInstanceArray: number;
  76674. constructor(name: string, source: Mesh);
  76675. /**
  76676. * Returns the string "InstancedMesh".
  76677. */
  76678. getClassName(): string;
  76679. /** Gets the list of lights affecting that mesh */
  76680. readonly lightSources: Light[];
  76681. _resyncLightSources(): void;
  76682. _resyncLighSource(light: Light): void;
  76683. _removeLightSource(light: Light): void;
  76684. /**
  76685. * If the source mesh receives shadows
  76686. */
  76687. readonly receiveShadows: boolean;
  76688. /**
  76689. * The material of the source mesh
  76690. */
  76691. readonly material: Nullable<Material>;
  76692. /**
  76693. * Visibility of the source mesh
  76694. */
  76695. readonly visibility: number;
  76696. /**
  76697. * Skeleton of the source mesh
  76698. */
  76699. readonly skeleton: Nullable<Skeleton>;
  76700. /**
  76701. * Rendering ground id of the source mesh
  76702. */
  76703. renderingGroupId: number;
  76704. /**
  76705. * Returns the total number of vertices (integer).
  76706. */
  76707. getTotalVertices(): number;
  76708. /**
  76709. * Returns a positive integer : the total number of indices in this mesh geometry.
  76710. * @returns the numner of indices or zero if the mesh has no geometry.
  76711. */
  76712. getTotalIndices(): number;
  76713. /**
  76714. * The source mesh of the instance
  76715. */
  76716. readonly sourceMesh: Mesh;
  76717. /**
  76718. * Is this node ready to be used/rendered
  76719. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76720. * @return {boolean} is it ready
  76721. */
  76722. isReady(completeCheck?: boolean): boolean;
  76723. /**
  76724. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76725. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76726. * @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.
  76727. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76728. */
  76729. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76730. /**
  76731. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76732. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76733. * The `data` are either a numeric array either a Float32Array.
  76734. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76735. * 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).
  76736. * Note that a new underlying VertexBuffer object is created each call.
  76737. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76738. *
  76739. * Possible `kind` values :
  76740. * - VertexBuffer.PositionKind
  76741. * - VertexBuffer.UVKind
  76742. * - VertexBuffer.UV2Kind
  76743. * - VertexBuffer.UV3Kind
  76744. * - VertexBuffer.UV4Kind
  76745. * - VertexBuffer.UV5Kind
  76746. * - VertexBuffer.UV6Kind
  76747. * - VertexBuffer.ColorKind
  76748. * - VertexBuffer.MatricesIndicesKind
  76749. * - VertexBuffer.MatricesIndicesExtraKind
  76750. * - VertexBuffer.MatricesWeightsKind
  76751. * - VertexBuffer.MatricesWeightsExtraKind
  76752. *
  76753. * Returns the Mesh.
  76754. */
  76755. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76756. /**
  76757. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76758. * If the mesh has no geometry, it is simply returned as it is.
  76759. * The `data` are either a numeric array either a Float32Array.
  76760. * No new underlying VertexBuffer object is created.
  76761. * 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.
  76762. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76763. *
  76764. * Possible `kind` values :
  76765. * - VertexBuffer.PositionKind
  76766. * - VertexBuffer.UVKind
  76767. * - VertexBuffer.UV2Kind
  76768. * - VertexBuffer.UV3Kind
  76769. * - VertexBuffer.UV4Kind
  76770. * - VertexBuffer.UV5Kind
  76771. * - VertexBuffer.UV6Kind
  76772. * - VertexBuffer.ColorKind
  76773. * - VertexBuffer.MatricesIndicesKind
  76774. * - VertexBuffer.MatricesIndicesExtraKind
  76775. * - VertexBuffer.MatricesWeightsKind
  76776. * - VertexBuffer.MatricesWeightsExtraKind
  76777. *
  76778. * Returns the Mesh.
  76779. */
  76780. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76781. /**
  76782. * Sets the mesh indices.
  76783. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76784. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76785. * This method creates a new index buffer each call.
  76786. * Returns the Mesh.
  76787. */
  76788. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76789. /**
  76790. * Boolean : True if the mesh owns the requested kind of data.
  76791. */
  76792. isVerticesDataPresent(kind: string): boolean;
  76793. /**
  76794. * Returns an array of indices (IndicesArray).
  76795. */
  76796. getIndices(): Nullable<IndicesArray>;
  76797. readonly _positions: Nullable<Vector3[]>;
  76798. /**
  76799. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76800. * This means the mesh underlying bounding box and sphere are recomputed.
  76801. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76802. * @returns the current mesh
  76803. */
  76804. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76805. /** @hidden */
  76806. _preActivate(): InstancedMesh;
  76807. /** @hidden */
  76808. _activate(renderId: number): boolean;
  76809. /** @hidden */
  76810. _postActivate(): void;
  76811. getWorldMatrix(): Matrix;
  76812. readonly isAnInstance: boolean;
  76813. /**
  76814. * Returns the current associated LOD AbstractMesh.
  76815. */
  76816. getLOD(camera: Camera): AbstractMesh;
  76817. /** @hidden */
  76818. _syncSubMeshes(): InstancedMesh;
  76819. /** @hidden */
  76820. _generatePointsArray(): boolean;
  76821. /**
  76822. * Creates a new InstancedMesh from the current mesh.
  76823. * - name (string) : the cloned mesh name
  76824. * - newParent (optional Node) : the optional Node to parent the clone to.
  76825. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76826. *
  76827. * Returns the clone.
  76828. */
  76829. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76830. /**
  76831. * Disposes the InstancedMesh.
  76832. * Returns nothing.
  76833. */
  76834. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76835. }
  76836. }
  76837. declare module BABYLON {
  76838. /**
  76839. * Defines the options associated with the creation of a shader material.
  76840. */
  76841. export interface IShaderMaterialOptions {
  76842. /**
  76843. * Does the material work in alpha blend mode
  76844. */
  76845. needAlphaBlending: boolean;
  76846. /**
  76847. * Does the material work in alpha test mode
  76848. */
  76849. needAlphaTesting: boolean;
  76850. /**
  76851. * The list of attribute names used in the shader
  76852. */
  76853. attributes: string[];
  76854. /**
  76855. * The list of unifrom names used in the shader
  76856. */
  76857. uniforms: string[];
  76858. /**
  76859. * The list of UBO names used in the shader
  76860. */
  76861. uniformBuffers: string[];
  76862. /**
  76863. * The list of sampler names used in the shader
  76864. */
  76865. samplers: string[];
  76866. /**
  76867. * The list of defines used in the shader
  76868. */
  76869. defines: string[];
  76870. }
  76871. /**
  76872. * 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.
  76873. *
  76874. * This returned material effects how the mesh will look based on the code in the shaders.
  76875. *
  76876. * @see http://doc.babylonjs.com/how_to/shader_material
  76877. */
  76878. export class ShaderMaterial extends Material {
  76879. private _shaderPath;
  76880. private _options;
  76881. private _textures;
  76882. private _textureArrays;
  76883. private _floats;
  76884. private _ints;
  76885. private _floatsArrays;
  76886. private _colors3;
  76887. private _colors3Arrays;
  76888. private _colors4;
  76889. private _vectors2;
  76890. private _vectors3;
  76891. private _vectors4;
  76892. private _matrices;
  76893. private _matrices3x3;
  76894. private _matrices2x2;
  76895. private _vectors2Arrays;
  76896. private _vectors3Arrays;
  76897. private _cachedWorldViewMatrix;
  76898. private _renderId;
  76899. /**
  76900. * Instantiate a new shader material.
  76901. * 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.
  76902. * This returned material effects how the mesh will look based on the code in the shaders.
  76903. * @see http://doc.babylonjs.com/how_to/shader_material
  76904. * @param name Define the name of the material in the scene
  76905. * @param scene Define the scene the material belongs to
  76906. * @param shaderPath Defines the route to the shader code in one of three ways:
  76907. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76908. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76909. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76910. * @param options Define the options used to create the shader
  76911. */
  76912. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76913. /**
  76914. * Gets the options used to compile the shader.
  76915. * They can be modified to trigger a new compilation
  76916. */
  76917. readonly options: IShaderMaterialOptions;
  76918. /**
  76919. * Gets the current class name of the material e.g. "ShaderMaterial"
  76920. * Mainly use in serialization.
  76921. * @returns the class name
  76922. */
  76923. getClassName(): string;
  76924. /**
  76925. * Specifies if the material will require alpha blending
  76926. * @returns a boolean specifying if alpha blending is needed
  76927. */
  76928. needAlphaBlending(): boolean;
  76929. /**
  76930. * Specifies if this material should be rendered in alpha test mode
  76931. * @returns a boolean specifying if an alpha test is needed.
  76932. */
  76933. needAlphaTesting(): boolean;
  76934. private _checkUniform;
  76935. /**
  76936. * Set a texture in the shader.
  76937. * @param name Define the name of the uniform samplers as defined in the shader
  76938. * @param texture Define the texture to bind to this sampler
  76939. * @return the material itself allowing "fluent" like uniform updates
  76940. */
  76941. setTexture(name: string, texture: Texture): ShaderMaterial;
  76942. /**
  76943. * Set a texture array in the shader.
  76944. * @param name Define the name of the uniform sampler array as defined in the shader
  76945. * @param textures Define the list of textures to bind to this sampler
  76946. * @return the material itself allowing "fluent" like uniform updates
  76947. */
  76948. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76949. /**
  76950. * Set a float in the shader.
  76951. * @param name Define the name of the uniform as defined in the shader
  76952. * @param value Define the value to give to the uniform
  76953. * @return the material itself allowing "fluent" like uniform updates
  76954. */
  76955. setFloat(name: string, value: number): ShaderMaterial;
  76956. /**
  76957. * Set a int in the shader.
  76958. * @param name Define the name of the uniform as defined in the shader
  76959. * @param value Define the value to give to the uniform
  76960. * @return the material itself allowing "fluent" like uniform updates
  76961. */
  76962. setInt(name: string, value: number): ShaderMaterial;
  76963. /**
  76964. * Set an array of floats in the shader.
  76965. * @param name Define the name of the uniform as defined in the shader
  76966. * @param value Define the value to give to the uniform
  76967. * @return the material itself allowing "fluent" like uniform updates
  76968. */
  76969. setFloats(name: string, value: number[]): ShaderMaterial;
  76970. /**
  76971. * Set a vec3 in the shader from a Color3.
  76972. * @param name Define the name of the uniform as defined in the shader
  76973. * @param value Define the value to give to the uniform
  76974. * @return the material itself allowing "fluent" like uniform updates
  76975. */
  76976. setColor3(name: string, value: Color3): ShaderMaterial;
  76977. /**
  76978. * Set a vec3 array in the shader from a Color3 array.
  76979. * @param name Define the name of the uniform as defined in the shader
  76980. * @param value Define the value to give to the uniform
  76981. * @return the material itself allowing "fluent" like uniform updates
  76982. */
  76983. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76984. /**
  76985. * Set a vec4 in the shader from a Color4.
  76986. * @param name Define the name of the uniform as defined in the shader
  76987. * @param value Define the value to give to the uniform
  76988. * @return the material itself allowing "fluent" like uniform updates
  76989. */
  76990. setColor4(name: string, value: Color4): ShaderMaterial;
  76991. /**
  76992. * Set a vec2 in the shader from a Vector2.
  76993. * @param name Define the name of the uniform as defined in the shader
  76994. * @param value Define the value to give to the uniform
  76995. * @return the material itself allowing "fluent" like uniform updates
  76996. */
  76997. setVector2(name: string, value: Vector2): ShaderMaterial;
  76998. /**
  76999. * Set a vec3 in the shader from a Vector3.
  77000. * @param name Define the name of the uniform as defined in the shader
  77001. * @param value Define the value to give to the uniform
  77002. * @return the material itself allowing "fluent" like uniform updates
  77003. */
  77004. setVector3(name: string, value: Vector3): ShaderMaterial;
  77005. /**
  77006. * Set a vec4 in the shader from a Vector4.
  77007. * @param name Define the name of the uniform as defined in the shader
  77008. * @param value Define the value to give to the uniform
  77009. * @return the material itself allowing "fluent" like uniform updates
  77010. */
  77011. setVector4(name: string, value: Vector4): ShaderMaterial;
  77012. /**
  77013. * Set a mat4 in the shader from a Matrix.
  77014. * @param name Define the name of the uniform as defined in the shader
  77015. * @param value Define the value to give to the uniform
  77016. * @return the material itself allowing "fluent" like uniform updates
  77017. */
  77018. setMatrix(name: string, value: Matrix): ShaderMaterial;
  77019. /**
  77020. * Set a mat3 in the shader from a Float32Array.
  77021. * @param name Define the name of the uniform as defined in the shader
  77022. * @param value Define the value to give to the uniform
  77023. * @return the material itself allowing "fluent" like uniform updates
  77024. */
  77025. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  77026. /**
  77027. * Set a mat2 in the shader from a Float32Array.
  77028. * @param name Define the name of the uniform as defined in the shader
  77029. * @param value Define the value to give to the uniform
  77030. * @return the material itself allowing "fluent" like uniform updates
  77031. */
  77032. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  77033. /**
  77034. * Set a vec2 array in the shader from a number array.
  77035. * @param name Define the name of the uniform as defined in the shader
  77036. * @param value Define the value to give to the uniform
  77037. * @return the material itself allowing "fluent" like uniform updates
  77038. */
  77039. setArray2(name: string, value: number[]): ShaderMaterial;
  77040. /**
  77041. * Set a vec3 array in the shader from a number array.
  77042. * @param name Define the name of the uniform as defined in the shader
  77043. * @param value Define the value to give to the uniform
  77044. * @return the material itself allowing "fluent" like uniform updates
  77045. */
  77046. setArray3(name: string, value: number[]): ShaderMaterial;
  77047. private _checkCache;
  77048. /**
  77049. * Specifies that the submesh is ready to be used
  77050. * @param mesh defines the mesh to check
  77051. * @param subMesh defines which submesh to check
  77052. * @param useInstances specifies that instances should be used
  77053. * @returns a boolean indicating that the submesh is ready or not
  77054. */
  77055. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77056. /**
  77057. * Checks if the material is ready to render the requested mesh
  77058. * @param mesh Define the mesh to render
  77059. * @param useInstances Define whether or not the material is used with instances
  77060. * @returns true if ready, otherwise false
  77061. */
  77062. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  77063. /**
  77064. * Binds the world matrix to the material
  77065. * @param world defines the world transformation matrix
  77066. */
  77067. bindOnlyWorldMatrix(world: Matrix): void;
  77068. /**
  77069. * Binds the material to the mesh
  77070. * @param world defines the world transformation matrix
  77071. * @param mesh defines the mesh to bind the material to
  77072. */
  77073. bind(world: Matrix, mesh?: Mesh): void;
  77074. /**
  77075. * Gets the active textures from the material
  77076. * @returns an array of textures
  77077. */
  77078. getActiveTextures(): BaseTexture[];
  77079. /**
  77080. * Specifies if the material uses a texture
  77081. * @param texture defines the texture to check against the material
  77082. * @returns a boolean specifying if the material uses the texture
  77083. */
  77084. hasTexture(texture: BaseTexture): boolean;
  77085. /**
  77086. * Makes a duplicate of the material, and gives it a new name
  77087. * @param name defines the new name for the duplicated material
  77088. * @returns the cloned material
  77089. */
  77090. clone(name: string): ShaderMaterial;
  77091. /**
  77092. * Disposes the material
  77093. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77094. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77095. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77096. */
  77097. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77098. /**
  77099. * Serializes this material in a JSON representation
  77100. * @returns the serialized material object
  77101. */
  77102. serialize(): any;
  77103. /**
  77104. * Creates a shader material from parsed shader material data
  77105. * @param source defines the JSON represnetation of the material
  77106. * @param scene defines the hosting scene
  77107. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77108. * @returns a new material
  77109. */
  77110. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  77111. }
  77112. }
  77113. declare module BABYLON {
  77114. /** @hidden */
  77115. export var colorPixelShader: {
  77116. name: string;
  77117. shader: string;
  77118. };
  77119. }
  77120. declare module BABYLON {
  77121. /** @hidden */
  77122. export var colorVertexShader: {
  77123. name: string;
  77124. shader: string;
  77125. };
  77126. }
  77127. declare module BABYLON {
  77128. /**
  77129. * Line mesh
  77130. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  77131. */
  77132. export class LinesMesh extends Mesh {
  77133. /**
  77134. * If vertex color should be applied to the mesh
  77135. */
  77136. useVertexColor?: boolean | undefined;
  77137. /**
  77138. * If vertex alpha should be applied to the mesh
  77139. */
  77140. useVertexAlpha?: boolean | undefined;
  77141. /**
  77142. * Color of the line (Default: White)
  77143. */
  77144. color: Color3;
  77145. /**
  77146. * Alpha of the line (Default: 1)
  77147. */
  77148. alpha: number;
  77149. /**
  77150. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77151. * This margin is expressed in world space coordinates, so its value may vary.
  77152. * Default value is 0.1
  77153. */
  77154. intersectionThreshold: number;
  77155. private _colorShader;
  77156. /**
  77157. * Creates a new LinesMesh
  77158. * @param name defines the name
  77159. * @param scene defines the hosting scene
  77160. * @param parent defines the parent mesh if any
  77161. * @param source defines the optional source LinesMesh used to clone data from
  77162. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77163. * When false, achieved by calling a clone(), also passing False.
  77164. * This will make creation of children, recursive.
  77165. * @param useVertexColor defines if this LinesMesh supports vertex color
  77166. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  77167. */
  77168. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  77169. /**
  77170. * If vertex color should be applied to the mesh
  77171. */
  77172. useVertexColor?: boolean | undefined,
  77173. /**
  77174. * If vertex alpha should be applied to the mesh
  77175. */
  77176. useVertexAlpha?: boolean | undefined);
  77177. private _addClipPlaneDefine;
  77178. private _removeClipPlaneDefine;
  77179. isReady(): boolean;
  77180. /**
  77181. * Returns the string "LineMesh"
  77182. */
  77183. getClassName(): string;
  77184. /**
  77185. * @hidden
  77186. */
  77187. /**
  77188. * @hidden
  77189. */
  77190. material: Material;
  77191. /**
  77192. * @hidden
  77193. */
  77194. readonly checkCollisions: boolean;
  77195. /** @hidden */
  77196. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  77197. /** @hidden */
  77198. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  77199. /**
  77200. * Disposes of the line mesh
  77201. * @param doNotRecurse If children should be disposed
  77202. */
  77203. dispose(doNotRecurse?: boolean): void;
  77204. /**
  77205. * Returns a new LineMesh object cloned from the current one.
  77206. */
  77207. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  77208. /**
  77209. * Creates a new InstancedLinesMesh object from the mesh model.
  77210. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77211. * @param name defines the name of the new instance
  77212. * @returns a new InstancedLinesMesh
  77213. */
  77214. createInstance(name: string): InstancedLinesMesh;
  77215. }
  77216. /**
  77217. * Creates an instance based on a source LinesMesh
  77218. */
  77219. export class InstancedLinesMesh extends InstancedMesh {
  77220. /**
  77221. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77222. * This margin is expressed in world space coordinates, so its value may vary.
  77223. * Initilized with the intersectionThreshold value of the source LinesMesh
  77224. */
  77225. intersectionThreshold: number;
  77226. constructor(name: string, source: LinesMesh);
  77227. /**
  77228. * Returns the string "InstancedLinesMesh".
  77229. */
  77230. getClassName(): string;
  77231. }
  77232. }
  77233. declare module BABYLON {
  77234. /** @hidden */
  77235. export var linePixelShader: {
  77236. name: string;
  77237. shader: string;
  77238. };
  77239. }
  77240. declare module BABYLON {
  77241. /** @hidden */
  77242. export var lineVertexShader: {
  77243. name: string;
  77244. shader: string;
  77245. };
  77246. }
  77247. declare module BABYLON {
  77248. interface AbstractMesh {
  77249. /**
  77250. * Disables the mesh edge rendering mode
  77251. * @returns the currentAbstractMesh
  77252. */
  77253. disableEdgesRendering(): AbstractMesh;
  77254. /**
  77255. * Enables the edge rendering mode on the mesh.
  77256. * This mode makes the mesh edges visible
  77257. * @param epsilon defines the maximal distance between two angles to detect a face
  77258. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77259. * @returns the currentAbstractMesh
  77260. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77261. */
  77262. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77263. /**
  77264. * Gets the edgesRenderer associated with the mesh
  77265. */
  77266. edgesRenderer: Nullable<EdgesRenderer>;
  77267. }
  77268. interface LinesMesh {
  77269. /**
  77270. * Enables the edge rendering mode on the mesh.
  77271. * This mode makes the mesh edges visible
  77272. * @param epsilon defines the maximal distance between two angles to detect a face
  77273. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77274. * @returns the currentAbstractMesh
  77275. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77276. */
  77277. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77278. }
  77279. interface InstancedLinesMesh {
  77280. /**
  77281. * Enables the edge rendering mode on the mesh.
  77282. * This mode makes the mesh edges visible
  77283. * @param epsilon defines the maximal distance between two angles to detect a face
  77284. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77285. * @returns the current InstancedLinesMesh
  77286. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77287. */
  77288. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  77289. }
  77290. /**
  77291. * Defines the minimum contract an Edges renderer should follow.
  77292. */
  77293. export interface IEdgesRenderer extends IDisposable {
  77294. /**
  77295. * Gets or sets a boolean indicating if the edgesRenderer is active
  77296. */
  77297. isEnabled: boolean;
  77298. /**
  77299. * Renders the edges of the attached mesh,
  77300. */
  77301. render(): void;
  77302. /**
  77303. * Checks wether or not the edges renderer is ready to render.
  77304. * @return true if ready, otherwise false.
  77305. */
  77306. isReady(): boolean;
  77307. }
  77308. /**
  77309. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  77310. */
  77311. export class EdgesRenderer implements IEdgesRenderer {
  77312. /**
  77313. * Define the size of the edges with an orthographic camera
  77314. */
  77315. edgesWidthScalerForOrthographic: number;
  77316. /**
  77317. * Define the size of the edges with a perspective camera
  77318. */
  77319. edgesWidthScalerForPerspective: number;
  77320. protected _source: AbstractMesh;
  77321. protected _linesPositions: number[];
  77322. protected _linesNormals: number[];
  77323. protected _linesIndices: number[];
  77324. protected _epsilon: number;
  77325. protected _indicesCount: number;
  77326. protected _lineShader: ShaderMaterial;
  77327. protected _ib: DataBuffer;
  77328. protected _buffers: {
  77329. [key: string]: Nullable<VertexBuffer>;
  77330. };
  77331. protected _checkVerticesInsteadOfIndices: boolean;
  77332. private _meshRebuildObserver;
  77333. private _meshDisposeObserver;
  77334. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  77335. isEnabled: boolean;
  77336. /**
  77337. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  77338. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  77339. * @param source Mesh used to create edges
  77340. * @param epsilon sum of angles in adjacency to check for edge
  77341. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  77342. * @param generateEdgesLines - should generate Lines or only prepare resources.
  77343. */
  77344. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  77345. protected _prepareRessources(): void;
  77346. /** @hidden */
  77347. _rebuild(): void;
  77348. /**
  77349. * Releases the required resources for the edges renderer
  77350. */
  77351. dispose(): void;
  77352. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  77353. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  77354. /**
  77355. * Checks if the pair of p0 and p1 is en edge
  77356. * @param faceIndex
  77357. * @param edge
  77358. * @param faceNormals
  77359. * @param p0
  77360. * @param p1
  77361. * @private
  77362. */
  77363. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  77364. /**
  77365. * push line into the position, normal and index buffer
  77366. * @protected
  77367. */
  77368. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  77369. /**
  77370. * Generates lines edges from adjacencjes
  77371. * @private
  77372. */
  77373. _generateEdgesLines(): void;
  77374. /**
  77375. * Checks wether or not the edges renderer is ready to render.
  77376. * @return true if ready, otherwise false.
  77377. */
  77378. isReady(): boolean;
  77379. /**
  77380. * Renders the edges of the attached mesh,
  77381. */
  77382. render(): void;
  77383. }
  77384. /**
  77385. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  77386. */
  77387. export class LineEdgesRenderer extends EdgesRenderer {
  77388. /**
  77389. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  77390. * @param source LineMesh used to generate edges
  77391. * @param epsilon not important (specified angle for edge detection)
  77392. * @param checkVerticesInsteadOfIndices not important for LineMesh
  77393. */
  77394. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  77395. /**
  77396. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  77397. */
  77398. _generateEdgesLines(): void;
  77399. }
  77400. }
  77401. declare module BABYLON {
  77402. /**
  77403. * This represents the object necessary to create a rendering group.
  77404. * This is exclusively used and created by the rendering manager.
  77405. * To modify the behavior, you use the available helpers in your scene or meshes.
  77406. * @hidden
  77407. */
  77408. export class RenderingGroup {
  77409. index: number;
  77410. private _scene;
  77411. private _opaqueSubMeshes;
  77412. private _transparentSubMeshes;
  77413. private _alphaTestSubMeshes;
  77414. private _depthOnlySubMeshes;
  77415. private _particleSystems;
  77416. private _spriteManagers;
  77417. private _opaqueSortCompareFn;
  77418. private _alphaTestSortCompareFn;
  77419. private _transparentSortCompareFn;
  77420. private _renderOpaque;
  77421. private _renderAlphaTest;
  77422. private _renderTransparent;
  77423. /** @hidden */
  77424. _edgesRenderers: SmartArray<IEdgesRenderer>;
  77425. onBeforeTransparentRendering: () => void;
  77426. /**
  77427. * Set the opaque sort comparison function.
  77428. * If null the sub meshes will be render in the order they were created
  77429. */
  77430. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77431. /**
  77432. * Set the alpha test sort comparison function.
  77433. * If null the sub meshes will be render in the order they were created
  77434. */
  77435. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77436. /**
  77437. * Set the transparent sort comparison function.
  77438. * If null the sub meshes will be render in the order they were created
  77439. */
  77440. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77441. /**
  77442. * Creates a new rendering group.
  77443. * @param index The rendering group index
  77444. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77445. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77446. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77447. */
  77448. 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>);
  77449. /**
  77450. * Render all the sub meshes contained in the group.
  77451. * @param customRenderFunction Used to override the default render behaviour of the group.
  77452. * @returns true if rendered some submeshes.
  77453. */
  77454. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77455. /**
  77456. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77457. * @param subMeshes The submeshes to render
  77458. */
  77459. private renderOpaqueSorted;
  77460. /**
  77461. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77462. * @param subMeshes The submeshes to render
  77463. */
  77464. private renderAlphaTestSorted;
  77465. /**
  77466. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77467. * @param subMeshes The submeshes to render
  77468. */
  77469. private renderTransparentSorted;
  77470. /**
  77471. * Renders the submeshes in a specified order.
  77472. * @param subMeshes The submeshes to sort before render
  77473. * @param sortCompareFn The comparison function use to sort
  77474. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77475. * @param transparent Specifies to activate blending if true
  77476. */
  77477. private static renderSorted;
  77478. /**
  77479. * Renders the submeshes in the order they were dispatched (no sort applied).
  77480. * @param subMeshes The submeshes to render
  77481. */
  77482. private static renderUnsorted;
  77483. /**
  77484. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77485. * are rendered back to front if in the same alpha index.
  77486. *
  77487. * @param a The first submesh
  77488. * @param b The second submesh
  77489. * @returns The result of the comparison
  77490. */
  77491. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77492. /**
  77493. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77494. * are rendered back to front.
  77495. *
  77496. * @param a The first submesh
  77497. * @param b The second submesh
  77498. * @returns The result of the comparison
  77499. */
  77500. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77501. /**
  77502. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77503. * are rendered front to back (prevent overdraw).
  77504. *
  77505. * @param a The first submesh
  77506. * @param b The second submesh
  77507. * @returns The result of the comparison
  77508. */
  77509. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77510. /**
  77511. * Resets the different lists of submeshes to prepare a new frame.
  77512. */
  77513. prepare(): void;
  77514. dispose(): void;
  77515. /**
  77516. * Inserts the submesh in its correct queue depending on its material.
  77517. * @param subMesh The submesh to dispatch
  77518. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77519. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77520. */
  77521. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77522. dispatchSprites(spriteManager: ISpriteManager): void;
  77523. dispatchParticles(particleSystem: IParticleSystem): void;
  77524. private _renderParticles;
  77525. private _renderSprites;
  77526. }
  77527. }
  77528. declare module BABYLON {
  77529. /**
  77530. * Interface describing the different options available in the rendering manager
  77531. * regarding Auto Clear between groups.
  77532. */
  77533. export interface IRenderingManagerAutoClearSetup {
  77534. /**
  77535. * Defines whether or not autoclear is enable.
  77536. */
  77537. autoClear: boolean;
  77538. /**
  77539. * Defines whether or not to autoclear the depth buffer.
  77540. */
  77541. depth: boolean;
  77542. /**
  77543. * Defines whether or not to autoclear the stencil buffer.
  77544. */
  77545. stencil: boolean;
  77546. }
  77547. /**
  77548. * This class is used by the onRenderingGroupObservable
  77549. */
  77550. export class RenderingGroupInfo {
  77551. /**
  77552. * The Scene that being rendered
  77553. */
  77554. scene: Scene;
  77555. /**
  77556. * The camera currently used for the rendering pass
  77557. */
  77558. camera: Nullable<Camera>;
  77559. /**
  77560. * The ID of the renderingGroup being processed
  77561. */
  77562. renderingGroupId: number;
  77563. }
  77564. /**
  77565. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77566. * It is enable to manage the different groups as well as the different necessary sort functions.
  77567. * This should not be used directly aside of the few static configurations
  77568. */
  77569. export class RenderingManager {
  77570. /**
  77571. * The max id used for rendering groups (not included)
  77572. */
  77573. static MAX_RENDERINGGROUPS: number;
  77574. /**
  77575. * The min id used for rendering groups (included)
  77576. */
  77577. static MIN_RENDERINGGROUPS: number;
  77578. /**
  77579. * Used to globally prevent autoclearing scenes.
  77580. */
  77581. static AUTOCLEAR: boolean;
  77582. /**
  77583. * @hidden
  77584. */
  77585. _useSceneAutoClearSetup: boolean;
  77586. private _scene;
  77587. private _renderingGroups;
  77588. private _depthStencilBufferAlreadyCleaned;
  77589. private _autoClearDepthStencil;
  77590. private _customOpaqueSortCompareFn;
  77591. private _customAlphaTestSortCompareFn;
  77592. private _customTransparentSortCompareFn;
  77593. private _renderingGroupInfo;
  77594. /**
  77595. * Instantiates a new rendering group for a particular scene
  77596. * @param scene Defines the scene the groups belongs to
  77597. */
  77598. constructor(scene: Scene);
  77599. private _clearDepthStencilBuffer;
  77600. /**
  77601. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77602. * @hidden
  77603. */
  77604. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77605. /**
  77606. * Resets the different information of the group to prepare a new frame
  77607. * @hidden
  77608. */
  77609. reset(): void;
  77610. /**
  77611. * Dispose and release the group and its associated resources.
  77612. * @hidden
  77613. */
  77614. dispose(): void;
  77615. /**
  77616. * Clear the info related to rendering groups preventing retention points during dispose.
  77617. */
  77618. freeRenderingGroups(): void;
  77619. private _prepareRenderingGroup;
  77620. /**
  77621. * Add a sprite manager to the rendering manager in order to render it this frame.
  77622. * @param spriteManager Define the sprite manager to render
  77623. */
  77624. dispatchSprites(spriteManager: ISpriteManager): void;
  77625. /**
  77626. * Add a particle system to the rendering manager in order to render it this frame.
  77627. * @param particleSystem Define the particle system to render
  77628. */
  77629. dispatchParticles(particleSystem: IParticleSystem): void;
  77630. /**
  77631. * Add a submesh to the manager in order to render it this frame
  77632. * @param subMesh The submesh to dispatch
  77633. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77634. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77635. */
  77636. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77637. /**
  77638. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77639. * This allowed control for front to back rendering or reversly depending of the special needs.
  77640. *
  77641. * @param renderingGroupId The rendering group id corresponding to its index
  77642. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77643. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77644. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77645. */
  77646. 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;
  77647. /**
  77648. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77649. *
  77650. * @param renderingGroupId The rendering group id corresponding to its index
  77651. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77652. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77653. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77654. */
  77655. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77656. /**
  77657. * Gets the current auto clear configuration for one rendering group of the rendering
  77658. * manager.
  77659. * @param index the rendering group index to get the information for
  77660. * @returns The auto clear setup for the requested rendering group
  77661. */
  77662. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77663. }
  77664. }
  77665. declare module BABYLON {
  77666. /**
  77667. * This Helps creating a texture that will be created from a camera in your scene.
  77668. * It is basically a dynamic texture that could be used to create special effects for instance.
  77669. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77670. */
  77671. export class RenderTargetTexture extends Texture {
  77672. isCube: boolean;
  77673. /**
  77674. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77675. */
  77676. static readonly REFRESHRATE_RENDER_ONCE: number;
  77677. /**
  77678. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77679. */
  77680. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77681. /**
  77682. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77683. * the central point of your effect and can save a lot of performances.
  77684. */
  77685. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77686. /**
  77687. * Use this predicate to dynamically define the list of mesh you want to render.
  77688. * If set, the renderList property will be overwritten.
  77689. */
  77690. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77691. private _renderList;
  77692. /**
  77693. * Use this list to define the list of mesh you want to render.
  77694. */
  77695. renderList: Nullable<Array<AbstractMesh>>;
  77696. private _hookArray;
  77697. /**
  77698. * Define if particles should be rendered in your texture.
  77699. */
  77700. renderParticles: boolean;
  77701. /**
  77702. * Define if sprites should be rendered in your texture.
  77703. */
  77704. renderSprites: boolean;
  77705. /**
  77706. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77707. */
  77708. coordinatesMode: number;
  77709. /**
  77710. * Define the camera used to render the texture.
  77711. */
  77712. activeCamera: Nullable<Camera>;
  77713. /**
  77714. * Override the render function of the texture with your own one.
  77715. */
  77716. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77717. /**
  77718. * Define if camera post processes should be use while rendering the texture.
  77719. */
  77720. useCameraPostProcesses: boolean;
  77721. /**
  77722. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77723. */
  77724. ignoreCameraViewport: boolean;
  77725. private _postProcessManager;
  77726. private _postProcesses;
  77727. private _resizeObserver;
  77728. /**
  77729. * An event triggered when the texture is unbind.
  77730. */
  77731. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77732. /**
  77733. * An event triggered when the texture is unbind.
  77734. */
  77735. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77736. private _onAfterUnbindObserver;
  77737. /**
  77738. * Set a after unbind callback in the texture.
  77739. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77740. */
  77741. onAfterUnbind: () => void;
  77742. /**
  77743. * An event triggered before rendering the texture
  77744. */
  77745. onBeforeRenderObservable: Observable<number>;
  77746. private _onBeforeRenderObserver;
  77747. /**
  77748. * Set a before render callback in the texture.
  77749. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77750. */
  77751. onBeforeRender: (faceIndex: number) => void;
  77752. /**
  77753. * An event triggered after rendering the texture
  77754. */
  77755. onAfterRenderObservable: Observable<number>;
  77756. private _onAfterRenderObserver;
  77757. /**
  77758. * Set a after render callback in the texture.
  77759. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77760. */
  77761. onAfterRender: (faceIndex: number) => void;
  77762. /**
  77763. * An event triggered after the texture clear
  77764. */
  77765. onClearObservable: Observable<Engine>;
  77766. private _onClearObserver;
  77767. /**
  77768. * Set a clear callback in the texture.
  77769. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77770. */
  77771. onClear: (Engine: Engine) => void;
  77772. /**
  77773. * Define the clear color of the Render Target if it should be different from the scene.
  77774. */
  77775. clearColor: Color4;
  77776. protected _size: number | {
  77777. width: number;
  77778. height: number;
  77779. };
  77780. protected _initialSizeParameter: number | {
  77781. width: number;
  77782. height: number;
  77783. } | {
  77784. ratio: number;
  77785. };
  77786. protected _sizeRatio: Nullable<number>;
  77787. /** @hidden */
  77788. _generateMipMaps: boolean;
  77789. protected _renderingManager: RenderingManager;
  77790. /** @hidden */
  77791. _waitingRenderList: string[];
  77792. protected _doNotChangeAspectRatio: boolean;
  77793. protected _currentRefreshId: number;
  77794. protected _refreshRate: number;
  77795. protected _textureMatrix: Matrix;
  77796. protected _samples: number;
  77797. protected _renderTargetOptions: RenderTargetCreationOptions;
  77798. /**
  77799. * Gets render target creation options that were used.
  77800. */
  77801. readonly renderTargetOptions: RenderTargetCreationOptions;
  77802. protected _engine: Engine;
  77803. protected _onRatioRescale(): void;
  77804. /**
  77805. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77806. * It must define where the camera used to render the texture is set
  77807. */
  77808. boundingBoxPosition: Vector3;
  77809. private _boundingBoxSize;
  77810. /**
  77811. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77812. * When defined, the cubemap will switch to local mode
  77813. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77814. * @example https://www.babylonjs-playground.com/#RNASML
  77815. */
  77816. boundingBoxSize: Vector3;
  77817. /**
  77818. * In case the RTT has been created with a depth texture, get the associated
  77819. * depth texture.
  77820. * Otherwise, return null.
  77821. */
  77822. depthStencilTexture: Nullable<InternalTexture>;
  77823. /**
  77824. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77825. * or used a shadow, depth texture...
  77826. * @param name The friendly name of the texture
  77827. * @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)
  77828. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77829. * @param generateMipMaps True if mip maps need to be generated after render.
  77830. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77831. * @param type The type of the buffer in the RTT (int, half float, float...)
  77832. * @param isCube True if a cube texture needs to be created
  77833. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77834. * @param generateDepthBuffer True to generate a depth buffer
  77835. * @param generateStencilBuffer True to generate a stencil buffer
  77836. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77837. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77838. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77839. */
  77840. constructor(name: string, size: number | {
  77841. width: number;
  77842. height: number;
  77843. } | {
  77844. ratio: number;
  77845. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77846. /**
  77847. * Creates a depth stencil texture.
  77848. * This is only available in WebGL 2 or with the depth texture extension available.
  77849. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77850. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77851. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77852. */
  77853. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77854. private _processSizeParameter;
  77855. /**
  77856. * Define the number of samples to use in case of MSAA.
  77857. * It defaults to one meaning no MSAA has been enabled.
  77858. */
  77859. samples: number;
  77860. /**
  77861. * Resets the refresh counter of the texture and start bak from scratch.
  77862. * Could be useful to regenerate the texture if it is setup to render only once.
  77863. */
  77864. resetRefreshCounter(): void;
  77865. /**
  77866. * Define the refresh rate of the texture or the rendering frequency.
  77867. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77868. */
  77869. refreshRate: number;
  77870. /**
  77871. * Adds a post process to the render target rendering passes.
  77872. * @param postProcess define the post process to add
  77873. */
  77874. addPostProcess(postProcess: PostProcess): void;
  77875. /**
  77876. * Clear all the post processes attached to the render target
  77877. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77878. */
  77879. clearPostProcesses(dispose?: boolean): void;
  77880. /**
  77881. * Remove one of the post process from the list of attached post processes to the texture
  77882. * @param postProcess define the post process to remove from the list
  77883. */
  77884. removePostProcess(postProcess: PostProcess): void;
  77885. /** @hidden */
  77886. _shouldRender(): boolean;
  77887. /**
  77888. * Gets the actual render size of the texture.
  77889. * @returns the width of the render size
  77890. */
  77891. getRenderSize(): number;
  77892. /**
  77893. * Gets the actual render width of the texture.
  77894. * @returns the width of the render size
  77895. */
  77896. getRenderWidth(): number;
  77897. /**
  77898. * Gets the actual render height of the texture.
  77899. * @returns the height of the render size
  77900. */
  77901. getRenderHeight(): number;
  77902. /**
  77903. * Get if the texture can be rescaled or not.
  77904. */
  77905. readonly canRescale: boolean;
  77906. /**
  77907. * Resize the texture using a ratio.
  77908. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77909. */
  77910. scale(ratio: number): void;
  77911. /**
  77912. * Get the texture reflection matrix used to rotate/transform the reflection.
  77913. * @returns the reflection matrix
  77914. */
  77915. getReflectionTextureMatrix(): Matrix;
  77916. /**
  77917. * Resize the texture to a new desired size.
  77918. * Be carrefull as it will recreate all the data in the new texture.
  77919. * @param size Define the new size. It can be:
  77920. * - a number for squared texture,
  77921. * - an object containing { width: number, height: number }
  77922. * - or an object containing a ratio { ratio: number }
  77923. */
  77924. resize(size: number | {
  77925. width: number;
  77926. height: number;
  77927. } | {
  77928. ratio: number;
  77929. }): void;
  77930. /**
  77931. * Renders all the objects from the render list into the texture.
  77932. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77933. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77934. */
  77935. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77936. private _bestReflectionRenderTargetDimension;
  77937. /**
  77938. * @hidden
  77939. * @param faceIndex face index to bind to if this is a cubetexture
  77940. */
  77941. _bindFrameBuffer(faceIndex?: number): void;
  77942. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77943. private renderToTarget;
  77944. /**
  77945. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77946. * This allowed control for front to back rendering or reversly depending of the special needs.
  77947. *
  77948. * @param renderingGroupId The rendering group id corresponding to its index
  77949. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77950. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77951. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77952. */
  77953. 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;
  77954. /**
  77955. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77956. *
  77957. * @param renderingGroupId The rendering group id corresponding to its index
  77958. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77959. */
  77960. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77961. /**
  77962. * Clones the texture.
  77963. * @returns the cloned texture
  77964. */
  77965. clone(): RenderTargetTexture;
  77966. /**
  77967. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77968. * @returns The JSON representation of the texture
  77969. */
  77970. serialize(): any;
  77971. /**
  77972. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77973. */
  77974. disposeFramebufferObjects(): void;
  77975. /**
  77976. * Dispose the texture and release its associated resources.
  77977. */
  77978. dispose(): void;
  77979. /** @hidden */
  77980. _rebuild(): void;
  77981. /**
  77982. * Clear the info related to rendering groups preventing retention point in material dispose.
  77983. */
  77984. freeRenderingGroups(): void;
  77985. /**
  77986. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77987. * @returns the view count
  77988. */
  77989. getViewCount(): number;
  77990. }
  77991. }
  77992. declare module BABYLON {
  77993. /**
  77994. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77995. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77996. * You can then easily use it as a reflectionTexture on a flat surface.
  77997. * In case the surface is not a plane, please consider relying on reflection probes.
  77998. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77999. */
  78000. export class MirrorTexture extends RenderTargetTexture {
  78001. private scene;
  78002. /**
  78003. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  78004. * 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.
  78005. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78006. */
  78007. mirrorPlane: Plane;
  78008. /**
  78009. * Define the blur ratio used to blur the reflection if needed.
  78010. */
  78011. blurRatio: number;
  78012. /**
  78013. * Define the adaptive blur kernel used to blur the reflection if needed.
  78014. * This will autocompute the closest best match for the `blurKernel`
  78015. */
  78016. adaptiveBlurKernel: number;
  78017. /**
  78018. * Define the blur kernel used to blur the reflection if needed.
  78019. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78020. */
  78021. blurKernel: number;
  78022. /**
  78023. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  78024. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78025. */
  78026. blurKernelX: number;
  78027. /**
  78028. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  78029. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78030. */
  78031. blurKernelY: number;
  78032. private _autoComputeBlurKernel;
  78033. protected _onRatioRescale(): void;
  78034. private _updateGammaSpace;
  78035. private _imageProcessingConfigChangeObserver;
  78036. private _transformMatrix;
  78037. private _mirrorMatrix;
  78038. private _savedViewMatrix;
  78039. private _blurX;
  78040. private _blurY;
  78041. private _adaptiveBlurKernel;
  78042. private _blurKernelX;
  78043. private _blurKernelY;
  78044. private _blurRatio;
  78045. /**
  78046. * Instantiates a Mirror Texture.
  78047. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78048. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78049. * You can then easily use it as a reflectionTexture on a flat surface.
  78050. * In case the surface is not a plane, please consider relying on reflection probes.
  78051. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78052. * @param name
  78053. * @param size
  78054. * @param scene
  78055. * @param generateMipMaps
  78056. * @param type
  78057. * @param samplingMode
  78058. * @param generateDepthBuffer
  78059. */
  78060. constructor(name: string, size: number | {
  78061. width: number;
  78062. height: number;
  78063. } | {
  78064. ratio: number;
  78065. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  78066. private _preparePostProcesses;
  78067. /**
  78068. * Clone the mirror texture.
  78069. * @returns the cloned texture
  78070. */
  78071. clone(): MirrorTexture;
  78072. /**
  78073. * Serialize the texture to a JSON representation you could use in Parse later on
  78074. * @returns the serialized JSON representation
  78075. */
  78076. serialize(): any;
  78077. /**
  78078. * Dispose the texture and release its associated resources.
  78079. */
  78080. dispose(): void;
  78081. }
  78082. }
  78083. declare module BABYLON {
  78084. /**
  78085. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78086. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78087. */
  78088. export class Texture extends BaseTexture {
  78089. /** @hidden */
  78090. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  78091. /** @hidden */
  78092. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  78093. /** @hidden */
  78094. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  78095. /** nearest is mag = nearest and min = nearest and mip = linear */
  78096. static readonly NEAREST_SAMPLINGMODE: number;
  78097. /** nearest is mag = nearest and min = nearest and mip = linear */
  78098. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  78099. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78100. static readonly BILINEAR_SAMPLINGMODE: number;
  78101. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78102. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  78103. /** Trilinear is mag = linear and min = linear and mip = linear */
  78104. static readonly TRILINEAR_SAMPLINGMODE: number;
  78105. /** Trilinear is mag = linear and min = linear and mip = linear */
  78106. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  78107. /** mag = nearest and min = nearest and mip = nearest */
  78108. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  78109. /** mag = nearest and min = linear and mip = nearest */
  78110. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  78111. /** mag = nearest and min = linear and mip = linear */
  78112. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  78113. /** mag = nearest and min = linear and mip = none */
  78114. static readonly NEAREST_LINEAR: number;
  78115. /** mag = nearest and min = nearest and mip = none */
  78116. static readonly NEAREST_NEAREST: number;
  78117. /** mag = linear and min = nearest and mip = nearest */
  78118. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  78119. /** mag = linear and min = nearest and mip = linear */
  78120. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  78121. /** mag = linear and min = linear and mip = none */
  78122. static readonly LINEAR_LINEAR: number;
  78123. /** mag = linear and min = nearest and mip = none */
  78124. static readonly LINEAR_NEAREST: number;
  78125. /** Explicit coordinates mode */
  78126. static readonly EXPLICIT_MODE: number;
  78127. /** Spherical coordinates mode */
  78128. static readonly SPHERICAL_MODE: number;
  78129. /** Planar coordinates mode */
  78130. static readonly PLANAR_MODE: number;
  78131. /** Cubic coordinates mode */
  78132. static readonly CUBIC_MODE: number;
  78133. /** Projection coordinates mode */
  78134. static readonly PROJECTION_MODE: number;
  78135. /** Inverse Cubic coordinates mode */
  78136. static readonly SKYBOX_MODE: number;
  78137. /** Inverse Cubic coordinates mode */
  78138. static readonly INVCUBIC_MODE: number;
  78139. /** Equirectangular coordinates mode */
  78140. static readonly EQUIRECTANGULAR_MODE: number;
  78141. /** Equirectangular Fixed coordinates mode */
  78142. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  78143. /** Equirectangular Fixed Mirrored coordinates mode */
  78144. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78145. /** Texture is not repeating outside of 0..1 UVs */
  78146. static readonly CLAMP_ADDRESSMODE: number;
  78147. /** Texture is repeating outside of 0..1 UVs */
  78148. static readonly WRAP_ADDRESSMODE: number;
  78149. /** Texture is repeating and mirrored */
  78150. static readonly MIRROR_ADDRESSMODE: number;
  78151. /**
  78152. * 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
  78153. */
  78154. static UseSerializedUrlIfAny: boolean;
  78155. /**
  78156. * Define the url of the texture.
  78157. */
  78158. url: Nullable<string>;
  78159. /**
  78160. * Define an offset on the texture to offset the u coordinates of the UVs
  78161. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78162. */
  78163. uOffset: number;
  78164. /**
  78165. * Define an offset on the texture to offset the v coordinates of the UVs
  78166. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78167. */
  78168. vOffset: number;
  78169. /**
  78170. * Define an offset on the texture to scale the u coordinates of the UVs
  78171. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78172. */
  78173. uScale: number;
  78174. /**
  78175. * Define an offset on the texture to scale the v coordinates of the UVs
  78176. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78177. */
  78178. vScale: number;
  78179. /**
  78180. * Define an offset on the texture to rotate around the u coordinates of the UVs
  78181. * @see http://doc.babylonjs.com/how_to/more_materials
  78182. */
  78183. uAng: number;
  78184. /**
  78185. * Define an offset on the texture to rotate around the v coordinates of the UVs
  78186. * @see http://doc.babylonjs.com/how_to/more_materials
  78187. */
  78188. vAng: number;
  78189. /**
  78190. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  78191. * @see http://doc.babylonjs.com/how_to/more_materials
  78192. */
  78193. wAng: number;
  78194. /**
  78195. * Defines the center of rotation (U)
  78196. */
  78197. uRotationCenter: number;
  78198. /**
  78199. * Defines the center of rotation (V)
  78200. */
  78201. vRotationCenter: number;
  78202. /**
  78203. * Defines the center of rotation (W)
  78204. */
  78205. wRotationCenter: number;
  78206. /**
  78207. * Are mip maps generated for this texture or not.
  78208. */
  78209. readonly noMipmap: boolean;
  78210. /**
  78211. * List of inspectable custom properties (used by the Inspector)
  78212. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78213. */
  78214. inspectableCustomProperties: Nullable<IInspectable[]>;
  78215. private _noMipmap;
  78216. /** @hidden */
  78217. _invertY: boolean;
  78218. private _rowGenerationMatrix;
  78219. private _cachedTextureMatrix;
  78220. private _projectionModeMatrix;
  78221. private _t0;
  78222. private _t1;
  78223. private _t2;
  78224. private _cachedUOffset;
  78225. private _cachedVOffset;
  78226. private _cachedUScale;
  78227. private _cachedVScale;
  78228. private _cachedUAng;
  78229. private _cachedVAng;
  78230. private _cachedWAng;
  78231. private _cachedProjectionMatrixId;
  78232. private _cachedCoordinatesMode;
  78233. /** @hidden */
  78234. protected _initialSamplingMode: number;
  78235. /** @hidden */
  78236. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  78237. private _deleteBuffer;
  78238. protected _format: Nullable<number>;
  78239. private _delayedOnLoad;
  78240. private _delayedOnError;
  78241. /**
  78242. * Observable triggered once the texture has been loaded.
  78243. */
  78244. onLoadObservable: Observable<Texture>;
  78245. protected _isBlocking: boolean;
  78246. /**
  78247. * Is the texture preventing material to render while loading.
  78248. * If false, a default texture will be used instead of the loading one during the preparation step.
  78249. */
  78250. isBlocking: boolean;
  78251. /**
  78252. * Get the current sampling mode associated with the texture.
  78253. */
  78254. readonly samplingMode: number;
  78255. /**
  78256. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  78257. */
  78258. readonly invertY: boolean;
  78259. /**
  78260. * Instantiates a new texture.
  78261. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78262. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78263. * @param url define the url of the picture to load as a texture
  78264. * @param scene define the scene the texture will belong to
  78265. * @param noMipmap define if the texture will require mip maps or not
  78266. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78267. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78268. * @param onLoad define a callback triggered when the texture has been loaded
  78269. * @param onError define a callback triggered when an error occurred during the loading session
  78270. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78271. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78272. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78273. */
  78274. 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);
  78275. /**
  78276. * Update the url (and optional buffer) of this texture if url was null during construction.
  78277. * @param url the url of the texture
  78278. * @param buffer the buffer of the texture (defaults to null)
  78279. * @param onLoad callback called when the texture is loaded (defaults to null)
  78280. */
  78281. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  78282. /**
  78283. * Finish the loading sequence of a texture flagged as delayed load.
  78284. * @hidden
  78285. */
  78286. delayLoad(): void;
  78287. private _prepareRowForTextureGeneration;
  78288. /**
  78289. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  78290. * @returns the transform matrix of the texture.
  78291. */
  78292. getTextureMatrix(): Matrix;
  78293. /**
  78294. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  78295. * @returns The reflection texture transform
  78296. */
  78297. getReflectionTextureMatrix(): Matrix;
  78298. /**
  78299. * Clones the texture.
  78300. * @returns the cloned texture
  78301. */
  78302. clone(): Texture;
  78303. /**
  78304. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78305. * @returns The JSON representation of the texture
  78306. */
  78307. serialize(): any;
  78308. /**
  78309. * Get the current class name of the texture useful for serialization or dynamic coding.
  78310. * @returns "Texture"
  78311. */
  78312. getClassName(): string;
  78313. /**
  78314. * Dispose the texture and release its associated resources.
  78315. */
  78316. dispose(): void;
  78317. /**
  78318. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78319. * @param parsedTexture Define the JSON representation of the texture
  78320. * @param scene Define the scene the parsed texture should be instantiated in
  78321. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78322. * @returns The parsed texture if successful
  78323. */
  78324. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78325. /**
  78326. * Creates a texture from its base 64 representation.
  78327. * @param data Define the base64 payload without the data: prefix
  78328. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78329. * @param scene Define the scene the texture should belong to
  78330. * @param noMipmap Forces the texture to not create mip map information if true
  78331. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78332. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78333. * @param onLoad define a callback triggered when the texture has been loaded
  78334. * @param onError define a callback triggered when an error occurred during the loading session
  78335. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78336. * @returns the created texture
  78337. */
  78338. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78339. /**
  78340. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78341. * @param data Define the base64 payload without the data: prefix
  78342. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78343. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78344. * @param scene Define the scene the texture should belong to
  78345. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78346. * @param noMipmap Forces the texture to not create mip map information if true
  78347. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78348. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78349. * @param onLoad define a callback triggered when the texture has been loaded
  78350. * @param onError define a callback triggered when an error occurred during the loading session
  78351. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78352. * @returns the created texture
  78353. */
  78354. 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;
  78355. }
  78356. }
  78357. declare module BABYLON {
  78358. interface Engine {
  78359. /**
  78360. * Creates a raw texture
  78361. * @param data defines the data to store in the texture
  78362. * @param width defines the width of the texture
  78363. * @param height defines the height of the texture
  78364. * @param format defines the format of the data
  78365. * @param generateMipMaps defines if the engine should generate the mip levels
  78366. * @param invertY defines if data must be stored with Y axis inverted
  78367. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78368. * @param compression defines the compression used (null by default)
  78369. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78370. * @returns the raw texture inside an InternalTexture
  78371. */
  78372. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78373. /**
  78374. * Update a raw texture
  78375. * @param texture defines the texture to update
  78376. * @param data defines the data to store in the texture
  78377. * @param format defines the format of the data
  78378. * @param invertY defines if data must be stored with Y axis inverted
  78379. */
  78380. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78381. /**
  78382. * Update a raw texture
  78383. * @param texture defines the texture to update
  78384. * @param data defines the data to store in the texture
  78385. * @param format defines the format of the data
  78386. * @param invertY defines if data must be stored with Y axis inverted
  78387. * @param compression defines the compression used (null by default)
  78388. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78389. */
  78390. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78391. /**
  78392. * Creates a new raw cube texture
  78393. * @param data defines the array of data to use to create each face
  78394. * @param size defines the size of the textures
  78395. * @param format defines the format of the data
  78396. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78397. * @param generateMipMaps defines if the engine should generate the mip levels
  78398. * @param invertY defines if data must be stored with Y axis inverted
  78399. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78400. * @param compression defines the compression used (null by default)
  78401. * @returns the cube texture as an InternalTexture
  78402. */
  78403. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78404. /**
  78405. * Update a raw cube texture
  78406. * @param texture defines the texture to udpdate
  78407. * @param data defines the data to store
  78408. * @param format defines the data format
  78409. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78410. * @param invertY defines if data must be stored with Y axis inverted
  78411. */
  78412. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78413. /**
  78414. * Update a raw cube texture
  78415. * @param texture defines the texture to udpdate
  78416. * @param data defines the data to store
  78417. * @param format defines the data format
  78418. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78419. * @param invertY defines if data must be stored with Y axis inverted
  78420. * @param compression defines the compression used (null by default)
  78421. */
  78422. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78423. /**
  78424. * Update a raw cube texture
  78425. * @param texture defines the texture to udpdate
  78426. * @param data defines the data to store
  78427. * @param format defines the data format
  78428. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78429. * @param invertY defines if data must be stored with Y axis inverted
  78430. * @param compression defines the compression used (null by default)
  78431. * @param level defines which level of the texture to update
  78432. */
  78433. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78434. /**
  78435. * Creates a new raw cube texture from a specified url
  78436. * @param url defines the url where the data is located
  78437. * @param scene defines the current scene
  78438. * @param size defines the size of the textures
  78439. * @param format defines the format of the data
  78440. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78441. * @param noMipmap defines if the engine should avoid generating the mip levels
  78442. * @param callback defines a callback used to extract texture data from loaded data
  78443. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78444. * @param onLoad defines a callback called when texture is loaded
  78445. * @param onError defines a callback called if there is an error
  78446. * @returns the cube texture as an InternalTexture
  78447. */
  78448. 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;
  78449. /**
  78450. * Creates a new raw cube texture from a specified url
  78451. * @param url defines the url where the data is located
  78452. * @param scene defines the current scene
  78453. * @param size defines the size of the textures
  78454. * @param format defines the format of the data
  78455. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78456. * @param noMipmap defines if the engine should avoid generating the mip levels
  78457. * @param callback defines a callback used to extract texture data from loaded data
  78458. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78459. * @param onLoad defines a callback called when texture is loaded
  78460. * @param onError defines a callback called if there is an error
  78461. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78462. * @param invertY defines if data must be stored with Y axis inverted
  78463. * @returns the cube texture as an InternalTexture
  78464. */
  78465. 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;
  78466. /**
  78467. * Creates a new raw 3D texture
  78468. * @param data defines the data used to create the texture
  78469. * @param width defines the width of the texture
  78470. * @param height defines the height of the texture
  78471. * @param depth defines the depth of the texture
  78472. * @param format defines the format of the texture
  78473. * @param generateMipMaps defines if the engine must generate mip levels
  78474. * @param invertY defines if data must be stored with Y axis inverted
  78475. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78476. * @param compression defines the compressed used (can be null)
  78477. * @param textureType defines the compressed used (can be null)
  78478. * @returns a new raw 3D texture (stored in an InternalTexture)
  78479. */
  78480. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78481. /**
  78482. * Update a raw 3D texture
  78483. * @param texture defines the texture to update
  78484. * @param data defines the data to store
  78485. * @param format defines the data format
  78486. * @param invertY defines if data must be stored with Y axis inverted
  78487. */
  78488. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78489. /**
  78490. * Update a raw 3D texture
  78491. * @param texture defines the texture to update
  78492. * @param data defines the data to store
  78493. * @param format defines the data format
  78494. * @param invertY defines if data must be stored with Y axis inverted
  78495. * @param compression defines the used compression (can be null)
  78496. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78497. */
  78498. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78499. }
  78500. }
  78501. declare module BABYLON {
  78502. /**
  78503. * Raw texture can help creating a texture directly from an array of data.
  78504. * This can be super useful if you either get the data from an uncompressed source or
  78505. * if you wish to create your texture pixel by pixel.
  78506. */
  78507. export class RawTexture extends Texture {
  78508. /**
  78509. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78510. */
  78511. format: number;
  78512. private _engine;
  78513. /**
  78514. * Instantiates a new RawTexture.
  78515. * Raw texture can help creating a texture directly from an array of data.
  78516. * This can be super useful if you either get the data from an uncompressed source or
  78517. * if you wish to create your texture pixel by pixel.
  78518. * @param data define the array of data to use to create the texture
  78519. * @param width define the width of the texture
  78520. * @param height define the height of the texture
  78521. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78522. * @param scene define the scene the texture belongs to
  78523. * @param generateMipMaps define whether mip maps should be generated or not
  78524. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78525. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78526. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78527. */
  78528. constructor(data: ArrayBufferView, width: number, height: number,
  78529. /**
  78530. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78531. */
  78532. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78533. /**
  78534. * Updates the texture underlying data.
  78535. * @param data Define the new data of the texture
  78536. */
  78537. update(data: ArrayBufferView): void;
  78538. /**
  78539. * Creates a luminance texture from some data.
  78540. * @param data Define the texture data
  78541. * @param width Define the width of the texture
  78542. * @param height Define the height of the texture
  78543. * @param scene Define the scene the texture belongs to
  78544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78547. * @returns the luminance texture
  78548. */
  78549. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78550. /**
  78551. * Creates a luminance alpha texture from some data.
  78552. * @param data Define the texture data
  78553. * @param width Define the width of the texture
  78554. * @param height Define the height of the texture
  78555. * @param scene Define the scene the texture belongs to
  78556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78559. * @returns the luminance alpha texture
  78560. */
  78561. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78562. /**
  78563. * Creates an alpha texture from some data.
  78564. * @param data Define the texture data
  78565. * @param width Define the width of the texture
  78566. * @param height Define the height of the texture
  78567. * @param scene Define the scene the texture belongs to
  78568. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78569. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78570. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78571. * @returns the alpha texture
  78572. */
  78573. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78574. /**
  78575. * Creates a RGB texture from some data.
  78576. * @param data Define the texture data
  78577. * @param width Define the width of the texture
  78578. * @param height Define the height of the texture
  78579. * @param scene Define the scene the texture belongs to
  78580. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78581. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78582. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78583. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78584. * @returns the RGB alpha texture
  78585. */
  78586. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78587. /**
  78588. * Creates a RGBA texture from some data.
  78589. * @param data Define the texture data
  78590. * @param width Define the width of the texture
  78591. * @param height Define the height of the texture
  78592. * @param scene Define the scene the texture belongs to
  78593. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78594. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78595. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78596. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78597. * @returns the RGBA texture
  78598. */
  78599. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78600. /**
  78601. * Creates a R texture from some data.
  78602. * @param data Define the texture data
  78603. * @param width Define the width of the texture
  78604. * @param height Define the height of the texture
  78605. * @param scene Define the scene the texture belongs to
  78606. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78607. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78608. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78609. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78610. * @returns the R texture
  78611. */
  78612. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78613. }
  78614. }
  78615. declare module BABYLON {
  78616. /**
  78617. * Defines a runtime animation
  78618. */
  78619. export class RuntimeAnimation {
  78620. private _events;
  78621. /**
  78622. * The current frame of the runtime animation
  78623. */
  78624. private _currentFrame;
  78625. /**
  78626. * The animation used by the runtime animation
  78627. */
  78628. private _animation;
  78629. /**
  78630. * The target of the runtime animation
  78631. */
  78632. private _target;
  78633. /**
  78634. * The initiating animatable
  78635. */
  78636. private _host;
  78637. /**
  78638. * The original value of the runtime animation
  78639. */
  78640. private _originalValue;
  78641. /**
  78642. * The original blend value of the runtime animation
  78643. */
  78644. private _originalBlendValue;
  78645. /**
  78646. * The offsets cache of the runtime animation
  78647. */
  78648. private _offsetsCache;
  78649. /**
  78650. * The high limits cache of the runtime animation
  78651. */
  78652. private _highLimitsCache;
  78653. /**
  78654. * Specifies if the runtime animation has been stopped
  78655. */
  78656. private _stopped;
  78657. /**
  78658. * The blending factor of the runtime animation
  78659. */
  78660. private _blendingFactor;
  78661. /**
  78662. * The BabylonJS scene
  78663. */
  78664. private _scene;
  78665. /**
  78666. * The current value of the runtime animation
  78667. */
  78668. private _currentValue;
  78669. /** @hidden */
  78670. _animationState: _IAnimationState;
  78671. /**
  78672. * The active target of the runtime animation
  78673. */
  78674. private _activeTargets;
  78675. private _currentActiveTarget;
  78676. private _directTarget;
  78677. /**
  78678. * The target path of the runtime animation
  78679. */
  78680. private _targetPath;
  78681. /**
  78682. * The weight of the runtime animation
  78683. */
  78684. private _weight;
  78685. /**
  78686. * The ratio offset of the runtime animation
  78687. */
  78688. private _ratioOffset;
  78689. /**
  78690. * The previous delay of the runtime animation
  78691. */
  78692. private _previousDelay;
  78693. /**
  78694. * The previous ratio of the runtime animation
  78695. */
  78696. private _previousRatio;
  78697. private _enableBlending;
  78698. private _keys;
  78699. private _minFrame;
  78700. private _maxFrame;
  78701. private _minValue;
  78702. private _maxValue;
  78703. private _targetIsArray;
  78704. /**
  78705. * Gets the current frame of the runtime animation
  78706. */
  78707. readonly currentFrame: number;
  78708. /**
  78709. * Gets the weight of the runtime animation
  78710. */
  78711. readonly weight: number;
  78712. /**
  78713. * Gets the current value of the runtime animation
  78714. */
  78715. readonly currentValue: any;
  78716. /**
  78717. * Gets the target path of the runtime animation
  78718. */
  78719. readonly targetPath: string;
  78720. /**
  78721. * Gets the actual target of the runtime animation
  78722. */
  78723. readonly target: any;
  78724. /** @hidden */
  78725. _onLoop: () => void;
  78726. /**
  78727. * Create a new RuntimeAnimation object
  78728. * @param target defines the target of the animation
  78729. * @param animation defines the source animation object
  78730. * @param scene defines the hosting scene
  78731. * @param host defines the initiating Animatable
  78732. */
  78733. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78734. private _preparePath;
  78735. /**
  78736. * Gets the animation from the runtime animation
  78737. */
  78738. readonly animation: Animation;
  78739. /**
  78740. * Resets the runtime animation to the beginning
  78741. * @param restoreOriginal defines whether to restore the target property to the original value
  78742. */
  78743. reset(restoreOriginal?: boolean): void;
  78744. /**
  78745. * Specifies if the runtime animation is stopped
  78746. * @returns Boolean specifying if the runtime animation is stopped
  78747. */
  78748. isStopped(): boolean;
  78749. /**
  78750. * Disposes of the runtime animation
  78751. */
  78752. dispose(): void;
  78753. /**
  78754. * Apply the interpolated value to the target
  78755. * @param currentValue defines the value computed by the animation
  78756. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78757. */
  78758. setValue(currentValue: any, weight: number): void;
  78759. private _getOriginalValues;
  78760. private _setValue;
  78761. /**
  78762. * Gets the loop pmode of the runtime animation
  78763. * @returns Loop Mode
  78764. */
  78765. private _getCorrectLoopMode;
  78766. /**
  78767. * Move the current animation to a given frame
  78768. * @param frame defines the frame to move to
  78769. */
  78770. goToFrame(frame: number): void;
  78771. /**
  78772. * @hidden Internal use only
  78773. */
  78774. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78775. /**
  78776. * Execute the current animation
  78777. * @param delay defines the delay to add to the current frame
  78778. * @param from defines the lower bound of the animation range
  78779. * @param to defines the upper bound of the animation range
  78780. * @param loop defines if the current animation must loop
  78781. * @param speedRatio defines the current speed ratio
  78782. * @param weight defines the weight of the animation (default is -1 so no weight)
  78783. * @param onLoop optional callback called when animation loops
  78784. * @returns a boolean indicating if the animation is running
  78785. */
  78786. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78787. }
  78788. }
  78789. declare module BABYLON {
  78790. /**
  78791. * Class used to store an actual running animation
  78792. */
  78793. export class Animatable {
  78794. /** defines the target object */
  78795. target: any;
  78796. /** defines the starting frame number (default is 0) */
  78797. fromFrame: number;
  78798. /** defines the ending frame number (default is 100) */
  78799. toFrame: number;
  78800. /** defines if the animation must loop (default is false) */
  78801. loopAnimation: boolean;
  78802. /** defines a callback to call when animation ends if it is not looping */
  78803. onAnimationEnd?: (() => void) | null | undefined;
  78804. /** defines a callback to call when animation loops */
  78805. onAnimationLoop?: (() => void) | null | undefined;
  78806. private _localDelayOffset;
  78807. private _pausedDelay;
  78808. private _runtimeAnimations;
  78809. private _paused;
  78810. private _scene;
  78811. private _speedRatio;
  78812. private _weight;
  78813. private _syncRoot;
  78814. /**
  78815. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78816. * This will only apply for non looping animation (default is true)
  78817. */
  78818. disposeOnEnd: boolean;
  78819. /**
  78820. * Gets a boolean indicating if the animation has started
  78821. */
  78822. animationStarted: boolean;
  78823. /**
  78824. * Observer raised when the animation ends
  78825. */
  78826. onAnimationEndObservable: Observable<Animatable>;
  78827. /**
  78828. * Observer raised when the animation loops
  78829. */
  78830. onAnimationLoopObservable: Observable<Animatable>;
  78831. /**
  78832. * Gets the root Animatable used to synchronize and normalize animations
  78833. */
  78834. readonly syncRoot: Nullable<Animatable>;
  78835. /**
  78836. * Gets the current frame of the first RuntimeAnimation
  78837. * Used to synchronize Animatables
  78838. */
  78839. readonly masterFrame: number;
  78840. /**
  78841. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78842. */
  78843. weight: number;
  78844. /**
  78845. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78846. */
  78847. speedRatio: number;
  78848. /**
  78849. * Creates a new Animatable
  78850. * @param scene defines the hosting scene
  78851. * @param target defines the target object
  78852. * @param fromFrame defines the starting frame number (default is 0)
  78853. * @param toFrame defines the ending frame number (default is 100)
  78854. * @param loopAnimation defines if the animation must loop (default is false)
  78855. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78856. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78857. * @param animations defines a group of animation to add to the new Animatable
  78858. * @param onAnimationLoop defines a callback to call when animation loops
  78859. */
  78860. constructor(scene: Scene,
  78861. /** defines the target object */
  78862. target: any,
  78863. /** defines the starting frame number (default is 0) */
  78864. fromFrame?: number,
  78865. /** defines the ending frame number (default is 100) */
  78866. toFrame?: number,
  78867. /** defines if the animation must loop (default is false) */
  78868. loopAnimation?: boolean, speedRatio?: number,
  78869. /** defines a callback to call when animation ends if it is not looping */
  78870. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78871. /** defines a callback to call when animation loops */
  78872. onAnimationLoop?: (() => void) | null | undefined);
  78873. /**
  78874. * Synchronize and normalize current Animatable with a source Animatable
  78875. * This is useful when using animation weights and when animations are not of the same length
  78876. * @param root defines the root Animatable to synchronize with
  78877. * @returns the current Animatable
  78878. */
  78879. syncWith(root: Animatable): Animatable;
  78880. /**
  78881. * Gets the list of runtime animations
  78882. * @returns an array of RuntimeAnimation
  78883. */
  78884. getAnimations(): RuntimeAnimation[];
  78885. /**
  78886. * Adds more animations to the current animatable
  78887. * @param target defines the target of the animations
  78888. * @param animations defines the new animations to add
  78889. */
  78890. appendAnimations(target: any, animations: Animation[]): void;
  78891. /**
  78892. * Gets the source animation for a specific property
  78893. * @param property defines the propertyu to look for
  78894. * @returns null or the source animation for the given property
  78895. */
  78896. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78897. /**
  78898. * Gets the runtime animation for a specific property
  78899. * @param property defines the propertyu to look for
  78900. * @returns null or the runtime animation for the given property
  78901. */
  78902. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78903. /**
  78904. * Resets the animatable to its original state
  78905. */
  78906. reset(): void;
  78907. /**
  78908. * Allows the animatable to blend with current running animations
  78909. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78910. * @param blendingSpeed defines the blending speed to use
  78911. */
  78912. enableBlending(blendingSpeed: number): void;
  78913. /**
  78914. * Disable animation blending
  78915. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78916. */
  78917. disableBlending(): void;
  78918. /**
  78919. * Jump directly to a given frame
  78920. * @param frame defines the frame to jump to
  78921. */
  78922. goToFrame(frame: number): void;
  78923. /**
  78924. * Pause the animation
  78925. */
  78926. pause(): void;
  78927. /**
  78928. * Restart the animation
  78929. */
  78930. restart(): void;
  78931. private _raiseOnAnimationEnd;
  78932. /**
  78933. * Stop and delete the current animation
  78934. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78935. * @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)
  78936. */
  78937. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78938. /**
  78939. * Wait asynchronously for the animation to end
  78940. * @returns a promise which will be fullfilled when the animation ends
  78941. */
  78942. waitAsync(): Promise<Animatable>;
  78943. /** @hidden */
  78944. _animate(delay: number): boolean;
  78945. }
  78946. interface Scene {
  78947. /** @hidden */
  78948. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78949. /** @hidden */
  78950. _processLateAnimationBindingsForMatrices(holder: {
  78951. totalWeight: number;
  78952. animations: RuntimeAnimation[];
  78953. originalValue: Matrix;
  78954. }): any;
  78955. /** @hidden */
  78956. _processLateAnimationBindingsForQuaternions(holder: {
  78957. totalWeight: number;
  78958. animations: RuntimeAnimation[];
  78959. originalValue: Quaternion;
  78960. }, refQuaternion: Quaternion): Quaternion;
  78961. /** @hidden */
  78962. _processLateAnimationBindings(): void;
  78963. /**
  78964. * Will start the animation sequence of a given target
  78965. * @param target defines the target
  78966. * @param from defines from which frame should animation start
  78967. * @param to defines until which frame should animation run.
  78968. * @param weight defines the weight to apply to the animation (1.0 by default)
  78969. * @param loop defines if the animation loops
  78970. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78971. * @param onAnimationEnd defines the function to be executed when the animation ends
  78972. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78973. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78974. * @param onAnimationLoop defines the callback to call when an animation loops
  78975. * @returns the animatable object created for this animation
  78976. */
  78977. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78978. /**
  78979. * Will start the animation sequence of a given target
  78980. * @param target defines the target
  78981. * @param from defines from which frame should animation start
  78982. * @param to defines until which frame should animation run.
  78983. * @param loop defines if the animation loops
  78984. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78985. * @param onAnimationEnd defines the function to be executed when the animation ends
  78986. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78987. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78988. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78989. * @param onAnimationLoop defines the callback to call when an animation loops
  78990. * @returns the animatable object created for this animation
  78991. */
  78992. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78993. /**
  78994. * Will start the animation sequence of a given target and its hierarchy
  78995. * @param target defines the target
  78996. * @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.
  78997. * @param from defines from which frame should animation start
  78998. * @param to defines until which frame should animation run.
  78999. * @param loop defines if the animation loops
  79000. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79001. * @param onAnimationEnd defines the function to be executed when the animation ends
  79002. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79003. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79004. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79005. * @param onAnimationLoop defines the callback to call when an animation loops
  79006. * @returns the list of created animatables
  79007. */
  79008. 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[];
  79009. /**
  79010. * Begin a new animation on a given node
  79011. * @param target defines the target where the animation will take place
  79012. * @param animations defines the list of animations to start
  79013. * @param from defines the initial value
  79014. * @param to defines the final value
  79015. * @param loop defines if you want animation to loop (off by default)
  79016. * @param speedRatio defines the speed ratio to apply to all animations
  79017. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79018. * @param onAnimationLoop defines the callback to call when an animation loops
  79019. * @returns the list of created animatables
  79020. */
  79021. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79022. /**
  79023. * Begin a new animation on a given node and its hierarchy
  79024. * @param target defines the root node where the animation will take place
  79025. * @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.
  79026. * @param animations defines the list of animations to start
  79027. * @param from defines the initial value
  79028. * @param to defines the final value
  79029. * @param loop defines if you want animation to loop (off by default)
  79030. * @param speedRatio defines the speed ratio to apply to all animations
  79031. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79032. * @param onAnimationLoop defines the callback to call when an animation loops
  79033. * @returns the list of animatables created for all nodes
  79034. */
  79035. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79036. /**
  79037. * Gets the animatable associated with a specific target
  79038. * @param target defines the target of the animatable
  79039. * @returns the required animatable if found
  79040. */
  79041. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79042. /**
  79043. * Gets all animatables associated with a given target
  79044. * @param target defines the target to look animatables for
  79045. * @returns an array of Animatables
  79046. */
  79047. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79048. /**
  79049. * Stops and removes all animations that have been applied to the scene
  79050. */
  79051. stopAllAnimations(): void;
  79052. }
  79053. interface Bone {
  79054. /**
  79055. * Copy an animation range from another bone
  79056. * @param source defines the source bone
  79057. * @param rangeName defines the range name to copy
  79058. * @param frameOffset defines the frame offset
  79059. * @param rescaleAsRequired defines if rescaling must be applied if required
  79060. * @param skelDimensionsRatio defines the scaling ratio
  79061. * @returns true if operation was successful
  79062. */
  79063. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79064. }
  79065. }
  79066. declare module BABYLON {
  79067. /**
  79068. * Class used to handle skinning animations
  79069. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79070. */
  79071. export class Skeleton implements IAnimatable {
  79072. /** defines the skeleton name */
  79073. name: string;
  79074. /** defines the skeleton Id */
  79075. id: string;
  79076. /**
  79077. * Defines the list of child bones
  79078. */
  79079. bones: Bone[];
  79080. /**
  79081. * Defines an estimate of the dimension of the skeleton at rest
  79082. */
  79083. dimensionsAtRest: Vector3;
  79084. /**
  79085. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79086. */
  79087. needInitialSkinMatrix: boolean;
  79088. /**
  79089. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79090. */
  79091. overrideMesh: Nullable<AbstractMesh>;
  79092. /**
  79093. * Gets the list of animations attached to this skeleton
  79094. */
  79095. animations: Array<Animation>;
  79096. private _scene;
  79097. private _isDirty;
  79098. private _transformMatrices;
  79099. private _transformMatrixTexture;
  79100. private _meshesWithPoseMatrix;
  79101. private _animatables;
  79102. private _identity;
  79103. private _synchronizedWithMesh;
  79104. private _ranges;
  79105. private _lastAbsoluteTransformsUpdateId;
  79106. private _canUseTextureForBones;
  79107. private _uniqueId;
  79108. /** @hidden */
  79109. _numBonesWithLinkedTransformNode: number;
  79110. /** @hidden */
  79111. _hasWaitingData: Nullable<boolean>;
  79112. /**
  79113. * Specifies if the skeleton should be serialized
  79114. */
  79115. doNotSerialize: boolean;
  79116. private _useTextureToStoreBoneMatrices;
  79117. /**
  79118. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79119. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79120. */
  79121. useTextureToStoreBoneMatrices: boolean;
  79122. private _animationPropertiesOverride;
  79123. /**
  79124. * Gets or sets the animation properties override
  79125. */
  79126. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79127. /**
  79128. * List of inspectable custom properties (used by the Inspector)
  79129. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79130. */
  79131. inspectableCustomProperties: IInspectable[];
  79132. /**
  79133. * An observable triggered before computing the skeleton's matrices
  79134. */
  79135. onBeforeComputeObservable: Observable<Skeleton>;
  79136. /**
  79137. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79138. */
  79139. readonly isUsingTextureForMatrices: boolean;
  79140. /**
  79141. * Gets the unique ID of this skeleton
  79142. */
  79143. readonly uniqueId: number;
  79144. /**
  79145. * Creates a new skeleton
  79146. * @param name defines the skeleton name
  79147. * @param id defines the skeleton Id
  79148. * @param scene defines the hosting scene
  79149. */
  79150. constructor(
  79151. /** defines the skeleton name */
  79152. name: string,
  79153. /** defines the skeleton Id */
  79154. id: string, scene: Scene);
  79155. /**
  79156. * Gets the current object class name.
  79157. * @return the class name
  79158. */
  79159. getClassName(): string;
  79160. /**
  79161. * Returns an array containing the root bones
  79162. * @returns an array containing the root bones
  79163. */
  79164. getChildren(): Array<Bone>;
  79165. /**
  79166. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79167. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79168. * @returns a Float32Array containing matrices data
  79169. */
  79170. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79171. /**
  79172. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79173. * @returns a raw texture containing the data
  79174. */
  79175. getTransformMatrixTexture(): Nullable<RawTexture>;
  79176. /**
  79177. * Gets the current hosting scene
  79178. * @returns a scene object
  79179. */
  79180. getScene(): Scene;
  79181. /**
  79182. * Gets a string representing the current skeleton data
  79183. * @param fullDetails defines a boolean indicating if we want a verbose version
  79184. * @returns a string representing the current skeleton data
  79185. */
  79186. toString(fullDetails?: boolean): string;
  79187. /**
  79188. * Get bone's index searching by name
  79189. * @param name defines bone's name to search for
  79190. * @return the indice of the bone. Returns -1 if not found
  79191. */
  79192. getBoneIndexByName(name: string): number;
  79193. /**
  79194. * Creater a new animation range
  79195. * @param name defines the name of the range
  79196. * @param from defines the start key
  79197. * @param to defines the end key
  79198. */
  79199. createAnimationRange(name: string, from: number, to: number): void;
  79200. /**
  79201. * Delete a specific animation range
  79202. * @param name defines the name of the range
  79203. * @param deleteFrames defines if frames must be removed as well
  79204. */
  79205. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79206. /**
  79207. * Gets a specific animation range
  79208. * @param name defines the name of the range to look for
  79209. * @returns the requested animation range or null if not found
  79210. */
  79211. getAnimationRange(name: string): Nullable<AnimationRange>;
  79212. /**
  79213. * Gets the list of all animation ranges defined on this skeleton
  79214. * @returns an array
  79215. */
  79216. getAnimationRanges(): Nullable<AnimationRange>[];
  79217. /**
  79218. * Copy animation range from a source skeleton.
  79219. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79220. * @param source defines the source skeleton
  79221. * @param name defines the name of the range to copy
  79222. * @param rescaleAsRequired defines if rescaling must be applied if required
  79223. * @returns true if operation was successful
  79224. */
  79225. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79226. /**
  79227. * Forces the skeleton to go to rest pose
  79228. */
  79229. returnToRest(): void;
  79230. private _getHighestAnimationFrame;
  79231. /**
  79232. * Begin a specific animation range
  79233. * @param name defines the name of the range to start
  79234. * @param loop defines if looping must be turned on (false by default)
  79235. * @param speedRatio defines the speed ratio to apply (1 by default)
  79236. * @param onAnimationEnd defines a callback which will be called when animation will end
  79237. * @returns a new animatable
  79238. */
  79239. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79240. /** @hidden */
  79241. _markAsDirty(): void;
  79242. /** @hidden */
  79243. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79244. /** @hidden */
  79245. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79246. private _computeTransformMatrices;
  79247. /**
  79248. * Build all resources required to render a skeleton
  79249. */
  79250. prepare(): void;
  79251. /**
  79252. * Gets the list of animatables currently running for this skeleton
  79253. * @returns an array of animatables
  79254. */
  79255. getAnimatables(): IAnimatable[];
  79256. /**
  79257. * Clone the current skeleton
  79258. * @param name defines the name of the new skeleton
  79259. * @param id defines the id of the new skeleton
  79260. * @returns the new skeleton
  79261. */
  79262. clone(name: string, id: string): Skeleton;
  79263. /**
  79264. * Enable animation blending for this skeleton
  79265. * @param blendingSpeed defines the blending speed to apply
  79266. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79267. */
  79268. enableBlending(blendingSpeed?: number): void;
  79269. /**
  79270. * Releases all resources associated with the current skeleton
  79271. */
  79272. dispose(): void;
  79273. /**
  79274. * Serialize the skeleton in a JSON object
  79275. * @returns a JSON object
  79276. */
  79277. serialize(): any;
  79278. /**
  79279. * Creates a new skeleton from serialized data
  79280. * @param parsedSkeleton defines the serialized data
  79281. * @param scene defines the hosting scene
  79282. * @returns a new skeleton
  79283. */
  79284. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79285. /**
  79286. * Compute all node absolute transforms
  79287. * @param forceUpdate defines if computation must be done even if cache is up to date
  79288. */
  79289. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79290. /**
  79291. * Gets the root pose matrix
  79292. * @returns a matrix
  79293. */
  79294. getPoseMatrix(): Nullable<Matrix>;
  79295. /**
  79296. * Sorts bones per internal index
  79297. */
  79298. sortBones(): void;
  79299. private _sortBones;
  79300. }
  79301. }
  79302. declare module BABYLON {
  79303. /**
  79304. * Defines a target to use with MorphTargetManager
  79305. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79306. */
  79307. export class MorphTarget implements IAnimatable {
  79308. /** defines the name of the target */
  79309. name: string;
  79310. /**
  79311. * Gets or sets the list of animations
  79312. */
  79313. animations: Animation[];
  79314. private _scene;
  79315. private _positions;
  79316. private _normals;
  79317. private _tangents;
  79318. private _influence;
  79319. /**
  79320. * Observable raised when the influence changes
  79321. */
  79322. onInfluenceChanged: Observable<boolean>;
  79323. /** @hidden */
  79324. _onDataLayoutChanged: Observable<void>;
  79325. /**
  79326. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  79327. */
  79328. influence: number;
  79329. /**
  79330. * Gets or sets the id of the morph Target
  79331. */
  79332. id: string;
  79333. private _animationPropertiesOverride;
  79334. /**
  79335. * Gets or sets the animation properties override
  79336. */
  79337. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79338. /**
  79339. * Creates a new MorphTarget
  79340. * @param name defines the name of the target
  79341. * @param influence defines the influence to use
  79342. * @param scene defines the scene the morphtarget belongs to
  79343. */
  79344. constructor(
  79345. /** defines the name of the target */
  79346. name: string, influence?: number, scene?: Nullable<Scene>);
  79347. /**
  79348. * Gets a boolean defining if the target contains position data
  79349. */
  79350. readonly hasPositions: boolean;
  79351. /**
  79352. * Gets a boolean defining if the target contains normal data
  79353. */
  79354. readonly hasNormals: boolean;
  79355. /**
  79356. * Gets a boolean defining if the target contains tangent data
  79357. */
  79358. readonly hasTangents: boolean;
  79359. /**
  79360. * Affects position data to this target
  79361. * @param data defines the position data to use
  79362. */
  79363. setPositions(data: Nullable<FloatArray>): void;
  79364. /**
  79365. * Gets the position data stored in this target
  79366. * @returns a FloatArray containing the position data (or null if not present)
  79367. */
  79368. getPositions(): Nullable<FloatArray>;
  79369. /**
  79370. * Affects normal data to this target
  79371. * @param data defines the normal data to use
  79372. */
  79373. setNormals(data: Nullable<FloatArray>): void;
  79374. /**
  79375. * Gets the normal data stored in this target
  79376. * @returns a FloatArray containing the normal data (or null if not present)
  79377. */
  79378. getNormals(): Nullable<FloatArray>;
  79379. /**
  79380. * Affects tangent data to this target
  79381. * @param data defines the tangent data to use
  79382. */
  79383. setTangents(data: Nullable<FloatArray>): void;
  79384. /**
  79385. * Gets the tangent data stored in this target
  79386. * @returns a FloatArray containing the tangent data (or null if not present)
  79387. */
  79388. getTangents(): Nullable<FloatArray>;
  79389. /**
  79390. * Serializes the current target into a Serialization object
  79391. * @returns the serialized object
  79392. */
  79393. serialize(): any;
  79394. /**
  79395. * Returns the string "MorphTarget"
  79396. * @returns "MorphTarget"
  79397. */
  79398. getClassName(): string;
  79399. /**
  79400. * Creates a new target from serialized data
  79401. * @param serializationObject defines the serialized data to use
  79402. * @returns a new MorphTarget
  79403. */
  79404. static Parse(serializationObject: any): MorphTarget;
  79405. /**
  79406. * Creates a MorphTarget from mesh data
  79407. * @param mesh defines the source mesh
  79408. * @param name defines the name to use for the new target
  79409. * @param influence defines the influence to attach to the target
  79410. * @returns a new MorphTarget
  79411. */
  79412. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  79413. }
  79414. }
  79415. declare module BABYLON {
  79416. /**
  79417. * This class is used to deform meshes using morphing between different targets
  79418. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79419. */
  79420. export class MorphTargetManager {
  79421. private _targets;
  79422. private _targetInfluenceChangedObservers;
  79423. private _targetDataLayoutChangedObservers;
  79424. private _activeTargets;
  79425. private _scene;
  79426. private _influences;
  79427. private _supportsNormals;
  79428. private _supportsTangents;
  79429. private _vertexCount;
  79430. private _uniqueId;
  79431. private _tempInfluences;
  79432. /**
  79433. * Creates a new MorphTargetManager
  79434. * @param scene defines the current scene
  79435. */
  79436. constructor(scene?: Nullable<Scene>);
  79437. /**
  79438. * Gets the unique ID of this manager
  79439. */
  79440. readonly uniqueId: number;
  79441. /**
  79442. * Gets the number of vertices handled by this manager
  79443. */
  79444. readonly vertexCount: number;
  79445. /**
  79446. * Gets a boolean indicating if this manager supports morphing of normals
  79447. */
  79448. readonly supportsNormals: boolean;
  79449. /**
  79450. * Gets a boolean indicating if this manager supports morphing of tangents
  79451. */
  79452. readonly supportsTangents: boolean;
  79453. /**
  79454. * Gets the number of targets stored in this manager
  79455. */
  79456. readonly numTargets: number;
  79457. /**
  79458. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79459. */
  79460. readonly numInfluencers: number;
  79461. /**
  79462. * Gets the list of influences (one per target)
  79463. */
  79464. readonly influences: Float32Array;
  79465. /**
  79466. * Gets the active target at specified index. An active target is a target with an influence > 0
  79467. * @param index defines the index to check
  79468. * @returns the requested target
  79469. */
  79470. getActiveTarget(index: number): MorphTarget;
  79471. /**
  79472. * Gets the target at specified index
  79473. * @param index defines the index to check
  79474. * @returns the requested target
  79475. */
  79476. getTarget(index: number): MorphTarget;
  79477. /**
  79478. * Add a new target to this manager
  79479. * @param target defines the target to add
  79480. */
  79481. addTarget(target: MorphTarget): void;
  79482. /**
  79483. * Removes a target from the manager
  79484. * @param target defines the target to remove
  79485. */
  79486. removeTarget(target: MorphTarget): void;
  79487. /**
  79488. * Serializes the current manager into a Serialization object
  79489. * @returns the serialized object
  79490. */
  79491. serialize(): any;
  79492. private _syncActiveTargets;
  79493. /**
  79494. * Syncrhonize the targets with all the meshes using this morph target manager
  79495. */
  79496. synchronize(): void;
  79497. /**
  79498. * Creates a new MorphTargetManager from serialized data
  79499. * @param serializationObject defines the serialized data
  79500. * @param scene defines the hosting scene
  79501. * @returns the new MorphTargetManager
  79502. */
  79503. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79504. }
  79505. }
  79506. declare module BABYLON {
  79507. /**
  79508. * Class used to represent a specific level of detail of a mesh
  79509. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79510. */
  79511. export class MeshLODLevel {
  79512. /** Defines the distance where this level should star being displayed */
  79513. distance: number;
  79514. /** Defines the mesh to use to render this level */
  79515. mesh: Nullable<Mesh>;
  79516. /**
  79517. * Creates a new LOD level
  79518. * @param distance defines the distance where this level should star being displayed
  79519. * @param mesh defines the mesh to use to render this level
  79520. */
  79521. constructor(
  79522. /** Defines the distance where this level should star being displayed */
  79523. distance: number,
  79524. /** Defines the mesh to use to render this level */
  79525. mesh: Nullable<Mesh>);
  79526. }
  79527. }
  79528. declare module BABYLON {
  79529. /**
  79530. * Mesh representing the gorund
  79531. */
  79532. export class GroundMesh extends Mesh {
  79533. /** If octree should be generated */
  79534. generateOctree: boolean;
  79535. private _heightQuads;
  79536. /** @hidden */
  79537. _subdivisionsX: number;
  79538. /** @hidden */
  79539. _subdivisionsY: number;
  79540. /** @hidden */
  79541. _width: number;
  79542. /** @hidden */
  79543. _height: number;
  79544. /** @hidden */
  79545. _minX: number;
  79546. /** @hidden */
  79547. _maxX: number;
  79548. /** @hidden */
  79549. _minZ: number;
  79550. /** @hidden */
  79551. _maxZ: number;
  79552. constructor(name: string, scene: Scene);
  79553. /**
  79554. * "GroundMesh"
  79555. * @returns "GroundMesh"
  79556. */
  79557. getClassName(): string;
  79558. /**
  79559. * The minimum of x and y subdivisions
  79560. */
  79561. readonly subdivisions: number;
  79562. /**
  79563. * X subdivisions
  79564. */
  79565. readonly subdivisionsX: number;
  79566. /**
  79567. * Y subdivisions
  79568. */
  79569. readonly subdivisionsY: number;
  79570. /**
  79571. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79572. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79573. * @param chunksCount the number of subdivisions for x and y
  79574. * @param octreeBlocksSize (Default: 32)
  79575. */
  79576. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79577. /**
  79578. * Returns a height (y) value in the Worl system :
  79579. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79580. * @param x x coordinate
  79581. * @param z z coordinate
  79582. * @returns the ground y position if (x, z) are outside the ground surface.
  79583. */
  79584. getHeightAtCoordinates(x: number, z: number): number;
  79585. /**
  79586. * Returns a normalized vector (Vector3) orthogonal to the ground
  79587. * at the ground coordinates (x, z) expressed in the World system.
  79588. * @param x x coordinate
  79589. * @param z z coordinate
  79590. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79591. */
  79592. getNormalAtCoordinates(x: number, z: number): Vector3;
  79593. /**
  79594. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79595. * at the ground coordinates (x, z) expressed in the World system.
  79596. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79597. * @param x x coordinate
  79598. * @param z z coordinate
  79599. * @param ref vector to store the result
  79600. * @returns the GroundMesh.
  79601. */
  79602. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79603. /**
  79604. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79605. * if the ground has been updated.
  79606. * This can be used in the render loop.
  79607. * @returns the GroundMesh.
  79608. */
  79609. updateCoordinateHeights(): GroundMesh;
  79610. private _getFacetAt;
  79611. private _initHeightQuads;
  79612. private _computeHeightQuads;
  79613. /**
  79614. * Serializes this ground mesh
  79615. * @param serializationObject object to write serialization to
  79616. */
  79617. serialize(serializationObject: any): void;
  79618. /**
  79619. * Parses a serialized ground mesh
  79620. * @param parsedMesh the serialized mesh
  79621. * @param scene the scene to create the ground mesh in
  79622. * @returns the created ground mesh
  79623. */
  79624. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79625. }
  79626. }
  79627. declare module BABYLON {
  79628. /**
  79629. * Interface for Physics-Joint data
  79630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79631. */
  79632. export interface PhysicsJointData {
  79633. /**
  79634. * The main pivot of the joint
  79635. */
  79636. mainPivot?: Vector3;
  79637. /**
  79638. * The connected pivot of the joint
  79639. */
  79640. connectedPivot?: Vector3;
  79641. /**
  79642. * The main axis of the joint
  79643. */
  79644. mainAxis?: Vector3;
  79645. /**
  79646. * The connected axis of the joint
  79647. */
  79648. connectedAxis?: Vector3;
  79649. /**
  79650. * The collision of the joint
  79651. */
  79652. collision?: boolean;
  79653. /**
  79654. * Native Oimo/Cannon/Energy data
  79655. */
  79656. nativeParams?: any;
  79657. }
  79658. /**
  79659. * This is a holder class for the physics joint created by the physics plugin
  79660. * It holds a set of functions to control the underlying joint
  79661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79662. */
  79663. export class PhysicsJoint {
  79664. /**
  79665. * The type of the physics joint
  79666. */
  79667. type: number;
  79668. /**
  79669. * The data for the physics joint
  79670. */
  79671. jointData: PhysicsJointData;
  79672. private _physicsJoint;
  79673. protected _physicsPlugin: IPhysicsEnginePlugin;
  79674. /**
  79675. * Initializes the physics joint
  79676. * @param type The type of the physics joint
  79677. * @param jointData The data for the physics joint
  79678. */
  79679. constructor(
  79680. /**
  79681. * The type of the physics joint
  79682. */
  79683. type: number,
  79684. /**
  79685. * The data for the physics joint
  79686. */
  79687. jointData: PhysicsJointData);
  79688. /**
  79689. * Gets the physics joint
  79690. */
  79691. /**
  79692. * Sets the physics joint
  79693. */
  79694. physicsJoint: any;
  79695. /**
  79696. * Sets the physics plugin
  79697. */
  79698. physicsPlugin: IPhysicsEnginePlugin;
  79699. /**
  79700. * Execute a function that is physics-plugin specific.
  79701. * @param {Function} func the function that will be executed.
  79702. * It accepts two parameters: the physics world and the physics joint
  79703. */
  79704. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79705. /**
  79706. * Distance-Joint type
  79707. */
  79708. static DistanceJoint: number;
  79709. /**
  79710. * Hinge-Joint type
  79711. */
  79712. static HingeJoint: number;
  79713. /**
  79714. * Ball-and-Socket joint type
  79715. */
  79716. static BallAndSocketJoint: number;
  79717. /**
  79718. * Wheel-Joint type
  79719. */
  79720. static WheelJoint: number;
  79721. /**
  79722. * Slider-Joint type
  79723. */
  79724. static SliderJoint: number;
  79725. /**
  79726. * Prismatic-Joint type
  79727. */
  79728. static PrismaticJoint: number;
  79729. /**
  79730. * Universal-Joint type
  79731. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79732. */
  79733. static UniversalJoint: number;
  79734. /**
  79735. * Hinge-Joint 2 type
  79736. */
  79737. static Hinge2Joint: number;
  79738. /**
  79739. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79740. */
  79741. static PointToPointJoint: number;
  79742. /**
  79743. * Spring-Joint type
  79744. */
  79745. static SpringJoint: number;
  79746. /**
  79747. * Lock-Joint type
  79748. */
  79749. static LockJoint: number;
  79750. }
  79751. /**
  79752. * A class representing a physics distance joint
  79753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79754. */
  79755. export class DistanceJoint extends PhysicsJoint {
  79756. /**
  79757. *
  79758. * @param jointData The data for the Distance-Joint
  79759. */
  79760. constructor(jointData: DistanceJointData);
  79761. /**
  79762. * Update the predefined distance.
  79763. * @param maxDistance The maximum preferred distance
  79764. * @param minDistance The minimum preferred distance
  79765. */
  79766. updateDistance(maxDistance: number, minDistance?: number): void;
  79767. }
  79768. /**
  79769. * Represents a Motor-Enabled Joint
  79770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79771. */
  79772. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79773. /**
  79774. * Initializes the Motor-Enabled Joint
  79775. * @param type The type of the joint
  79776. * @param jointData The physica joint data for the joint
  79777. */
  79778. constructor(type: number, jointData: PhysicsJointData);
  79779. /**
  79780. * Set the motor values.
  79781. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79782. * @param force the force to apply
  79783. * @param maxForce max force for this motor.
  79784. */
  79785. setMotor(force?: number, maxForce?: number): void;
  79786. /**
  79787. * Set the motor's limits.
  79788. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79789. * @param upperLimit The upper limit of the motor
  79790. * @param lowerLimit The lower limit of the motor
  79791. */
  79792. setLimit(upperLimit: number, lowerLimit?: number): void;
  79793. }
  79794. /**
  79795. * This class represents a single physics Hinge-Joint
  79796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79797. */
  79798. export class HingeJoint extends MotorEnabledJoint {
  79799. /**
  79800. * Initializes the Hinge-Joint
  79801. * @param jointData The joint data for the Hinge-Joint
  79802. */
  79803. constructor(jointData: PhysicsJointData);
  79804. /**
  79805. * Set the motor values.
  79806. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79807. * @param {number} force the force to apply
  79808. * @param {number} maxForce max force for this motor.
  79809. */
  79810. setMotor(force?: number, maxForce?: number): void;
  79811. /**
  79812. * Set the motor's limits.
  79813. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79814. * @param upperLimit The upper limit of the motor
  79815. * @param lowerLimit The lower limit of the motor
  79816. */
  79817. setLimit(upperLimit: number, lowerLimit?: number): void;
  79818. }
  79819. /**
  79820. * This class represents a dual hinge physics joint (same as wheel joint)
  79821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79822. */
  79823. export class Hinge2Joint extends MotorEnabledJoint {
  79824. /**
  79825. * Initializes the Hinge2-Joint
  79826. * @param jointData The joint data for the Hinge2-Joint
  79827. */
  79828. constructor(jointData: PhysicsJointData);
  79829. /**
  79830. * Set the motor values.
  79831. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79832. * @param {number} targetSpeed the speed the motor is to reach
  79833. * @param {number} maxForce max force for this motor.
  79834. * @param {motorIndex} the motor's index, 0 or 1.
  79835. */
  79836. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79837. /**
  79838. * Set the motor limits.
  79839. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79840. * @param {number} upperLimit the upper limit
  79841. * @param {number} lowerLimit lower limit
  79842. * @param {motorIndex} the motor's index, 0 or 1.
  79843. */
  79844. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79845. }
  79846. /**
  79847. * Interface for a motor enabled joint
  79848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79849. */
  79850. export interface IMotorEnabledJoint {
  79851. /**
  79852. * Physics joint
  79853. */
  79854. physicsJoint: any;
  79855. /**
  79856. * Sets the motor of the motor-enabled joint
  79857. * @param force The force of the motor
  79858. * @param maxForce The maximum force of the motor
  79859. * @param motorIndex The index of the motor
  79860. */
  79861. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79862. /**
  79863. * Sets the limit of the motor
  79864. * @param upperLimit The upper limit of the motor
  79865. * @param lowerLimit The lower limit of the motor
  79866. * @param motorIndex The index of the motor
  79867. */
  79868. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79869. }
  79870. /**
  79871. * Joint data for a Distance-Joint
  79872. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79873. */
  79874. export interface DistanceJointData extends PhysicsJointData {
  79875. /**
  79876. * Max distance the 2 joint objects can be apart
  79877. */
  79878. maxDistance: number;
  79879. }
  79880. /**
  79881. * Joint data from a spring joint
  79882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79883. */
  79884. export interface SpringJointData extends PhysicsJointData {
  79885. /**
  79886. * Length of the spring
  79887. */
  79888. length: number;
  79889. /**
  79890. * Stiffness of the spring
  79891. */
  79892. stiffness: number;
  79893. /**
  79894. * Damping of the spring
  79895. */
  79896. damping: number;
  79897. /** this callback will be called when applying the force to the impostors. */
  79898. forceApplicationCallback: () => void;
  79899. }
  79900. }
  79901. declare module BABYLON {
  79902. /**
  79903. * Holds the data for the raycast result
  79904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79905. */
  79906. export class PhysicsRaycastResult {
  79907. private _hasHit;
  79908. private _hitDistance;
  79909. private _hitNormalWorld;
  79910. private _hitPointWorld;
  79911. private _rayFromWorld;
  79912. private _rayToWorld;
  79913. /**
  79914. * Gets if there was a hit
  79915. */
  79916. readonly hasHit: boolean;
  79917. /**
  79918. * Gets the distance from the hit
  79919. */
  79920. readonly hitDistance: number;
  79921. /**
  79922. * Gets the hit normal/direction in the world
  79923. */
  79924. readonly hitNormalWorld: Vector3;
  79925. /**
  79926. * Gets the hit point in the world
  79927. */
  79928. readonly hitPointWorld: Vector3;
  79929. /**
  79930. * Gets the ray "start point" of the ray in the world
  79931. */
  79932. readonly rayFromWorld: Vector3;
  79933. /**
  79934. * Gets the ray "end point" of the ray in the world
  79935. */
  79936. readonly rayToWorld: Vector3;
  79937. /**
  79938. * Sets the hit data (normal & point in world space)
  79939. * @param hitNormalWorld defines the normal in world space
  79940. * @param hitPointWorld defines the point in world space
  79941. */
  79942. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79943. /**
  79944. * Sets the distance from the start point to the hit point
  79945. * @param distance
  79946. */
  79947. setHitDistance(distance: number): void;
  79948. /**
  79949. * Calculates the distance manually
  79950. */
  79951. calculateHitDistance(): void;
  79952. /**
  79953. * Resets all the values to default
  79954. * @param from The from point on world space
  79955. * @param to The to point on world space
  79956. */
  79957. reset(from?: Vector3, to?: Vector3): void;
  79958. }
  79959. /**
  79960. * Interface for the size containing width and height
  79961. */
  79962. interface IXYZ {
  79963. /**
  79964. * X
  79965. */
  79966. x: number;
  79967. /**
  79968. * Y
  79969. */
  79970. y: number;
  79971. /**
  79972. * Z
  79973. */
  79974. z: number;
  79975. }
  79976. }
  79977. declare module BABYLON {
  79978. /**
  79979. * Interface used to describe a physics joint
  79980. */
  79981. export interface PhysicsImpostorJoint {
  79982. /** Defines the main impostor to which the joint is linked */
  79983. mainImpostor: PhysicsImpostor;
  79984. /** Defines the impostor that is connected to the main impostor using this joint */
  79985. connectedImpostor: PhysicsImpostor;
  79986. /** Defines the joint itself */
  79987. joint: PhysicsJoint;
  79988. }
  79989. /** @hidden */
  79990. export interface IPhysicsEnginePlugin {
  79991. world: any;
  79992. name: string;
  79993. setGravity(gravity: Vector3): void;
  79994. setTimeStep(timeStep: number): void;
  79995. getTimeStep(): number;
  79996. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79997. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79998. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79999. generatePhysicsBody(impostor: PhysicsImpostor): void;
  80000. removePhysicsBody(impostor: PhysicsImpostor): void;
  80001. generateJoint(joint: PhysicsImpostorJoint): void;
  80002. removeJoint(joint: PhysicsImpostorJoint): void;
  80003. isSupported(): boolean;
  80004. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  80005. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  80006. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80007. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80008. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80009. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80010. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  80011. getBodyMass(impostor: PhysicsImpostor): number;
  80012. getBodyFriction(impostor: PhysicsImpostor): number;
  80013. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  80014. getBodyRestitution(impostor: PhysicsImpostor): number;
  80015. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  80016. getBodyPressure?(impostor: PhysicsImpostor): number;
  80017. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  80018. getBodyStiffness?(impostor: PhysicsImpostor): number;
  80019. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  80020. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  80021. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  80022. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  80023. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  80024. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80025. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80026. sleepBody(impostor: PhysicsImpostor): void;
  80027. wakeUpBody(impostor: PhysicsImpostor): void;
  80028. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80029. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  80030. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  80031. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  80032. getRadius(impostor: PhysicsImpostor): number;
  80033. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  80034. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  80035. dispose(): void;
  80036. }
  80037. /**
  80038. * Interface used to define a physics engine
  80039. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  80040. */
  80041. export interface IPhysicsEngine {
  80042. /**
  80043. * Gets the gravity vector used by the simulation
  80044. */
  80045. gravity: Vector3;
  80046. /**
  80047. * Sets the gravity vector used by the simulation
  80048. * @param gravity defines the gravity vector to use
  80049. */
  80050. setGravity(gravity: Vector3): void;
  80051. /**
  80052. * Set the time step of the physics engine.
  80053. * Default is 1/60.
  80054. * To slow it down, enter 1/600 for example.
  80055. * To speed it up, 1/30
  80056. * @param newTimeStep the new timestep to apply to this world.
  80057. */
  80058. setTimeStep(newTimeStep: number): void;
  80059. /**
  80060. * Get the time step of the physics engine.
  80061. * @returns the current time step
  80062. */
  80063. getTimeStep(): number;
  80064. /**
  80065. * Release all resources
  80066. */
  80067. dispose(): void;
  80068. /**
  80069. * Gets the name of the current physics plugin
  80070. * @returns the name of the plugin
  80071. */
  80072. getPhysicsPluginName(): string;
  80073. /**
  80074. * Adding a new impostor for the impostor tracking.
  80075. * This will be done by the impostor itself.
  80076. * @param impostor the impostor to add
  80077. */
  80078. addImpostor(impostor: PhysicsImpostor): void;
  80079. /**
  80080. * Remove an impostor from the engine.
  80081. * This impostor and its mesh will not longer be updated by the physics engine.
  80082. * @param impostor the impostor to remove
  80083. */
  80084. removeImpostor(impostor: PhysicsImpostor): void;
  80085. /**
  80086. * Add a joint to the physics engine
  80087. * @param mainImpostor defines the main impostor to which the joint is added.
  80088. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  80089. * @param joint defines the joint that will connect both impostors.
  80090. */
  80091. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80092. /**
  80093. * Removes a joint from the simulation
  80094. * @param mainImpostor defines the impostor used with the joint
  80095. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  80096. * @param joint defines the joint to remove
  80097. */
  80098. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80099. /**
  80100. * Gets the current plugin used to run the simulation
  80101. * @returns current plugin
  80102. */
  80103. getPhysicsPlugin(): IPhysicsEnginePlugin;
  80104. /**
  80105. * Gets the list of physic impostors
  80106. * @returns an array of PhysicsImpostor
  80107. */
  80108. getImpostors(): Array<PhysicsImpostor>;
  80109. /**
  80110. * Gets the impostor for a physics enabled object
  80111. * @param object defines the object impersonated by the impostor
  80112. * @returns the PhysicsImpostor or null if not found
  80113. */
  80114. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80115. /**
  80116. * Gets the impostor for a physics body object
  80117. * @param body defines physics body used by the impostor
  80118. * @returns the PhysicsImpostor or null if not found
  80119. */
  80120. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  80121. /**
  80122. * Does a raycast in the physics world
  80123. * @param from when should the ray start?
  80124. * @param to when should the ray end?
  80125. * @returns PhysicsRaycastResult
  80126. */
  80127. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80128. /**
  80129. * Called by the scene. No need to call it.
  80130. * @param delta defines the timespam between frames
  80131. */
  80132. _step(delta: number): void;
  80133. }
  80134. }
  80135. declare module BABYLON {
  80136. /**
  80137. * The interface for the physics imposter parameters
  80138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80139. */
  80140. export interface PhysicsImpostorParameters {
  80141. /**
  80142. * The mass of the physics imposter
  80143. */
  80144. mass: number;
  80145. /**
  80146. * The friction of the physics imposter
  80147. */
  80148. friction?: number;
  80149. /**
  80150. * The coefficient of restitution of the physics imposter
  80151. */
  80152. restitution?: number;
  80153. /**
  80154. * The native options of the physics imposter
  80155. */
  80156. nativeOptions?: any;
  80157. /**
  80158. * Specifies if the parent should be ignored
  80159. */
  80160. ignoreParent?: boolean;
  80161. /**
  80162. * Specifies if bi-directional transformations should be disabled
  80163. */
  80164. disableBidirectionalTransformation?: boolean;
  80165. /**
  80166. * The pressure inside the physics imposter, soft object only
  80167. */
  80168. pressure?: number;
  80169. /**
  80170. * The stiffness the physics imposter, soft object only
  80171. */
  80172. stiffness?: number;
  80173. /**
  80174. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  80175. */
  80176. velocityIterations?: number;
  80177. /**
  80178. * The number of iterations used in maintaining consistent vertex positions, soft object only
  80179. */
  80180. positionIterations?: number;
  80181. /**
  80182. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  80183. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  80184. * Add to fix multiple points
  80185. */
  80186. fixedPoints?: number;
  80187. /**
  80188. * The collision margin around a soft object
  80189. */
  80190. margin?: number;
  80191. /**
  80192. * The collision margin around a soft object
  80193. */
  80194. damping?: number;
  80195. /**
  80196. * The path for a rope based on an extrusion
  80197. */
  80198. path?: any;
  80199. /**
  80200. * The shape of an extrusion used for a rope based on an extrusion
  80201. */
  80202. shape?: any;
  80203. }
  80204. /**
  80205. * Interface for a physics-enabled object
  80206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80207. */
  80208. export interface IPhysicsEnabledObject {
  80209. /**
  80210. * The position of the physics-enabled object
  80211. */
  80212. position: Vector3;
  80213. /**
  80214. * The rotation of the physics-enabled object
  80215. */
  80216. rotationQuaternion: Nullable<Quaternion>;
  80217. /**
  80218. * The scale of the physics-enabled object
  80219. */
  80220. scaling: Vector3;
  80221. /**
  80222. * The rotation of the physics-enabled object
  80223. */
  80224. rotation?: Vector3;
  80225. /**
  80226. * The parent of the physics-enabled object
  80227. */
  80228. parent?: any;
  80229. /**
  80230. * The bounding info of the physics-enabled object
  80231. * @returns The bounding info of the physics-enabled object
  80232. */
  80233. getBoundingInfo(): BoundingInfo;
  80234. /**
  80235. * Computes the world matrix
  80236. * @param force Specifies if the world matrix should be computed by force
  80237. * @returns A world matrix
  80238. */
  80239. computeWorldMatrix(force: boolean): Matrix;
  80240. /**
  80241. * Gets the world matrix
  80242. * @returns A world matrix
  80243. */
  80244. getWorldMatrix?(): Matrix;
  80245. /**
  80246. * Gets the child meshes
  80247. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  80248. * @returns An array of abstract meshes
  80249. */
  80250. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  80251. /**
  80252. * Gets the vertex data
  80253. * @param kind The type of vertex data
  80254. * @returns A nullable array of numbers, or a float32 array
  80255. */
  80256. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  80257. /**
  80258. * Gets the indices from the mesh
  80259. * @returns A nullable array of index arrays
  80260. */
  80261. getIndices?(): Nullable<IndicesArray>;
  80262. /**
  80263. * Gets the scene from the mesh
  80264. * @returns the indices array or null
  80265. */
  80266. getScene?(): Scene;
  80267. /**
  80268. * Gets the absolute position from the mesh
  80269. * @returns the absolute position
  80270. */
  80271. getAbsolutePosition(): Vector3;
  80272. /**
  80273. * Gets the absolute pivot point from the mesh
  80274. * @returns the absolute pivot point
  80275. */
  80276. getAbsolutePivotPoint(): Vector3;
  80277. /**
  80278. * Rotates the mesh
  80279. * @param axis The axis of rotation
  80280. * @param amount The amount of rotation
  80281. * @param space The space of the rotation
  80282. * @returns The rotation transform node
  80283. */
  80284. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80285. /**
  80286. * Translates the mesh
  80287. * @param axis The axis of translation
  80288. * @param distance The distance of translation
  80289. * @param space The space of the translation
  80290. * @returns The transform node
  80291. */
  80292. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80293. /**
  80294. * Sets the absolute position of the mesh
  80295. * @param absolutePosition The absolute position of the mesh
  80296. * @returns The transform node
  80297. */
  80298. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80299. /**
  80300. * Gets the class name of the mesh
  80301. * @returns The class name
  80302. */
  80303. getClassName(): string;
  80304. }
  80305. /**
  80306. * Represents a physics imposter
  80307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80308. */
  80309. export class PhysicsImpostor {
  80310. /**
  80311. * The physics-enabled object used as the physics imposter
  80312. */
  80313. object: IPhysicsEnabledObject;
  80314. /**
  80315. * The type of the physics imposter
  80316. */
  80317. type: number;
  80318. private _options;
  80319. private _scene?;
  80320. /**
  80321. * The default object size of the imposter
  80322. */
  80323. static DEFAULT_OBJECT_SIZE: Vector3;
  80324. /**
  80325. * The identity quaternion of the imposter
  80326. */
  80327. static IDENTITY_QUATERNION: Quaternion;
  80328. /** @hidden */
  80329. _pluginData: any;
  80330. private _physicsEngine;
  80331. private _physicsBody;
  80332. private _bodyUpdateRequired;
  80333. private _onBeforePhysicsStepCallbacks;
  80334. private _onAfterPhysicsStepCallbacks;
  80335. /** @hidden */
  80336. _onPhysicsCollideCallbacks: Array<{
  80337. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  80338. otherImpostors: Array<PhysicsImpostor>;
  80339. }>;
  80340. private _deltaPosition;
  80341. private _deltaRotation;
  80342. private _deltaRotationConjugated;
  80343. /** hidden */
  80344. _isFromLine: boolean;
  80345. private _parent;
  80346. private _isDisposed;
  80347. private static _tmpVecs;
  80348. private static _tmpQuat;
  80349. /**
  80350. * Specifies if the physics imposter is disposed
  80351. */
  80352. readonly isDisposed: boolean;
  80353. /**
  80354. * Gets the mass of the physics imposter
  80355. */
  80356. mass: number;
  80357. /**
  80358. * Gets the coefficient of friction
  80359. */
  80360. /**
  80361. * Sets the coefficient of friction
  80362. */
  80363. friction: number;
  80364. /**
  80365. * Gets the coefficient of restitution
  80366. */
  80367. /**
  80368. * Sets the coefficient of restitution
  80369. */
  80370. restitution: number;
  80371. /**
  80372. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  80373. */
  80374. /**
  80375. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  80376. */
  80377. pressure: number;
  80378. /**
  80379. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80380. */
  80381. /**
  80382. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80383. */
  80384. stiffness: number;
  80385. /**
  80386. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80387. */
  80388. /**
  80389. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80390. */
  80391. velocityIterations: number;
  80392. /**
  80393. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80394. */
  80395. /**
  80396. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80397. */
  80398. positionIterations: number;
  80399. /**
  80400. * The unique id of the physics imposter
  80401. * set by the physics engine when adding this impostor to the array
  80402. */
  80403. uniqueId: number;
  80404. /**
  80405. * @hidden
  80406. */
  80407. soft: boolean;
  80408. /**
  80409. * @hidden
  80410. */
  80411. segments: number;
  80412. private _joints;
  80413. /**
  80414. * Initializes the physics imposter
  80415. * @param object The physics-enabled object used as the physics imposter
  80416. * @param type The type of the physics imposter
  80417. * @param _options The options for the physics imposter
  80418. * @param _scene The Babylon scene
  80419. */
  80420. constructor(
  80421. /**
  80422. * The physics-enabled object used as the physics imposter
  80423. */
  80424. object: IPhysicsEnabledObject,
  80425. /**
  80426. * The type of the physics imposter
  80427. */
  80428. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  80429. /**
  80430. * This function will completly initialize this impostor.
  80431. * It will create a new body - but only if this mesh has no parent.
  80432. * If it has, this impostor will not be used other than to define the impostor
  80433. * of the child mesh.
  80434. * @hidden
  80435. */
  80436. _init(): void;
  80437. private _getPhysicsParent;
  80438. /**
  80439. * Should a new body be generated.
  80440. * @returns boolean specifying if body initialization is required
  80441. */
  80442. isBodyInitRequired(): boolean;
  80443. /**
  80444. * Sets the updated scaling
  80445. * @param updated Specifies if the scaling is updated
  80446. */
  80447. setScalingUpdated(): void;
  80448. /**
  80449. * Force a regeneration of this or the parent's impostor's body.
  80450. * Use under cautious - This will remove all joints already implemented.
  80451. */
  80452. forceUpdate(): void;
  80453. /**
  80454. * Gets the body that holds this impostor. Either its own, or its parent.
  80455. */
  80456. /**
  80457. * Set the physics body. Used mainly by the physics engine/plugin
  80458. */
  80459. physicsBody: any;
  80460. /**
  80461. * Get the parent of the physics imposter
  80462. * @returns Physics imposter or null
  80463. */
  80464. /**
  80465. * Sets the parent of the physics imposter
  80466. */
  80467. parent: Nullable<PhysicsImpostor>;
  80468. /**
  80469. * Resets the update flags
  80470. */
  80471. resetUpdateFlags(): void;
  80472. /**
  80473. * Gets the object extend size
  80474. * @returns the object extend size
  80475. */
  80476. getObjectExtendSize(): Vector3;
  80477. /**
  80478. * Gets the object center
  80479. * @returns The object center
  80480. */
  80481. getObjectCenter(): Vector3;
  80482. /**
  80483. * Get a specific parametes from the options parameter
  80484. * @param paramName The object parameter name
  80485. * @returns The object parameter
  80486. */
  80487. getParam(paramName: string): any;
  80488. /**
  80489. * Sets a specific parameter in the options given to the physics plugin
  80490. * @param paramName The parameter name
  80491. * @param value The value of the parameter
  80492. */
  80493. setParam(paramName: string, value: number): void;
  80494. /**
  80495. * Specifically change the body's mass option. Won't recreate the physics body object
  80496. * @param mass The mass of the physics imposter
  80497. */
  80498. setMass(mass: number): void;
  80499. /**
  80500. * Gets the linear velocity
  80501. * @returns linear velocity or null
  80502. */
  80503. getLinearVelocity(): Nullable<Vector3>;
  80504. /**
  80505. * Sets the linear velocity
  80506. * @param velocity linear velocity or null
  80507. */
  80508. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80509. /**
  80510. * Gets the angular velocity
  80511. * @returns angular velocity or null
  80512. */
  80513. getAngularVelocity(): Nullable<Vector3>;
  80514. /**
  80515. * Sets the angular velocity
  80516. * @param velocity The velocity or null
  80517. */
  80518. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80519. /**
  80520. * Execute a function with the physics plugin native code
  80521. * Provide a function the will have two variables - the world object and the physics body object
  80522. * @param func The function to execute with the physics plugin native code
  80523. */
  80524. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80525. /**
  80526. * Register 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. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80530. /**
  80531. * Unregister a function that will be executed before the physics world is stepping forward
  80532. * @param func The function to execute before the physics world is stepped forward
  80533. */
  80534. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80535. /**
  80536. * Register a function that will be executed after the physics step
  80537. * @param func The function to execute after physics step
  80538. */
  80539. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80540. /**
  80541. * Unregisters a function that will be executed after the physics step
  80542. * @param func The function to execute after physics step
  80543. */
  80544. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80545. /**
  80546. * register a function that will be executed when this impostor collides against a different body
  80547. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80548. * @param func Callback that is executed on collision
  80549. */
  80550. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80551. /**
  80552. * Unregisters the physics imposter on contact
  80553. * @param collideAgainst The physics object to collide against
  80554. * @param func Callback to execute on collision
  80555. */
  80556. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80557. private _tmpQuat;
  80558. private _tmpQuat2;
  80559. /**
  80560. * Get the parent rotation
  80561. * @returns The parent rotation
  80562. */
  80563. getParentsRotation(): Quaternion;
  80564. /**
  80565. * this function is executed by the physics engine.
  80566. */
  80567. beforeStep: () => void;
  80568. /**
  80569. * this function is executed by the physics engine
  80570. */
  80571. afterStep: () => void;
  80572. /**
  80573. * Legacy collision detection event support
  80574. */
  80575. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80576. /**
  80577. * event and body object due to cannon's event-based architecture.
  80578. */
  80579. onCollide: (e: {
  80580. body: any;
  80581. }) => void;
  80582. /**
  80583. * Apply a force
  80584. * @param force The force to apply
  80585. * @param contactPoint The contact point for the force
  80586. * @returns The physics imposter
  80587. */
  80588. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80589. /**
  80590. * Apply an impulse
  80591. * @param force The impulse force
  80592. * @param contactPoint The contact point for the impulse force
  80593. * @returns The physics imposter
  80594. */
  80595. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80596. /**
  80597. * A help function to create a joint
  80598. * @param otherImpostor A physics imposter used to create a joint
  80599. * @param jointType The type of joint
  80600. * @param jointData The data for the joint
  80601. * @returns The physics imposter
  80602. */
  80603. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80604. /**
  80605. * Add a joint to this impostor with a different impostor
  80606. * @param otherImpostor A physics imposter used to add a joint
  80607. * @param joint The joint to add
  80608. * @returns The physics imposter
  80609. */
  80610. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80611. /**
  80612. * Add an anchor to a cloth impostor
  80613. * @param otherImpostor rigid impostor to anchor to
  80614. * @param width ratio across width from 0 to 1
  80615. * @param height ratio up height from 0 to 1
  80616. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80617. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80618. * @returns impostor the soft imposter
  80619. */
  80620. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80621. /**
  80622. * Add a hook to a rope impostor
  80623. * @param otherImpostor rigid impostor to anchor to
  80624. * @param length ratio across rope from 0 to 1
  80625. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80626. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80627. * @returns impostor the rope imposter
  80628. */
  80629. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80630. /**
  80631. * Will keep this body still, in a sleep mode.
  80632. * @returns the physics imposter
  80633. */
  80634. sleep(): PhysicsImpostor;
  80635. /**
  80636. * Wake the body up.
  80637. * @returns The physics imposter
  80638. */
  80639. wakeUp(): PhysicsImpostor;
  80640. /**
  80641. * Clones the physics imposter
  80642. * @param newObject The physics imposter clones to this physics-enabled object
  80643. * @returns A nullable physics imposter
  80644. */
  80645. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80646. /**
  80647. * Disposes the physics imposter
  80648. */
  80649. dispose(): void;
  80650. /**
  80651. * Sets the delta position
  80652. * @param position The delta position amount
  80653. */
  80654. setDeltaPosition(position: Vector3): void;
  80655. /**
  80656. * Sets the delta rotation
  80657. * @param rotation The delta rotation amount
  80658. */
  80659. setDeltaRotation(rotation: Quaternion): void;
  80660. /**
  80661. * Gets the box size of the physics imposter and stores the result in the input parameter
  80662. * @param result Stores the box size
  80663. * @returns The physics imposter
  80664. */
  80665. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80666. /**
  80667. * Gets the radius of the physics imposter
  80668. * @returns Radius of the physics imposter
  80669. */
  80670. getRadius(): number;
  80671. /**
  80672. * Sync a bone with this impostor
  80673. * @param bone The bone to sync to the impostor.
  80674. * @param boneMesh The mesh that the bone is influencing.
  80675. * @param jointPivot The pivot of the joint / bone in local space.
  80676. * @param distToJoint Optional distance from the impostor to the joint.
  80677. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80678. */
  80679. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80680. /**
  80681. * Sync impostor to a bone
  80682. * @param bone The bone that the impostor will be synced to.
  80683. * @param boneMesh The mesh that the bone is influencing.
  80684. * @param jointPivot The pivot of the joint / bone in local space.
  80685. * @param distToJoint Optional distance from the impostor to the joint.
  80686. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80687. * @param boneAxis Optional vector3 axis the bone is aligned with
  80688. */
  80689. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80690. /**
  80691. * No-Imposter type
  80692. */
  80693. static NoImpostor: number;
  80694. /**
  80695. * Sphere-Imposter type
  80696. */
  80697. static SphereImpostor: number;
  80698. /**
  80699. * Box-Imposter type
  80700. */
  80701. static BoxImpostor: number;
  80702. /**
  80703. * Plane-Imposter type
  80704. */
  80705. static PlaneImpostor: number;
  80706. /**
  80707. * Mesh-imposter type
  80708. */
  80709. static MeshImpostor: number;
  80710. /**
  80711. * Cylinder-Imposter type
  80712. */
  80713. static CylinderImpostor: number;
  80714. /**
  80715. * Particle-Imposter type
  80716. */
  80717. static ParticleImpostor: number;
  80718. /**
  80719. * Heightmap-Imposter type
  80720. */
  80721. static HeightmapImpostor: number;
  80722. /**
  80723. * ConvexHull-Impostor type (Ammo.js plugin only)
  80724. */
  80725. static ConvexHullImpostor: number;
  80726. /**
  80727. * Rope-Imposter type
  80728. */
  80729. static RopeImpostor: number;
  80730. /**
  80731. * Cloth-Imposter type
  80732. */
  80733. static ClothImpostor: number;
  80734. /**
  80735. * Softbody-Imposter type
  80736. */
  80737. static SoftbodyImpostor: number;
  80738. }
  80739. }
  80740. declare module BABYLON {
  80741. /**
  80742. * @hidden
  80743. **/
  80744. export class _CreationDataStorage {
  80745. closePath?: boolean;
  80746. closeArray?: boolean;
  80747. idx: number[];
  80748. dashSize: number;
  80749. gapSize: number;
  80750. path3D: Path3D;
  80751. pathArray: Vector3[][];
  80752. arc: number;
  80753. radius: number;
  80754. cap: number;
  80755. tessellation: number;
  80756. }
  80757. /**
  80758. * @hidden
  80759. **/
  80760. class _InstanceDataStorage {
  80761. visibleInstances: any;
  80762. batchCache: _InstancesBatch;
  80763. instancesBufferSize: number;
  80764. instancesBuffer: Nullable<Buffer>;
  80765. instancesData: Float32Array;
  80766. overridenInstanceCount: number;
  80767. isFrozen: boolean;
  80768. previousBatch: _InstancesBatch;
  80769. hardwareInstancedRendering: boolean;
  80770. sideOrientation: number;
  80771. }
  80772. /**
  80773. * @hidden
  80774. **/
  80775. export class _InstancesBatch {
  80776. mustReturn: boolean;
  80777. visibleInstances: Nullable<InstancedMesh[]>[];
  80778. renderSelf: boolean[];
  80779. hardwareInstancedRendering: boolean[];
  80780. }
  80781. /**
  80782. * Class used to represent renderable models
  80783. */
  80784. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80785. /**
  80786. * Mesh side orientation : usually the external or front surface
  80787. */
  80788. static readonly FRONTSIDE: number;
  80789. /**
  80790. * Mesh side orientation : usually the internal or back surface
  80791. */
  80792. static readonly BACKSIDE: number;
  80793. /**
  80794. * Mesh side orientation : both internal and external or front and back surfaces
  80795. */
  80796. static readonly DOUBLESIDE: number;
  80797. /**
  80798. * Mesh side orientation : by default, `FRONTSIDE`
  80799. */
  80800. static readonly DEFAULTSIDE: number;
  80801. /**
  80802. * Mesh cap setting : no cap
  80803. */
  80804. static readonly NO_CAP: number;
  80805. /**
  80806. * Mesh cap setting : one cap at the beginning of the mesh
  80807. */
  80808. static readonly CAP_START: number;
  80809. /**
  80810. * Mesh cap setting : one cap at the end of the mesh
  80811. */
  80812. static readonly CAP_END: number;
  80813. /**
  80814. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80815. */
  80816. static readonly CAP_ALL: number;
  80817. /**
  80818. * Gets the default side orientation.
  80819. * @param orientation the orientation to value to attempt to get
  80820. * @returns the default orientation
  80821. * @hidden
  80822. */
  80823. static _GetDefaultSideOrientation(orientation?: number): number;
  80824. private _internalMeshDataInfo;
  80825. /**
  80826. * An event triggered before rendering the mesh
  80827. */
  80828. readonly onBeforeRenderObservable: Observable<Mesh>;
  80829. /**
  80830. * An event triggered before binding the mesh
  80831. */
  80832. readonly onBeforeBindObservable: Observable<Mesh>;
  80833. /**
  80834. * An event triggered after rendering the mesh
  80835. */
  80836. readonly onAfterRenderObservable: Observable<Mesh>;
  80837. /**
  80838. * An event triggered before drawing the mesh
  80839. */
  80840. readonly onBeforeDrawObservable: Observable<Mesh>;
  80841. private _onBeforeDrawObserver;
  80842. /**
  80843. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80844. */
  80845. onBeforeDraw: () => void;
  80846. /**
  80847. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80848. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80849. */
  80850. delayLoadState: number;
  80851. /**
  80852. * Gets the list of instances created from this mesh
  80853. * it is not supposed to be modified manually.
  80854. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80855. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80856. */
  80857. instances: InstancedMesh[];
  80858. /**
  80859. * Gets the file containing delay loading data for this mesh
  80860. */
  80861. delayLoadingFile: string;
  80862. /** @hidden */
  80863. _binaryInfo: any;
  80864. /**
  80865. * User defined function used to change how LOD level selection is done
  80866. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80867. */
  80868. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  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. /** @hidden */
  80888. _originalBuilderSideOrientation: number;
  80889. /**
  80890. * Use this property to change the original side orientation defined at construction time
  80891. */
  80892. overrideMaterialSideOrientation: Nullable<number>;
  80893. /**
  80894. * Gets the source mesh (the one used to clone this one from)
  80895. */
  80896. readonly source: Nullable<Mesh>;
  80897. /**
  80898. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80899. */
  80900. isUnIndexed: boolean;
  80901. /**
  80902. * @constructor
  80903. * @param name The value used by scene.getMeshByName() to do a lookup.
  80904. * @param scene The scene to add this mesh to.
  80905. * @param parent The parent of this mesh, if it has one
  80906. * @param source An optional Mesh from which geometry is shared, cloned.
  80907. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80908. * When false, achieved by calling a clone(), also passing False.
  80909. * This will make creation of children, recursive.
  80910. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80911. */
  80912. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80913. /**
  80914. * Gets the class name
  80915. * @returns the string "Mesh".
  80916. */
  80917. getClassName(): string;
  80918. /** @hidden */
  80919. readonly _isMesh: boolean;
  80920. /**
  80921. * Returns a description of this mesh
  80922. * @param fullDetails define if full details about this mesh must be used
  80923. * @returns a descriptive string representing this mesh
  80924. */
  80925. toString(fullDetails?: boolean): string;
  80926. /** @hidden */
  80927. _unBindEffect(): void;
  80928. /**
  80929. * Gets a boolean indicating if this mesh has LOD
  80930. */
  80931. readonly hasLODLevels: boolean;
  80932. /**
  80933. * Gets the list of MeshLODLevel associated with the current mesh
  80934. * @returns an array of MeshLODLevel
  80935. */
  80936. getLODLevels(): MeshLODLevel[];
  80937. private _sortLODLevels;
  80938. /**
  80939. * Add a mesh as LOD level triggered at the given distance.
  80940. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80941. * @param distance The distance from the center of the object to show this level
  80942. * @param mesh The mesh to be added as LOD level (can be null)
  80943. * @return This mesh (for chaining)
  80944. */
  80945. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80946. /**
  80947. * Returns the LOD level mesh at the passed distance or null if not found.
  80948. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80949. * @param distance The distance from the center of the object to show this level
  80950. * @returns a Mesh or `null`
  80951. */
  80952. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80953. /**
  80954. * Remove a mesh from the LOD array
  80955. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80956. * @param mesh defines the mesh to be removed
  80957. * @return This mesh (for chaining)
  80958. */
  80959. removeLODLevel(mesh: Mesh): Mesh;
  80960. /**
  80961. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80962. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80963. * @param camera defines the camera to use to compute distance
  80964. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80965. * @return This mesh (for chaining)
  80966. */
  80967. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80968. /**
  80969. * Gets the mesh internal Geometry object
  80970. */
  80971. readonly geometry: Nullable<Geometry>;
  80972. /**
  80973. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80974. * @returns the total number of vertices
  80975. */
  80976. getTotalVertices(): number;
  80977. /**
  80978. * Returns the content of an associated vertex buffer
  80979. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80980. * - VertexBuffer.PositionKind
  80981. * - VertexBuffer.UVKind
  80982. * - VertexBuffer.UV2Kind
  80983. * - VertexBuffer.UV3Kind
  80984. * - VertexBuffer.UV4Kind
  80985. * - VertexBuffer.UV5Kind
  80986. * - VertexBuffer.UV6Kind
  80987. * - VertexBuffer.ColorKind
  80988. * - VertexBuffer.MatricesIndicesKind
  80989. * - VertexBuffer.MatricesIndicesExtraKind
  80990. * - VertexBuffer.MatricesWeightsKind
  80991. * - VertexBuffer.MatricesWeightsExtraKind
  80992. * @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
  80993. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80994. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80995. */
  80996. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80997. /**
  80998. * Returns the mesh VertexBuffer object from the requested `kind`
  80999. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81000. * - VertexBuffer.PositionKind
  81001. * - VertexBuffer.UVKind
  81002. * - VertexBuffer.UV2Kind
  81003. * - VertexBuffer.UV3Kind
  81004. * - VertexBuffer.UV4Kind
  81005. * - VertexBuffer.UV5Kind
  81006. * - VertexBuffer.UV6Kind
  81007. * - VertexBuffer.ColorKind
  81008. * - VertexBuffer.MatricesIndicesKind
  81009. * - VertexBuffer.MatricesIndicesExtraKind
  81010. * - VertexBuffer.MatricesWeightsKind
  81011. * - VertexBuffer.MatricesWeightsExtraKind
  81012. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  81013. */
  81014. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81015. /**
  81016. * Tests if a specific vertex buffer is associated with this mesh
  81017. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81018. * - VertexBuffer.PositionKind
  81019. * - VertexBuffer.UVKind
  81020. * - VertexBuffer.UV2Kind
  81021. * - VertexBuffer.UV3Kind
  81022. * - VertexBuffer.UV4Kind
  81023. * - VertexBuffer.UV5Kind
  81024. * - VertexBuffer.UV6Kind
  81025. * - VertexBuffer.ColorKind
  81026. * - VertexBuffer.MatricesIndicesKind
  81027. * - VertexBuffer.MatricesIndicesExtraKind
  81028. * - VertexBuffer.MatricesWeightsKind
  81029. * - VertexBuffer.MatricesWeightsExtraKind
  81030. * @returns a boolean
  81031. */
  81032. isVerticesDataPresent(kind: string): boolean;
  81033. /**
  81034. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  81035. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81036. * - VertexBuffer.PositionKind
  81037. * - VertexBuffer.UVKind
  81038. * - VertexBuffer.UV2Kind
  81039. * - VertexBuffer.UV3Kind
  81040. * - VertexBuffer.UV4Kind
  81041. * - VertexBuffer.UV5Kind
  81042. * - VertexBuffer.UV6Kind
  81043. * - VertexBuffer.ColorKind
  81044. * - VertexBuffer.MatricesIndicesKind
  81045. * - VertexBuffer.MatricesIndicesExtraKind
  81046. * - VertexBuffer.MatricesWeightsKind
  81047. * - VertexBuffer.MatricesWeightsExtraKind
  81048. * @returns a boolean
  81049. */
  81050. isVertexBufferUpdatable(kind: string): boolean;
  81051. /**
  81052. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  81053. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81054. * - VertexBuffer.PositionKind
  81055. * - VertexBuffer.UVKind
  81056. * - VertexBuffer.UV2Kind
  81057. * - VertexBuffer.UV3Kind
  81058. * - VertexBuffer.UV4Kind
  81059. * - VertexBuffer.UV5Kind
  81060. * - VertexBuffer.UV6Kind
  81061. * - VertexBuffer.ColorKind
  81062. * - VertexBuffer.MatricesIndicesKind
  81063. * - VertexBuffer.MatricesIndicesExtraKind
  81064. * - VertexBuffer.MatricesWeightsKind
  81065. * - VertexBuffer.MatricesWeightsExtraKind
  81066. * @returns an array of strings
  81067. */
  81068. getVerticesDataKinds(): string[];
  81069. /**
  81070. * Returns a positive integer : the total number of indices in this mesh geometry.
  81071. * @returns the numner of indices or zero if the mesh has no geometry.
  81072. */
  81073. getTotalIndices(): number;
  81074. /**
  81075. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81076. * @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.
  81077. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81078. * @returns the indices array or an empty array if the mesh has no geometry
  81079. */
  81080. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81081. readonly isBlocked: boolean;
  81082. /**
  81083. * Determine if the current mesh is ready to be rendered
  81084. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81085. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  81086. * @returns true if all associated assets are ready (material, textures, shaders)
  81087. */
  81088. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  81089. /**
  81090. * 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.
  81091. */
  81092. readonly areNormalsFrozen: boolean;
  81093. /**
  81094. * 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.
  81095. * @returns the current mesh
  81096. */
  81097. freezeNormals(): Mesh;
  81098. /**
  81099. * 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
  81100. * @returns the current mesh
  81101. */
  81102. unfreezeNormals(): Mesh;
  81103. /**
  81104. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  81105. */
  81106. overridenInstanceCount: number;
  81107. /** @hidden */
  81108. _preActivate(): Mesh;
  81109. /** @hidden */
  81110. _preActivateForIntermediateRendering(renderId: number): Mesh;
  81111. /** @hidden */
  81112. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  81113. /**
  81114. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81115. * This means the mesh underlying bounding box and sphere are recomputed.
  81116. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81117. * @returns the current mesh
  81118. */
  81119. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  81120. /** @hidden */
  81121. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  81122. /**
  81123. * This function will subdivide the mesh into multiple submeshes
  81124. * @param count defines the expected number of submeshes
  81125. */
  81126. subdivide(count: number): void;
  81127. /**
  81128. * Copy a FloatArray into a specific associated vertex buffer
  81129. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81130. * - VertexBuffer.PositionKind
  81131. * - VertexBuffer.UVKind
  81132. * - VertexBuffer.UV2Kind
  81133. * - VertexBuffer.UV3Kind
  81134. * - VertexBuffer.UV4Kind
  81135. * - VertexBuffer.UV5Kind
  81136. * - VertexBuffer.UV6Kind
  81137. * - VertexBuffer.ColorKind
  81138. * - VertexBuffer.MatricesIndicesKind
  81139. * - VertexBuffer.MatricesIndicesExtraKind
  81140. * - VertexBuffer.MatricesWeightsKind
  81141. * - VertexBuffer.MatricesWeightsExtraKind
  81142. * @param data defines the data source
  81143. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81144. * @param stride defines the data stride size (can be null)
  81145. * @returns the current mesh
  81146. */
  81147. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  81148. /**
  81149. * Flags an associated vertex buffer as updatable
  81150. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81151. * - VertexBuffer.PositionKind
  81152. * - VertexBuffer.UVKind
  81153. * - VertexBuffer.UV2Kind
  81154. * - VertexBuffer.UV3Kind
  81155. * - VertexBuffer.UV4Kind
  81156. * - VertexBuffer.UV5Kind
  81157. * - VertexBuffer.UV6Kind
  81158. * - VertexBuffer.ColorKind
  81159. * - VertexBuffer.MatricesIndicesKind
  81160. * - VertexBuffer.MatricesIndicesExtraKind
  81161. * - VertexBuffer.MatricesWeightsKind
  81162. * - VertexBuffer.MatricesWeightsExtraKind
  81163. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81164. */
  81165. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  81166. /**
  81167. * Sets the mesh global Vertex Buffer
  81168. * @param buffer defines the buffer to use
  81169. * @returns the current mesh
  81170. */
  81171. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  81172. /**
  81173. * Update a specific associated vertex buffer
  81174. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81175. * - VertexBuffer.PositionKind
  81176. * - VertexBuffer.UVKind
  81177. * - VertexBuffer.UV2Kind
  81178. * - VertexBuffer.UV3Kind
  81179. * - VertexBuffer.UV4Kind
  81180. * - VertexBuffer.UV5Kind
  81181. * - VertexBuffer.UV6Kind
  81182. * - VertexBuffer.ColorKind
  81183. * - VertexBuffer.MatricesIndicesKind
  81184. * - VertexBuffer.MatricesIndicesExtraKind
  81185. * - VertexBuffer.MatricesWeightsKind
  81186. * - VertexBuffer.MatricesWeightsExtraKind
  81187. * @param data defines the data source
  81188. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81189. * @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)
  81190. * @returns the current mesh
  81191. */
  81192. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  81193. /**
  81194. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81195. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81196. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81197. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81198. * @returns the current mesh
  81199. */
  81200. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  81201. /**
  81202. * Creates a un-shared specific occurence of the geometry for the mesh.
  81203. * @returns the current mesh
  81204. */
  81205. makeGeometryUnique(): Mesh;
  81206. /**
  81207. * Set the index buffer of this mesh
  81208. * @param indices defines the source data
  81209. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81210. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81211. * @returns the current mesh
  81212. */
  81213. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  81214. /**
  81215. * Update the current index buffer
  81216. * @param indices defines the source data
  81217. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81218. * @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)
  81219. * @returns the current mesh
  81220. */
  81221. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  81222. /**
  81223. * Invert the geometry to move from a right handed system to a left handed one.
  81224. * @returns the current mesh
  81225. */
  81226. toLeftHanded(): Mesh;
  81227. /** @hidden */
  81228. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  81229. /** @hidden */
  81230. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  81231. /**
  81232. * Registers for this mesh a javascript function called just before the rendering process
  81233. * @param func defines the function to call before rendering this mesh
  81234. * @returns the current mesh
  81235. */
  81236. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81237. /**
  81238. * Disposes a previously registered javascript function called before the rendering
  81239. * @param func defines the function to remove
  81240. * @returns the current mesh
  81241. */
  81242. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81243. /**
  81244. * Registers for this mesh a javascript function called just after the rendering is complete
  81245. * @param func defines the function to call after rendering this mesh
  81246. * @returns the current mesh
  81247. */
  81248. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81249. /**
  81250. * Disposes a previously registered javascript function called after the rendering.
  81251. * @param func defines the function to remove
  81252. * @returns the current mesh
  81253. */
  81254. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81255. /** @hidden */
  81256. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  81257. /** @hidden */
  81258. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  81259. /** @hidden */
  81260. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  81261. /** @hidden */
  81262. _freeze(): void;
  81263. /** @hidden */
  81264. _unFreeze(): void;
  81265. /**
  81266. * 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
  81267. * @param subMesh defines the subMesh to render
  81268. * @param enableAlphaMode defines if alpha mode can be changed
  81269. * @returns the current mesh
  81270. */
  81271. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  81272. private _onBeforeDraw;
  81273. /**
  81274. * Renormalize the mesh and patch it up if there are no weights
  81275. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81276. * However in the case of zero weights then we set just a single influence to 1.
  81277. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81278. */
  81279. cleanMatrixWeights(): void;
  81280. private normalizeSkinFourWeights;
  81281. private normalizeSkinWeightsAndExtra;
  81282. /**
  81283. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81284. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81285. * the user know there was an issue with importing the mesh
  81286. * @returns a validation object with skinned, valid and report string
  81287. */
  81288. validateSkinning(): {
  81289. skinned: boolean;
  81290. valid: boolean;
  81291. report: string;
  81292. };
  81293. /** @hidden */
  81294. _checkDelayState(): Mesh;
  81295. private _queueLoad;
  81296. /**
  81297. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81298. * A mesh is in the frustum if its bounding box intersects the frustum
  81299. * @param frustumPlanes defines the frustum to test
  81300. * @returns true if the mesh is in the frustum planes
  81301. */
  81302. isInFrustum(frustumPlanes: Plane[]): boolean;
  81303. /**
  81304. * Sets the mesh material by the material or multiMaterial `id` property
  81305. * @param id is a string identifying the material or the multiMaterial
  81306. * @returns the current mesh
  81307. */
  81308. setMaterialByID(id: string): Mesh;
  81309. /**
  81310. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81311. * @returns an array of IAnimatable
  81312. */
  81313. getAnimatables(): IAnimatable[];
  81314. /**
  81315. * Modifies the mesh geometry according to the passed transformation matrix.
  81316. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81317. * The mesh normals are modified using the same transformation.
  81318. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81319. * @param transform defines the transform matrix to use
  81320. * @see http://doc.babylonjs.com/resources/baking_transformations
  81321. * @returns the current mesh
  81322. */
  81323. bakeTransformIntoVertices(transform: Matrix): Mesh;
  81324. /**
  81325. * Modifies the mesh geometry according to its own current World Matrix.
  81326. * The mesh World Matrix is then reset.
  81327. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81328. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81329. * @see http://doc.babylonjs.com/resources/baking_transformations
  81330. * @returns the current mesh
  81331. */
  81332. bakeCurrentTransformIntoVertices(): Mesh;
  81333. /** @hidden */
  81334. readonly _positions: Nullable<Vector3[]>;
  81335. /** @hidden */
  81336. _resetPointsArrayCache(): Mesh;
  81337. /** @hidden */
  81338. _generatePointsArray(): boolean;
  81339. /**
  81340. * Returns a new Mesh object generated from the current mesh properties.
  81341. * This method must not get confused with createInstance()
  81342. * @param name is a string, the name given to the new mesh
  81343. * @param newParent can be any Node object (default `null`)
  81344. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81345. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81346. * @returns a new mesh
  81347. */
  81348. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  81349. /**
  81350. * Releases resources associated with this mesh.
  81351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81353. */
  81354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81355. /**
  81356. * Modifies the mesh geometry according to a displacement map.
  81357. * 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.
  81358. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81359. * @param url is a string, the URL from the image file is to be downloaded.
  81360. * @param minHeight is the lower limit of the displacement.
  81361. * @param maxHeight is the upper limit of the displacement.
  81362. * @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.
  81363. * @param uvOffset is an optional vector2 used to offset UV.
  81364. * @param uvScale is an optional vector2 used to scale UV.
  81365. * @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.
  81366. * @returns the Mesh.
  81367. */
  81368. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81369. /**
  81370. * Modifies the mesh geometry according to a displacementMap buffer.
  81371. * 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.
  81372. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81373. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81374. * @param heightMapWidth is the width of the buffer image.
  81375. * @param heightMapHeight is the height of the buffer image.
  81376. * @param minHeight is the lower limit of the displacement.
  81377. * @param maxHeight is the upper limit of the displacement.
  81378. * @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.
  81379. * @param uvOffset is an optional vector2 used to offset UV.
  81380. * @param uvScale is an optional vector2 used to scale UV.
  81381. * @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.
  81382. * @returns the Mesh.
  81383. */
  81384. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81385. /**
  81386. * Modify the mesh to get a flat shading rendering.
  81387. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81388. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81389. * @returns current mesh
  81390. */
  81391. convertToFlatShadedMesh(): Mesh;
  81392. /**
  81393. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  81394. * In other words, more vertices, no more indices and a single bigger VBO.
  81395. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  81396. * @returns current mesh
  81397. */
  81398. convertToUnIndexedMesh(): Mesh;
  81399. /**
  81400. * Inverses facet orientations.
  81401. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81402. * @param flipNormals will also inverts the normals
  81403. * @returns current mesh
  81404. */
  81405. flipFaces(flipNormals?: boolean): Mesh;
  81406. /**
  81407. * Increase the number of facets and hence vertices in a mesh
  81408. * Vertex normals are interpolated from existing vertex normals
  81409. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81410. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  81411. */
  81412. increaseVertices(numberPerEdge: number): void;
  81413. /**
  81414. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  81415. * This will undo any application of covertToFlatShadedMesh
  81416. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81417. */
  81418. forceSharedVertices(): void;
  81419. /** @hidden */
  81420. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  81421. /** @hidden */
  81422. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81423. /**
  81424. * Creates a new InstancedMesh object from the mesh model.
  81425. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81426. * @param name defines the name of the new instance
  81427. * @returns a new InstancedMesh
  81428. */
  81429. createInstance(name: string): InstancedMesh;
  81430. /**
  81431. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81432. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81433. * @returns the current mesh
  81434. */
  81435. synchronizeInstances(): Mesh;
  81436. /**
  81437. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81438. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81439. * This should be used together with the simplification to avoid disappearing triangles.
  81440. * @param successCallback an optional success callback to be called after the optimization finished.
  81441. * @returns the current mesh
  81442. */
  81443. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81444. /**
  81445. * Serialize current mesh
  81446. * @param serializationObject defines the object which will receive the serialization data
  81447. */
  81448. serialize(serializationObject: any): void;
  81449. /** @hidden */
  81450. _syncGeometryWithMorphTargetManager(): void;
  81451. /** @hidden */
  81452. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81453. /**
  81454. * Returns a new Mesh object parsed from the source provided.
  81455. * @param parsedMesh is the source
  81456. * @param scene defines the hosting scene
  81457. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81458. * @returns a new Mesh
  81459. */
  81460. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81461. /**
  81462. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81463. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81464. * @param name defines the name of the mesh to create
  81465. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81466. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81467. * @param closePath creates a seam between the first and the last points of each path of the path array
  81468. * @param offset is taken in account only if the `pathArray` is containing a single path
  81469. * @param scene defines the hosting scene
  81470. * @param updatable defines if the mesh must be flagged as updatable
  81471. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81472. * @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)
  81473. * @returns a new Mesh
  81474. */
  81475. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81476. /**
  81477. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81478. * @param name defines the name of the mesh to create
  81479. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81480. * @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
  81481. * @param scene defines the hosting scene
  81482. * @param updatable defines if the mesh must be flagged as updatable
  81483. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81484. * @returns a new Mesh
  81485. */
  81486. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81487. /**
  81488. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81489. * @param name defines the name of the mesh to create
  81490. * @param size sets the size (float) of each box side (default 1)
  81491. * @param scene defines the hosting scene
  81492. * @param updatable defines if the mesh must be flagged as updatable
  81493. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81494. * @returns a new Mesh
  81495. */
  81496. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81497. /**
  81498. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81499. * @param name defines the name of the mesh to create
  81500. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81501. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81502. * @param scene defines the hosting scene
  81503. * @param updatable defines if the mesh must be flagged as updatable
  81504. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81505. * @returns a new Mesh
  81506. */
  81507. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81508. /**
  81509. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81510. * @param name defines the name of the mesh to create
  81511. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81512. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81513. * @param scene defines the hosting scene
  81514. * @returns a new Mesh
  81515. */
  81516. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81517. /**
  81518. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81519. * @param name defines the name of the mesh to create
  81520. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81521. * @param diameterTop set the top cap diameter (floats, default 1)
  81522. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81523. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81524. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81525. * @param scene defines the hosting scene
  81526. * @param updatable defines if the mesh must be flagged as updatable
  81527. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81528. * @returns a new Mesh
  81529. */
  81530. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81531. /**
  81532. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81533. * @param name defines the name of the mesh to create
  81534. * @param diameter sets the diameter size (float) of the torus (default 1)
  81535. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81536. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81537. * @param scene defines the hosting scene
  81538. * @param updatable defines if the mesh must be flagged as updatable
  81539. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81540. * @returns a new Mesh
  81541. */
  81542. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81543. /**
  81544. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81545. * @param name defines the name of the mesh to create
  81546. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81547. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81548. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81549. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81550. * @param p the number of windings on X axis (positive integers, default 2)
  81551. * @param q the number of windings on Y axis (positive integers, default 3)
  81552. * @param scene defines the hosting scene
  81553. * @param updatable defines if the mesh must be flagged as updatable
  81554. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81555. * @returns a new Mesh
  81556. */
  81557. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81558. /**
  81559. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  81560. * @param name defines the name of the mesh to create
  81561. * @param points is an array successive Vector3
  81562. * @param scene defines the hosting scene
  81563. * @param updatable defines if the mesh must be flagged as updatable
  81564. * @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).
  81565. * @returns a new Mesh
  81566. */
  81567. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81568. /**
  81569. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81570. * @param name defines the name of the mesh to create
  81571. * @param points is an array successive Vector3
  81572. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81573. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81574. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81575. * @param scene defines the hosting scene
  81576. * @param updatable defines if the mesh must be flagged as updatable
  81577. * @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)
  81578. * @returns a new Mesh
  81579. */
  81580. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81581. /**
  81582. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81583. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81584. * 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.
  81585. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81586. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81587. * Remember you can only change the shape positions, not their number when updating a polygon.
  81588. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81589. * @param name defines the name of the mesh to create
  81590. * @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
  81591. * @param scene defines the hosting scene
  81592. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81593. * @param updatable defines if the mesh must be flagged as updatable
  81594. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81595. * @param earcutInjection can be used to inject your own earcut reference
  81596. * @returns a new Mesh
  81597. */
  81598. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81599. /**
  81600. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81601. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81602. * @param name defines the name of the mesh to create
  81603. * @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
  81604. * @param depth defines the height of extrusion
  81605. * @param scene defines the hosting scene
  81606. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81607. * @param updatable defines if the mesh must be flagged as updatable
  81608. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81609. * @param earcutInjection can be used to inject your own earcut reference
  81610. * @returns a new Mesh
  81611. */
  81612. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81613. /**
  81614. * Creates an extruded shape mesh.
  81615. * 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
  81616. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81617. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81618. * @param name defines the name of the mesh to create
  81619. * @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
  81620. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81621. * @param scale is the value to scale the shape
  81622. * @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
  81623. * @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
  81624. * @param scene defines the hosting scene
  81625. * @param updatable defines if the mesh must be flagged as updatable
  81626. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81627. * @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)
  81628. * @returns a new Mesh
  81629. */
  81630. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81631. /**
  81632. * Creates an custom extruded shape mesh.
  81633. * The custom extrusion is a parametric shape.
  81634. * It has no predefined shape. Its final shape will depend on the input parameters.
  81635. * Please consider using the same method from the MeshBuilder class instead
  81636. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81637. * @param name defines the name of the mesh to create
  81638. * @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
  81639. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81640. * @param scaleFunction is a custom Javascript function called on each path point
  81641. * @param rotationFunction is a custom Javascript function called on each path point
  81642. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81643. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81644. * @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
  81645. * @param scene defines the hosting scene
  81646. * @param updatable defines if the mesh must be flagged as updatable
  81647. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81648. * @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)
  81649. * @returns a new Mesh
  81650. */
  81651. 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;
  81652. /**
  81653. * Creates lathe mesh.
  81654. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81655. * Please consider using the same method from the MeshBuilder class instead
  81656. * @param name defines the name of the mesh to create
  81657. * @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
  81658. * @param radius is the radius value of the lathe
  81659. * @param tessellation is the side number of the lathe.
  81660. * @param scene defines the hosting scene
  81661. * @param updatable defines if the mesh must be flagged as updatable
  81662. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81663. * @returns a new Mesh
  81664. */
  81665. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81666. /**
  81667. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81668. * @param name defines the name of the mesh to create
  81669. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81670. * @param scene defines the hosting scene
  81671. * @param updatable defines if the mesh must be flagged as updatable
  81672. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81673. * @returns a new Mesh
  81674. */
  81675. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81676. /**
  81677. * Creates a ground mesh.
  81678. * Please consider using the same method from the MeshBuilder class instead
  81679. * @param name defines the name of the mesh to create
  81680. * @param width set the width of the ground
  81681. * @param height set the height of the ground
  81682. * @param subdivisions sets the number of subdivisions per side
  81683. * @param scene defines the hosting scene
  81684. * @param updatable defines if the mesh must be flagged as updatable
  81685. * @returns a new Mesh
  81686. */
  81687. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81688. /**
  81689. * Creates a tiled ground mesh.
  81690. * Please consider using the same method from the MeshBuilder class instead
  81691. * @param name defines the name of the mesh to create
  81692. * @param xmin set the ground minimum X coordinate
  81693. * @param zmin set the ground minimum Y coordinate
  81694. * @param xmax set the ground maximum X coordinate
  81695. * @param zmax set the ground maximum Z coordinate
  81696. * @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
  81697. * @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
  81698. * @param scene defines the hosting scene
  81699. * @param updatable defines if the mesh must be flagged as updatable
  81700. * @returns a new Mesh
  81701. */
  81702. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81703. w: number;
  81704. h: number;
  81705. }, precision: {
  81706. w: number;
  81707. h: number;
  81708. }, scene: Scene, updatable?: boolean): Mesh;
  81709. /**
  81710. * Creates a ground mesh from a height map.
  81711. * Please consider using the same method from the MeshBuilder class instead
  81712. * @see http://doc.babylonjs.com/babylon101/height_map
  81713. * @param name defines the name of the mesh to create
  81714. * @param url sets the URL of the height map image resource
  81715. * @param width set the ground width size
  81716. * @param height set the ground height size
  81717. * @param subdivisions sets the number of subdivision per side
  81718. * @param minHeight is the minimum altitude on the ground
  81719. * @param maxHeight is the maximum altitude on the ground
  81720. * @param scene defines the hosting scene
  81721. * @param updatable defines if the mesh must be flagged as updatable
  81722. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81723. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81724. * @returns a new Mesh
  81725. */
  81726. 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;
  81727. /**
  81728. * Creates a tube mesh.
  81729. * The tube is a parametric shape.
  81730. * It has no predefined shape. Its final shape will depend on the input parameters.
  81731. * Please consider using the same method from the MeshBuilder class instead
  81732. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81733. * @param name defines the name of the mesh to create
  81734. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81735. * @param radius sets the tube radius size
  81736. * @param tessellation is the number of sides on the tubular surface
  81737. * @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
  81738. * @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
  81739. * @param scene defines the hosting scene
  81740. * @param updatable defines if the mesh must be flagged as updatable
  81741. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81742. * @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)
  81743. * @returns a new Mesh
  81744. */
  81745. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81746. (i: number, distance: number): number;
  81747. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81748. /**
  81749. * Creates a polyhedron mesh.
  81750. * Please consider using the same method from the MeshBuilder class instead.
  81751. * * 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
  81752. * * The parameter `size` (positive float, default 1) sets the polygon size
  81753. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81754. * * 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`
  81755. * * 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
  81756. * * 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)`)
  81757. * * 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
  81758. * * 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
  81759. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81760. * * If you create a double-sided mesh, you can choose what parts of 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
  81761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81762. * @param name defines the name of the mesh to create
  81763. * @param options defines the options used to create the mesh
  81764. * @param scene defines the hosting scene
  81765. * @returns a new Mesh
  81766. */
  81767. static CreatePolyhedron(name: string, options: {
  81768. type?: number;
  81769. size?: number;
  81770. sizeX?: number;
  81771. sizeY?: number;
  81772. sizeZ?: number;
  81773. custom?: any;
  81774. faceUV?: Vector4[];
  81775. faceColors?: Color4[];
  81776. updatable?: boolean;
  81777. sideOrientation?: number;
  81778. }, scene: Scene): Mesh;
  81779. /**
  81780. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81781. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81782. * * 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`)
  81783. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81784. * * 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
  81785. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81786. * * If you create a double-sided mesh, you can choose what parts of 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
  81787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81788. * @param name defines the name of the mesh
  81789. * @param options defines the options used to create the mesh
  81790. * @param scene defines the hosting scene
  81791. * @returns a new Mesh
  81792. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81793. */
  81794. static CreateIcoSphere(name: string, options: {
  81795. radius?: number;
  81796. flat?: boolean;
  81797. subdivisions?: number;
  81798. sideOrientation?: number;
  81799. updatable?: boolean;
  81800. }, scene: Scene): Mesh;
  81801. /**
  81802. * Creates a decal mesh.
  81803. * Please consider using the same method from the MeshBuilder class instead.
  81804. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81805. * @param name defines the name of the mesh
  81806. * @param sourceMesh defines the mesh receiving the decal
  81807. * @param position sets the position of the decal in world coordinates
  81808. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81809. * @param size sets the decal scaling
  81810. * @param angle sets the angle to rotate the decal
  81811. * @returns a new Mesh
  81812. */
  81813. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81814. /**
  81815. * Prepare internal position array for software CPU skinning
  81816. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81817. */
  81818. setPositionsForCPUSkinning(): Float32Array;
  81819. /**
  81820. * Prepare internal normal array for software CPU skinning
  81821. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81822. */
  81823. setNormalsForCPUSkinning(): Float32Array;
  81824. /**
  81825. * Updates the vertex buffer by applying transformation from the bones
  81826. * @param skeleton defines the skeleton to apply to current mesh
  81827. * @returns the current mesh
  81828. */
  81829. applySkeleton(skeleton: Skeleton): Mesh;
  81830. /**
  81831. * 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
  81832. * @param meshes defines the list of meshes to scan
  81833. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81834. */
  81835. static MinMax(meshes: AbstractMesh[]): {
  81836. min: Vector3;
  81837. max: Vector3;
  81838. };
  81839. /**
  81840. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81841. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81842. * @returns a vector3
  81843. */
  81844. static Center(meshesOrMinMaxVector: {
  81845. min: Vector3;
  81846. max: Vector3;
  81847. } | AbstractMesh[]): Vector3;
  81848. /**
  81849. * Merge the array of meshes into a single mesh for performance reasons.
  81850. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81851. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81852. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81853. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81854. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81855. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81856. * @returns a new mesh
  81857. */
  81858. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81859. /** @hidden */
  81860. addInstance(instance: InstancedMesh): void;
  81861. /** @hidden */
  81862. removeInstance(instance: InstancedMesh): void;
  81863. }
  81864. }
  81865. declare module BABYLON {
  81866. /**
  81867. * Base class for the main features of a material in Babylon.js
  81868. */
  81869. export class Material implements IAnimatable {
  81870. /**
  81871. * Returns the triangle fill mode
  81872. */
  81873. static readonly TriangleFillMode: number;
  81874. /**
  81875. * Returns the wireframe mode
  81876. */
  81877. static readonly WireFrameFillMode: number;
  81878. /**
  81879. * Returns the point fill mode
  81880. */
  81881. static readonly PointFillMode: number;
  81882. /**
  81883. * Returns the point list draw mode
  81884. */
  81885. static readonly PointListDrawMode: number;
  81886. /**
  81887. * Returns the line list draw mode
  81888. */
  81889. static readonly LineListDrawMode: number;
  81890. /**
  81891. * Returns the line loop draw mode
  81892. */
  81893. static readonly LineLoopDrawMode: number;
  81894. /**
  81895. * Returns the line strip draw mode
  81896. */
  81897. static readonly LineStripDrawMode: number;
  81898. /**
  81899. * Returns the triangle strip draw mode
  81900. */
  81901. static readonly TriangleStripDrawMode: number;
  81902. /**
  81903. * Returns the triangle fan draw mode
  81904. */
  81905. static readonly TriangleFanDrawMode: number;
  81906. /**
  81907. * Stores the clock-wise side orientation
  81908. */
  81909. static readonly ClockWiseSideOrientation: number;
  81910. /**
  81911. * Stores the counter clock-wise side orientation
  81912. */
  81913. static readonly CounterClockWiseSideOrientation: number;
  81914. /**
  81915. * The dirty texture flag value
  81916. */
  81917. static readonly TextureDirtyFlag: number;
  81918. /**
  81919. * The dirty light flag value
  81920. */
  81921. static readonly LightDirtyFlag: number;
  81922. /**
  81923. * The dirty fresnel flag value
  81924. */
  81925. static readonly FresnelDirtyFlag: number;
  81926. /**
  81927. * The dirty attribute flag value
  81928. */
  81929. static readonly AttributesDirtyFlag: number;
  81930. /**
  81931. * The dirty misc flag value
  81932. */
  81933. static readonly MiscDirtyFlag: number;
  81934. /**
  81935. * The all dirty flag value
  81936. */
  81937. static readonly AllDirtyFlag: number;
  81938. /**
  81939. * The ID of the material
  81940. */
  81941. id: string;
  81942. /**
  81943. * Gets or sets the unique id of the material
  81944. */
  81945. uniqueId: number;
  81946. /**
  81947. * The name of the material
  81948. */
  81949. name: string;
  81950. /**
  81951. * Gets or sets user defined metadata
  81952. */
  81953. metadata: any;
  81954. /**
  81955. * For internal use only. Please do not use.
  81956. */
  81957. reservedDataStore: any;
  81958. /**
  81959. * Specifies if the ready state should be checked on each call
  81960. */
  81961. checkReadyOnEveryCall: boolean;
  81962. /**
  81963. * Specifies if the ready state should be checked once
  81964. */
  81965. checkReadyOnlyOnce: boolean;
  81966. /**
  81967. * The state of the material
  81968. */
  81969. state: string;
  81970. /**
  81971. * The alpha value of the material
  81972. */
  81973. protected _alpha: number;
  81974. /**
  81975. * List of inspectable custom properties (used by the Inspector)
  81976. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81977. */
  81978. inspectableCustomProperties: IInspectable[];
  81979. /**
  81980. * Sets the alpha value of the material
  81981. */
  81982. /**
  81983. * Gets the alpha value of the material
  81984. */
  81985. alpha: number;
  81986. /**
  81987. * Specifies if back face culling is enabled
  81988. */
  81989. protected _backFaceCulling: boolean;
  81990. /**
  81991. * Sets the back-face culling state
  81992. */
  81993. /**
  81994. * Gets the back-face culling state
  81995. */
  81996. backFaceCulling: boolean;
  81997. /**
  81998. * Stores the value for side orientation
  81999. */
  82000. sideOrientation: number;
  82001. /**
  82002. * Callback triggered when the material is compiled
  82003. */
  82004. onCompiled: Nullable<(effect: Effect) => void>;
  82005. /**
  82006. * Callback triggered when an error occurs
  82007. */
  82008. onError: Nullable<(effect: Effect, errors: string) => void>;
  82009. /**
  82010. * Callback triggered to get the render target textures
  82011. */
  82012. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  82013. /**
  82014. * Gets a boolean indicating that current material needs to register RTT
  82015. */
  82016. readonly hasRenderTargetTextures: boolean;
  82017. /**
  82018. * Specifies if the material should be serialized
  82019. */
  82020. doNotSerialize: boolean;
  82021. /**
  82022. * @hidden
  82023. */
  82024. _storeEffectOnSubMeshes: boolean;
  82025. /**
  82026. * Stores the animations for the material
  82027. */
  82028. animations: Nullable<Array<Animation>>;
  82029. /**
  82030. * An event triggered when the material is disposed
  82031. */
  82032. onDisposeObservable: Observable<Material>;
  82033. /**
  82034. * An observer which watches for dispose events
  82035. */
  82036. private _onDisposeObserver;
  82037. private _onUnBindObservable;
  82038. /**
  82039. * Called during a dispose event
  82040. */
  82041. onDispose: () => void;
  82042. private _onBindObservable;
  82043. /**
  82044. * An event triggered when the material is bound
  82045. */
  82046. readonly onBindObservable: Observable<AbstractMesh>;
  82047. /**
  82048. * An observer which watches for bind events
  82049. */
  82050. private _onBindObserver;
  82051. /**
  82052. * Called during a bind event
  82053. */
  82054. onBind: (Mesh: AbstractMesh) => void;
  82055. /**
  82056. * An event triggered when the material is unbound
  82057. */
  82058. readonly onUnBindObservable: Observable<Material>;
  82059. /**
  82060. * Stores the value of the alpha mode
  82061. */
  82062. private _alphaMode;
  82063. /**
  82064. * Sets the value of the alpha mode.
  82065. *
  82066. * | Value | Type | Description |
  82067. * | --- | --- | --- |
  82068. * | 0 | ALPHA_DISABLE | |
  82069. * | 1 | ALPHA_ADD | |
  82070. * | 2 | ALPHA_COMBINE | |
  82071. * | 3 | ALPHA_SUBTRACT | |
  82072. * | 4 | ALPHA_MULTIPLY | |
  82073. * | 5 | ALPHA_MAXIMIZED | |
  82074. * | 6 | ALPHA_ONEONE | |
  82075. * | 7 | ALPHA_PREMULTIPLIED | |
  82076. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  82077. * | 9 | ALPHA_INTERPOLATE | |
  82078. * | 10 | ALPHA_SCREENMODE | |
  82079. *
  82080. */
  82081. /**
  82082. * Gets the value of the alpha mode
  82083. */
  82084. alphaMode: number;
  82085. /**
  82086. * Stores the state of the need depth pre-pass value
  82087. */
  82088. private _needDepthPrePass;
  82089. /**
  82090. * Sets the need depth pre-pass value
  82091. */
  82092. /**
  82093. * Gets the depth pre-pass value
  82094. */
  82095. needDepthPrePass: boolean;
  82096. /**
  82097. * Specifies if depth writing should be disabled
  82098. */
  82099. disableDepthWrite: boolean;
  82100. /**
  82101. * Specifies if depth writing should be forced
  82102. */
  82103. forceDepthWrite: boolean;
  82104. /**
  82105. * Specifies if there should be a separate pass for culling
  82106. */
  82107. separateCullingPass: boolean;
  82108. /**
  82109. * Stores the state specifing if fog should be enabled
  82110. */
  82111. private _fogEnabled;
  82112. /**
  82113. * Sets the state for enabling fog
  82114. */
  82115. /**
  82116. * Gets the value of the fog enabled state
  82117. */
  82118. fogEnabled: boolean;
  82119. /**
  82120. * Stores the size of points
  82121. */
  82122. pointSize: number;
  82123. /**
  82124. * Stores the z offset value
  82125. */
  82126. zOffset: number;
  82127. /**
  82128. * Gets a value specifying if wireframe mode is enabled
  82129. */
  82130. /**
  82131. * Sets the state of wireframe mode
  82132. */
  82133. wireframe: boolean;
  82134. /**
  82135. * Gets the value specifying if point clouds are enabled
  82136. */
  82137. /**
  82138. * Sets the state of point cloud mode
  82139. */
  82140. pointsCloud: boolean;
  82141. /**
  82142. * Gets the material fill mode
  82143. */
  82144. /**
  82145. * Sets the material fill mode
  82146. */
  82147. fillMode: number;
  82148. /**
  82149. * @hidden
  82150. * Stores the effects for the material
  82151. */
  82152. _effect: Nullable<Effect>;
  82153. /**
  82154. * @hidden
  82155. * Specifies if the material was previously ready
  82156. */
  82157. _wasPreviouslyReady: boolean;
  82158. /**
  82159. * Specifies if uniform buffers should be used
  82160. */
  82161. private _useUBO;
  82162. /**
  82163. * Stores a reference to the scene
  82164. */
  82165. private _scene;
  82166. /**
  82167. * Stores the fill mode state
  82168. */
  82169. private _fillMode;
  82170. /**
  82171. * Specifies if the depth write state should be cached
  82172. */
  82173. private _cachedDepthWriteState;
  82174. /**
  82175. * Stores the uniform buffer
  82176. */
  82177. protected _uniformBuffer: UniformBuffer;
  82178. /** @hidden */
  82179. _indexInSceneMaterialArray: number;
  82180. /** @hidden */
  82181. meshMap: Nullable<{
  82182. [id: string]: AbstractMesh | undefined;
  82183. }>;
  82184. /**
  82185. * Creates a material instance
  82186. * @param name defines the name of the material
  82187. * @param scene defines the scene to reference
  82188. * @param doNotAdd specifies if the material should be added to the scene
  82189. */
  82190. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  82191. /**
  82192. * Returns a string representation of the current material
  82193. * @param fullDetails defines a boolean indicating which levels of logging is desired
  82194. * @returns a string with material information
  82195. */
  82196. toString(fullDetails?: boolean): string;
  82197. /**
  82198. * Gets the class name of the material
  82199. * @returns a string with the class name of the material
  82200. */
  82201. getClassName(): string;
  82202. /**
  82203. * Specifies if updates for the material been locked
  82204. */
  82205. readonly isFrozen: boolean;
  82206. /**
  82207. * Locks updates for the material
  82208. */
  82209. freeze(): void;
  82210. /**
  82211. * Unlocks updates for the material
  82212. */
  82213. unfreeze(): void;
  82214. /**
  82215. * Specifies if the material is ready to be used
  82216. * @param mesh defines the mesh to check
  82217. * @param useInstances specifies if instances should be used
  82218. * @returns a boolean indicating if the material is ready to be used
  82219. */
  82220. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82221. /**
  82222. * Specifies that the submesh is ready to be used
  82223. * @param mesh defines the mesh to check
  82224. * @param subMesh defines which submesh to check
  82225. * @param useInstances specifies that instances should be used
  82226. * @returns a boolean indicating that the submesh is ready or not
  82227. */
  82228. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82229. /**
  82230. * Returns the material effect
  82231. * @returns the effect associated with the material
  82232. */
  82233. getEffect(): Nullable<Effect>;
  82234. /**
  82235. * Returns the current scene
  82236. * @returns a Scene
  82237. */
  82238. getScene(): Scene;
  82239. /**
  82240. * Specifies if the material will require alpha blending
  82241. * @returns a boolean specifying if alpha blending is needed
  82242. */
  82243. needAlphaBlending(): boolean;
  82244. /**
  82245. * Specifies if the mesh will require alpha blending
  82246. * @param mesh defines the mesh to check
  82247. * @returns a boolean specifying if alpha blending is needed for the mesh
  82248. */
  82249. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  82250. /**
  82251. * Specifies if this material should be rendered in alpha test mode
  82252. * @returns a boolean specifying if an alpha test is needed.
  82253. */
  82254. needAlphaTesting(): boolean;
  82255. /**
  82256. * Gets the texture used for the alpha test
  82257. * @returns the texture to use for alpha testing
  82258. */
  82259. getAlphaTestTexture(): Nullable<BaseTexture>;
  82260. /**
  82261. * Marks the material to indicate that it needs to be re-calculated
  82262. */
  82263. markDirty(): void;
  82264. /** @hidden */
  82265. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  82266. /**
  82267. * Binds the material to the mesh
  82268. * @param world defines the world transformation matrix
  82269. * @param mesh defines the mesh to bind the material to
  82270. */
  82271. bind(world: Matrix, mesh?: Mesh): void;
  82272. /**
  82273. * Binds the submesh to the material
  82274. * @param world defines the world transformation matrix
  82275. * @param mesh defines the mesh containing the submesh
  82276. * @param subMesh defines the submesh to bind the material to
  82277. */
  82278. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  82279. /**
  82280. * Binds the world matrix to the material
  82281. * @param world defines the world transformation matrix
  82282. */
  82283. bindOnlyWorldMatrix(world: Matrix): void;
  82284. /**
  82285. * Binds the scene's uniform buffer to the effect.
  82286. * @param effect defines the effect to bind to the scene uniform buffer
  82287. * @param sceneUbo defines the uniform buffer storing scene data
  82288. */
  82289. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  82290. /**
  82291. * Binds the view matrix to the effect
  82292. * @param effect defines the effect to bind the view matrix to
  82293. */
  82294. bindView(effect: Effect): void;
  82295. /**
  82296. * Binds the view projection matrix to the effect
  82297. * @param effect defines the effect to bind the view projection matrix to
  82298. */
  82299. bindViewProjection(effect: Effect): void;
  82300. /**
  82301. * Specifies if material alpha testing should be turned on for the mesh
  82302. * @param mesh defines the mesh to check
  82303. */
  82304. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  82305. /**
  82306. * Processes to execute after binding the material to a mesh
  82307. * @param mesh defines the rendered mesh
  82308. */
  82309. protected _afterBind(mesh?: Mesh): void;
  82310. /**
  82311. * Unbinds the material from the mesh
  82312. */
  82313. unbind(): void;
  82314. /**
  82315. * Gets the active textures from the material
  82316. * @returns an array of textures
  82317. */
  82318. getActiveTextures(): BaseTexture[];
  82319. /**
  82320. * Specifies if the material uses a texture
  82321. * @param texture defines the texture to check against the material
  82322. * @returns a boolean specifying if the material uses the texture
  82323. */
  82324. hasTexture(texture: BaseTexture): boolean;
  82325. /**
  82326. * Makes a duplicate of the material, and gives it a new name
  82327. * @param name defines the new name for the duplicated material
  82328. * @returns the cloned material
  82329. */
  82330. clone(name: string): Nullable<Material>;
  82331. /**
  82332. * Gets the meshes bound to the material
  82333. * @returns an array of meshes bound to the material
  82334. */
  82335. getBindedMeshes(): AbstractMesh[];
  82336. /**
  82337. * Force shader compilation
  82338. * @param mesh defines the mesh associated with this material
  82339. * @param onCompiled defines a function to execute once the material is compiled
  82340. * @param options defines the options to configure the compilation
  82341. */
  82342. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  82343. clipPlane: boolean;
  82344. }>): void;
  82345. /**
  82346. * Force shader compilation
  82347. * @param mesh defines the mesh that will use this material
  82348. * @param options defines additional options for compiling the shaders
  82349. * @returns a promise that resolves when the compilation completes
  82350. */
  82351. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  82352. clipPlane: boolean;
  82353. }>): Promise<void>;
  82354. private static readonly _ImageProcessingDirtyCallBack;
  82355. private static readonly _TextureDirtyCallBack;
  82356. private static readonly _FresnelDirtyCallBack;
  82357. private static readonly _MiscDirtyCallBack;
  82358. private static readonly _LightsDirtyCallBack;
  82359. private static readonly _AttributeDirtyCallBack;
  82360. private static _FresnelAndMiscDirtyCallBack;
  82361. private static _TextureAndMiscDirtyCallBack;
  82362. private static readonly _DirtyCallbackArray;
  82363. private static readonly _RunDirtyCallBacks;
  82364. /**
  82365. * Marks a define in the material to indicate that it needs to be re-computed
  82366. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  82367. */
  82368. markAsDirty(flag: number): void;
  82369. /**
  82370. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  82371. * @param func defines a function which checks material defines against the submeshes
  82372. */
  82373. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  82374. /**
  82375. * Indicates that image processing needs to be re-calculated for all submeshes
  82376. */
  82377. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  82378. /**
  82379. * Indicates that textures need to be re-calculated for all submeshes
  82380. */
  82381. protected _markAllSubMeshesAsTexturesDirty(): void;
  82382. /**
  82383. * Indicates that fresnel needs to be re-calculated for all submeshes
  82384. */
  82385. protected _markAllSubMeshesAsFresnelDirty(): void;
  82386. /**
  82387. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  82388. */
  82389. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  82390. /**
  82391. * Indicates that lights need to be re-calculated for all submeshes
  82392. */
  82393. protected _markAllSubMeshesAsLightsDirty(): void;
  82394. /**
  82395. * Indicates that attributes need to be re-calculated for all submeshes
  82396. */
  82397. protected _markAllSubMeshesAsAttributesDirty(): void;
  82398. /**
  82399. * Indicates that misc needs to be re-calculated for all submeshes
  82400. */
  82401. protected _markAllSubMeshesAsMiscDirty(): void;
  82402. /**
  82403. * Indicates that textures and misc need to be re-calculated for all submeshes
  82404. */
  82405. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  82406. /**
  82407. * Disposes the material
  82408. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82409. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82410. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82411. */
  82412. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82413. /** @hidden */
  82414. private releaseVertexArrayObject;
  82415. /**
  82416. * Serializes this material
  82417. * @returns the serialized material object
  82418. */
  82419. serialize(): any;
  82420. /**
  82421. * Creates a material from parsed material data
  82422. * @param parsedMaterial defines parsed material data
  82423. * @param scene defines the hosting scene
  82424. * @param rootUrl defines the root URL to use to load textures
  82425. * @returns a new material
  82426. */
  82427. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82428. }
  82429. }
  82430. declare module BABYLON {
  82431. /**
  82432. * Base class for submeshes
  82433. */
  82434. export class BaseSubMesh {
  82435. /** @hidden */
  82436. _materialDefines: Nullable<MaterialDefines>;
  82437. /** @hidden */
  82438. _materialEffect: Nullable<Effect>;
  82439. /**
  82440. * Gets associated effect
  82441. */
  82442. readonly effect: Nullable<Effect>;
  82443. /**
  82444. * Sets associated effect (effect used to render this submesh)
  82445. * @param effect defines the effect to associate with
  82446. * @param defines defines the set of defines used to compile this effect
  82447. */
  82448. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82449. }
  82450. /**
  82451. * Defines a subdivision inside a mesh
  82452. */
  82453. export class SubMesh extends BaseSubMesh implements ICullable {
  82454. /** the material index to use */
  82455. materialIndex: number;
  82456. /** vertex index start */
  82457. verticesStart: number;
  82458. /** vertices count */
  82459. verticesCount: number;
  82460. /** index start */
  82461. indexStart: number;
  82462. /** indices count */
  82463. indexCount: number;
  82464. /** @hidden */
  82465. _linesIndexCount: number;
  82466. private _mesh;
  82467. private _renderingMesh;
  82468. private _boundingInfo;
  82469. private _linesIndexBuffer;
  82470. /** @hidden */
  82471. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82472. /** @hidden */
  82473. _trianglePlanes: Plane[];
  82474. /** @hidden */
  82475. _lastColliderTransformMatrix: Nullable<Matrix>;
  82476. /** @hidden */
  82477. _renderId: number;
  82478. /** @hidden */
  82479. _alphaIndex: number;
  82480. /** @hidden */
  82481. _distanceToCamera: number;
  82482. /** @hidden */
  82483. _id: number;
  82484. private _currentMaterial;
  82485. /**
  82486. * Add a new submesh to a mesh
  82487. * @param materialIndex defines the material index to use
  82488. * @param verticesStart defines vertex index start
  82489. * @param verticesCount defines vertices count
  82490. * @param indexStart defines index start
  82491. * @param indexCount defines indices count
  82492. * @param mesh defines the parent mesh
  82493. * @param renderingMesh defines an optional rendering mesh
  82494. * @param createBoundingBox defines if bounding box should be created for this submesh
  82495. * @returns the new submesh
  82496. */
  82497. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82498. /**
  82499. * Creates a new submesh
  82500. * @param materialIndex defines the material index to use
  82501. * @param verticesStart defines vertex index start
  82502. * @param verticesCount defines vertices count
  82503. * @param indexStart defines index start
  82504. * @param indexCount defines indices count
  82505. * @param mesh defines the parent mesh
  82506. * @param renderingMesh defines an optional rendering mesh
  82507. * @param createBoundingBox defines if bounding box should be created for this submesh
  82508. */
  82509. constructor(
  82510. /** the material index to use */
  82511. materialIndex: number,
  82512. /** vertex index start */
  82513. verticesStart: number,
  82514. /** vertices count */
  82515. verticesCount: number,
  82516. /** index start */
  82517. indexStart: number,
  82518. /** indices count */
  82519. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82520. /**
  82521. * Returns true if this submesh covers the entire parent mesh
  82522. * @ignorenaming
  82523. */
  82524. readonly IsGlobal: boolean;
  82525. /**
  82526. * Returns the submesh BoudingInfo object
  82527. * @returns current bounding info (or mesh's one if the submesh is global)
  82528. */
  82529. getBoundingInfo(): BoundingInfo;
  82530. /**
  82531. * Sets the submesh BoundingInfo
  82532. * @param boundingInfo defines the new bounding info to use
  82533. * @returns the SubMesh
  82534. */
  82535. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82536. /**
  82537. * Returns the mesh of the current submesh
  82538. * @return the parent mesh
  82539. */
  82540. getMesh(): AbstractMesh;
  82541. /**
  82542. * Returns the rendering mesh of the submesh
  82543. * @returns the rendering mesh (could be different from parent mesh)
  82544. */
  82545. getRenderingMesh(): Mesh;
  82546. /**
  82547. * Returns the submesh material
  82548. * @returns null or the current material
  82549. */
  82550. getMaterial(): Nullable<Material>;
  82551. /**
  82552. * Sets a new updated BoundingInfo object to the submesh
  82553. * @param data defines an optional position array to use to determine the bounding info
  82554. * @returns the SubMesh
  82555. */
  82556. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  82557. /** @hidden */
  82558. _checkCollision(collider: Collider): boolean;
  82559. /**
  82560. * Updates the submesh BoundingInfo
  82561. * @param world defines the world matrix to use to update the bounding info
  82562. * @returns the submesh
  82563. */
  82564. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82565. /**
  82566. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82567. * @param frustumPlanes defines the frustum planes
  82568. * @returns true if the submesh is intersecting with the frustum
  82569. */
  82570. isInFrustum(frustumPlanes: Plane[]): boolean;
  82571. /**
  82572. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82573. * @param frustumPlanes defines the frustum planes
  82574. * @returns true if the submesh is inside the frustum
  82575. */
  82576. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82577. /**
  82578. * Renders the submesh
  82579. * @param enableAlphaMode defines if alpha needs to be used
  82580. * @returns the submesh
  82581. */
  82582. render(enableAlphaMode: boolean): SubMesh;
  82583. /**
  82584. * @hidden
  82585. */
  82586. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  82587. /**
  82588. * Checks if the submesh intersects with a ray
  82589. * @param ray defines the ray to test
  82590. * @returns true is the passed ray intersects the submesh bounding box
  82591. */
  82592. canIntersects(ray: Ray): boolean;
  82593. /**
  82594. * Intersects current submesh with a ray
  82595. * @param ray defines the ray to test
  82596. * @param positions defines mesh's positions array
  82597. * @param indices defines mesh's indices array
  82598. * @param fastCheck defines if only bounding info should be used
  82599. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82600. * @returns intersection info or null if no intersection
  82601. */
  82602. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82603. /** @hidden */
  82604. private _intersectLines;
  82605. /** @hidden */
  82606. private _intersectTriangles;
  82607. /** @hidden */
  82608. private _intersectUnIndexedTriangles;
  82609. /** @hidden */
  82610. _rebuild(): void;
  82611. /**
  82612. * Creates a new submesh from the passed mesh
  82613. * @param newMesh defines the new hosting mesh
  82614. * @param newRenderingMesh defines an optional rendering mesh
  82615. * @returns the new submesh
  82616. */
  82617. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82618. /**
  82619. * Release associated resources
  82620. */
  82621. dispose(): void;
  82622. /**
  82623. * Gets the class name
  82624. * @returns the string "SubMesh".
  82625. */
  82626. getClassName(): string;
  82627. /**
  82628. * Creates a new submesh from indices data
  82629. * @param materialIndex the index of the main mesh material
  82630. * @param startIndex the index where to start the copy in the mesh indices array
  82631. * @param indexCount the number of indices to copy then from the startIndex
  82632. * @param mesh the main mesh to create the submesh from
  82633. * @param renderingMesh the optional rendering mesh
  82634. * @returns a new submesh
  82635. */
  82636. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82637. }
  82638. }
  82639. declare module BABYLON {
  82640. /**
  82641. * Class used to store geometry data (vertex buffers + index buffer)
  82642. */
  82643. export class Geometry implements IGetSetVerticesData {
  82644. /**
  82645. * Gets or sets the ID of the geometry
  82646. */
  82647. id: string;
  82648. /**
  82649. * Gets or sets the unique ID of the geometry
  82650. */
  82651. uniqueId: number;
  82652. /**
  82653. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82654. */
  82655. delayLoadState: number;
  82656. /**
  82657. * Gets the file containing the data to load when running in delay load state
  82658. */
  82659. delayLoadingFile: Nullable<string>;
  82660. /**
  82661. * Callback called when the geometry is updated
  82662. */
  82663. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82664. private _scene;
  82665. private _engine;
  82666. private _meshes;
  82667. private _totalVertices;
  82668. /** @hidden */
  82669. _indices: IndicesArray;
  82670. /** @hidden */
  82671. _vertexBuffers: {
  82672. [key: string]: VertexBuffer;
  82673. };
  82674. private _isDisposed;
  82675. private _extend;
  82676. private _boundingBias;
  82677. /** @hidden */
  82678. _delayInfo: Array<string>;
  82679. private _indexBuffer;
  82680. private _indexBufferIsUpdatable;
  82681. /** @hidden */
  82682. _boundingInfo: Nullable<BoundingInfo>;
  82683. /** @hidden */
  82684. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82685. /** @hidden */
  82686. _softwareSkinningFrameId: number;
  82687. private _vertexArrayObjects;
  82688. private _updatable;
  82689. /** @hidden */
  82690. _positions: Nullable<Vector3[]>;
  82691. /**
  82692. * 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
  82693. */
  82694. /**
  82695. * 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
  82696. */
  82697. boundingBias: Vector2;
  82698. /**
  82699. * Static function used to attach a new empty geometry to a mesh
  82700. * @param mesh defines the mesh to attach the geometry to
  82701. * @returns the new Geometry
  82702. */
  82703. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82704. /**
  82705. * Creates a new geometry
  82706. * @param id defines the unique ID
  82707. * @param scene defines the hosting scene
  82708. * @param vertexData defines the VertexData used to get geometry data
  82709. * @param updatable defines if geometry must be updatable (false by default)
  82710. * @param mesh defines the mesh that will be associated with the geometry
  82711. */
  82712. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82713. /**
  82714. * Gets the current extend of the geometry
  82715. */
  82716. readonly extend: {
  82717. minimum: Vector3;
  82718. maximum: Vector3;
  82719. };
  82720. /**
  82721. * Gets the hosting scene
  82722. * @returns the hosting Scene
  82723. */
  82724. getScene(): Scene;
  82725. /**
  82726. * Gets the hosting engine
  82727. * @returns the hosting Engine
  82728. */
  82729. getEngine(): Engine;
  82730. /**
  82731. * Defines if the geometry is ready to use
  82732. * @returns true if the geometry is ready to be used
  82733. */
  82734. isReady(): boolean;
  82735. /**
  82736. * Gets a value indicating that the geometry should not be serialized
  82737. */
  82738. readonly doNotSerialize: boolean;
  82739. /** @hidden */
  82740. _rebuild(): void;
  82741. /**
  82742. * Affects all geometry data in one call
  82743. * @param vertexData defines the geometry data
  82744. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82745. */
  82746. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82747. /**
  82748. * Set specific vertex data
  82749. * @param kind defines the data kind (Position, normal, etc...)
  82750. * @param data defines the vertex data to use
  82751. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82752. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82753. */
  82754. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82755. /**
  82756. * Removes a specific vertex data
  82757. * @param kind defines the data kind (Position, normal, etc...)
  82758. */
  82759. removeVerticesData(kind: string): void;
  82760. /**
  82761. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82762. * @param buffer defines the vertex buffer to use
  82763. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82764. */
  82765. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82766. /**
  82767. * Update a specific vertex buffer
  82768. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  82769. * It will do nothing if the buffer is not updatable
  82770. * @param kind defines the data kind (Position, normal, etc...)
  82771. * @param data defines the data to use
  82772. * @param offset defines the offset in the target buffer where to store the data
  82773. * @param useBytes set to true if the offset is in bytes
  82774. */
  82775. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82776. /**
  82777. * Update a specific vertex buffer
  82778. * This function will create a new buffer if the current one is not updatable
  82779. * @param kind defines the data kind (Position, normal, etc...)
  82780. * @param data defines the data to use
  82781. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82782. */
  82783. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82784. private _updateBoundingInfo;
  82785. /** @hidden */
  82786. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  82787. /**
  82788. * Gets total number of vertices
  82789. * @returns the total number of vertices
  82790. */
  82791. getTotalVertices(): number;
  82792. /**
  82793. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82794. * @param kind defines the data kind (Position, normal, etc...)
  82795. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82796. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82797. * @returns a float array containing vertex data
  82798. */
  82799. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82800. /**
  82801. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82802. * @param kind defines the data kind (Position, normal, etc...)
  82803. * @returns true if the vertex buffer with the specified kind is updatable
  82804. */
  82805. isVertexBufferUpdatable(kind: string): boolean;
  82806. /**
  82807. * Gets a specific vertex buffer
  82808. * @param kind defines the data kind (Position, normal, etc...)
  82809. * @returns a VertexBuffer
  82810. */
  82811. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82812. /**
  82813. * Returns all vertex buffers
  82814. * @return an object holding all vertex buffers indexed by kind
  82815. */
  82816. getVertexBuffers(): Nullable<{
  82817. [key: string]: VertexBuffer;
  82818. }>;
  82819. /**
  82820. * Gets a boolean indicating if specific vertex buffer is present
  82821. * @param kind defines the data kind (Position, normal, etc...)
  82822. * @returns true if data is present
  82823. */
  82824. isVerticesDataPresent(kind: string): boolean;
  82825. /**
  82826. * Gets a list of all attached data kinds (Position, normal, etc...)
  82827. * @returns a list of string containing all kinds
  82828. */
  82829. getVerticesDataKinds(): string[];
  82830. /**
  82831. * Update index buffer
  82832. * @param indices defines the indices to store in the index buffer
  82833. * @param offset defines the offset in the target buffer where to store the data
  82834. * @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)
  82835. */
  82836. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82837. /**
  82838. * Creates a new index buffer
  82839. * @param indices defines the indices to store in the index buffer
  82840. * @param totalVertices defines the total number of vertices (could be null)
  82841. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82842. */
  82843. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82844. /**
  82845. * Return the total number of indices
  82846. * @returns the total number of indices
  82847. */
  82848. getTotalIndices(): number;
  82849. /**
  82850. * Gets the index buffer array
  82851. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82852. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82853. * @returns the index buffer array
  82854. */
  82855. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82856. /**
  82857. * Gets the index buffer
  82858. * @return the index buffer
  82859. */
  82860. getIndexBuffer(): Nullable<DataBuffer>;
  82861. /** @hidden */
  82862. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82863. /**
  82864. * Release the associated resources for a specific mesh
  82865. * @param mesh defines the source mesh
  82866. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82867. */
  82868. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82869. /**
  82870. * Apply current geometry to a given mesh
  82871. * @param mesh defines the mesh to apply geometry to
  82872. */
  82873. applyToMesh(mesh: Mesh): void;
  82874. private _updateExtend;
  82875. private _applyToMesh;
  82876. private notifyUpdate;
  82877. /**
  82878. * Load the geometry if it was flagged as delay loaded
  82879. * @param scene defines the hosting scene
  82880. * @param onLoaded defines a callback called when the geometry is loaded
  82881. */
  82882. load(scene: Scene, onLoaded?: () => void): void;
  82883. private _queueLoad;
  82884. /**
  82885. * Invert the geometry to move from a right handed system to a left handed one.
  82886. */
  82887. toLeftHanded(): void;
  82888. /** @hidden */
  82889. _resetPointsArrayCache(): void;
  82890. /** @hidden */
  82891. _generatePointsArray(): boolean;
  82892. /**
  82893. * Gets a value indicating if the geometry is disposed
  82894. * @returns true if the geometry was disposed
  82895. */
  82896. isDisposed(): boolean;
  82897. private _disposeVertexArrayObjects;
  82898. /**
  82899. * Free all associated resources
  82900. */
  82901. dispose(): void;
  82902. /**
  82903. * Clone the current geometry into a new geometry
  82904. * @param id defines the unique ID of the new geometry
  82905. * @returns a new geometry object
  82906. */
  82907. copy(id: string): Geometry;
  82908. /**
  82909. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82910. * @return a JSON representation of the current geometry data (without the vertices data)
  82911. */
  82912. serialize(): any;
  82913. private toNumberArray;
  82914. /**
  82915. * Serialize all vertices data into a JSON oject
  82916. * @returns a JSON representation of the current geometry data
  82917. */
  82918. serializeVerticeData(): any;
  82919. /**
  82920. * Extracts a clone of a mesh geometry
  82921. * @param mesh defines the source mesh
  82922. * @param id defines the unique ID of the new geometry object
  82923. * @returns the new geometry object
  82924. */
  82925. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82926. /**
  82927. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82928. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82929. * Be aware Math.random() could cause collisions, but:
  82930. * "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"
  82931. * @returns a string containing a new GUID
  82932. */
  82933. static RandomId(): string;
  82934. /** @hidden */
  82935. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82936. private static _CleanMatricesWeights;
  82937. /**
  82938. * Create a new geometry from persisted data (Using .babylon file format)
  82939. * @param parsedVertexData defines the persisted data
  82940. * @param scene defines the hosting scene
  82941. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82942. * @returns the new geometry object
  82943. */
  82944. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82945. }
  82946. }
  82947. declare module BABYLON {
  82948. /**
  82949. * Define an interface for all classes that will get and set the data on vertices
  82950. */
  82951. export interface IGetSetVerticesData {
  82952. /**
  82953. * Gets a boolean indicating if specific vertex data is present
  82954. * @param kind defines the vertex data kind to use
  82955. * @returns true is data kind is present
  82956. */
  82957. isVerticesDataPresent(kind: string): boolean;
  82958. /**
  82959. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82960. * @param kind defines the data kind (Position, normal, etc...)
  82961. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82962. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82963. * @returns a float array containing vertex data
  82964. */
  82965. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82966. /**
  82967. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82968. * @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.
  82969. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82970. * @returns the indices array or an empty array if the mesh has no geometry
  82971. */
  82972. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82973. /**
  82974. * Set specific vertex data
  82975. * @param kind defines the data kind (Position, normal, etc...)
  82976. * @param data defines the vertex data to use
  82977. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82978. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82979. */
  82980. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82981. /**
  82982. * Update a specific associated vertex buffer
  82983. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82984. * - VertexBuffer.PositionKind
  82985. * - VertexBuffer.UVKind
  82986. * - VertexBuffer.UV2Kind
  82987. * - VertexBuffer.UV3Kind
  82988. * - VertexBuffer.UV4Kind
  82989. * - VertexBuffer.UV5Kind
  82990. * - VertexBuffer.UV6Kind
  82991. * - VertexBuffer.ColorKind
  82992. * - VertexBuffer.MatricesIndicesKind
  82993. * - VertexBuffer.MatricesIndicesExtraKind
  82994. * - VertexBuffer.MatricesWeightsKind
  82995. * - VertexBuffer.MatricesWeightsExtraKind
  82996. * @param data defines the data source
  82997. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  82998. * @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)
  82999. */
  83000. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  83001. /**
  83002. * Creates a new index buffer
  83003. * @param indices defines the indices to store in the index buffer
  83004. * @param totalVertices defines the total number of vertices (could be null)
  83005. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  83006. */
  83007. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  83008. }
  83009. /**
  83010. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  83011. */
  83012. export class VertexData {
  83013. /**
  83014. * Mesh side orientation : usually the external or front surface
  83015. */
  83016. static readonly FRONTSIDE: number;
  83017. /**
  83018. * Mesh side orientation : usually the internal or back surface
  83019. */
  83020. static readonly BACKSIDE: number;
  83021. /**
  83022. * Mesh side orientation : both internal and external or front and back surfaces
  83023. */
  83024. static readonly DOUBLESIDE: number;
  83025. /**
  83026. * Mesh side orientation : by default, `FRONTSIDE`
  83027. */
  83028. static readonly DEFAULTSIDE: number;
  83029. /**
  83030. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  83031. */
  83032. positions: Nullable<FloatArray>;
  83033. /**
  83034. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  83035. */
  83036. normals: Nullable<FloatArray>;
  83037. /**
  83038. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  83039. */
  83040. tangents: Nullable<FloatArray>;
  83041. /**
  83042. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83043. */
  83044. uvs: Nullable<FloatArray>;
  83045. /**
  83046. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83047. */
  83048. uvs2: Nullable<FloatArray>;
  83049. /**
  83050. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83051. */
  83052. uvs3: Nullable<FloatArray>;
  83053. /**
  83054. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83055. */
  83056. uvs4: Nullable<FloatArray>;
  83057. /**
  83058. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83059. */
  83060. uvs5: Nullable<FloatArray>;
  83061. /**
  83062. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83063. */
  83064. uvs6: Nullable<FloatArray>;
  83065. /**
  83066. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  83067. */
  83068. colors: Nullable<FloatArray>;
  83069. /**
  83070. * 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).
  83071. */
  83072. matricesIndices: Nullable<FloatArray>;
  83073. /**
  83074. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  83075. */
  83076. matricesWeights: Nullable<FloatArray>;
  83077. /**
  83078. * An array extending the number of possible indices
  83079. */
  83080. matricesIndicesExtra: Nullable<FloatArray>;
  83081. /**
  83082. * An array extending the number of possible weights when the number of indices is extended
  83083. */
  83084. matricesWeightsExtra: Nullable<FloatArray>;
  83085. /**
  83086. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  83087. */
  83088. indices: Nullable<IndicesArray>;
  83089. /**
  83090. * Uses the passed data array to set the set the values for the specified kind of data
  83091. * @param data a linear array of floating numbers
  83092. * @param kind the type of data that is being set, eg positions, colors etc
  83093. */
  83094. set(data: FloatArray, kind: string): void;
  83095. /**
  83096. * Associates the vertexData to the passed Mesh.
  83097. * Sets it as updatable or not (default `false`)
  83098. * @param mesh the mesh the vertexData is applied to
  83099. * @param updatable when used and having the value true allows new data to update the vertexData
  83100. * @returns the VertexData
  83101. */
  83102. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  83103. /**
  83104. * Associates the vertexData to the passed Geometry.
  83105. * Sets it as updatable or not (default `false`)
  83106. * @param geometry the geometry the vertexData is applied to
  83107. * @param updatable when used and having the value true allows new data to update the vertexData
  83108. * @returns VertexData
  83109. */
  83110. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  83111. /**
  83112. * Updates the associated mesh
  83113. * @param mesh the mesh to be updated
  83114. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83115. * @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
  83116. * @returns VertexData
  83117. */
  83118. updateMesh(mesh: Mesh): VertexData;
  83119. /**
  83120. * Updates the associated geometry
  83121. * @param geometry the geometry to be updated
  83122. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83123. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  83124. * @returns VertexData.
  83125. */
  83126. updateGeometry(geometry: Geometry): VertexData;
  83127. private _applyTo;
  83128. private _update;
  83129. /**
  83130. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83131. * @param matrix the transforming matrix
  83132. * @returns the VertexData
  83133. */
  83134. transform(matrix: Matrix): VertexData;
  83135. /**
  83136. * Merges the passed VertexData into the current one
  83137. * @param other the VertexData to be merged into the current one
  83138. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83139. * @returns the modified VertexData
  83140. */
  83141. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  83142. private _mergeElement;
  83143. private _validate;
  83144. /**
  83145. * Serializes the VertexData
  83146. * @returns a serialized object
  83147. */
  83148. serialize(): any;
  83149. /**
  83150. * Extracts the vertexData from a mesh
  83151. * @param mesh the mesh from which to extract the VertexData
  83152. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83153. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83154. * @returns the object VertexData associated to the passed mesh
  83155. */
  83156. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83157. /**
  83158. * Extracts the vertexData from the geometry
  83159. * @param geometry the geometry from which to extract the VertexData
  83160. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  83161. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83162. * @returns the object VertexData associated to the passed mesh
  83163. */
  83164. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83165. private static _ExtractFrom;
  83166. /**
  83167. * Creates the VertexData for a Ribbon
  83168. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83169. * * pathArray array of paths, each of which an array of successive Vector3
  83170. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83171. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83172. * * 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
  83173. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83174. * * 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)
  83175. * * 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)
  83176. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83177. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83178. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83179. * @returns the VertexData of the ribbon
  83180. */
  83181. static CreateRibbon(options: {
  83182. pathArray: Vector3[][];
  83183. closeArray?: boolean;
  83184. closePath?: boolean;
  83185. offset?: number;
  83186. sideOrientation?: number;
  83187. frontUVs?: Vector4;
  83188. backUVs?: Vector4;
  83189. invertUV?: boolean;
  83190. uvs?: Vector2[];
  83191. colors?: Color4[];
  83192. }): VertexData;
  83193. /**
  83194. * Creates the VertexData for a box
  83195. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83196. * * size sets the width, height and depth of the box to the value of size, optional default 1
  83197. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  83198. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  83199. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  83200. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  83201. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  83202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83203. * * 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)
  83204. * * 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)
  83205. * @returns the VertexData of the box
  83206. */
  83207. static CreateBox(options: {
  83208. size?: number;
  83209. width?: number;
  83210. height?: number;
  83211. depth?: number;
  83212. faceUV?: Vector4[];
  83213. faceColors?: Color4[];
  83214. sideOrientation?: number;
  83215. frontUVs?: Vector4;
  83216. backUVs?: Vector4;
  83217. }): VertexData;
  83218. /**
  83219. * Creates the VertexData for an ellipsoid, defaults to a sphere
  83220. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83221. * * segments sets the number of horizontal strips optional, default 32
  83222. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  83223. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  83224. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  83225. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  83226. * * 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
  83227. * * 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
  83228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83229. * * 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)
  83230. * * 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)
  83231. * @returns the VertexData of the ellipsoid
  83232. */
  83233. static CreateSphere(options: {
  83234. segments?: number;
  83235. diameter?: number;
  83236. diameterX?: number;
  83237. diameterY?: number;
  83238. diameterZ?: number;
  83239. arc?: number;
  83240. slice?: number;
  83241. sideOrientation?: number;
  83242. frontUVs?: Vector4;
  83243. backUVs?: Vector4;
  83244. }): VertexData;
  83245. /**
  83246. * Creates the VertexData for a cylinder, cone or prism
  83247. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83248. * * height sets the height (y direction) of the cylinder, optional, default 2
  83249. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  83250. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  83251. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  83252. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83253. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  83254. * * 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
  83255. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83256. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83257. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  83258. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  83259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83260. * * 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)
  83261. * * 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)
  83262. * @returns the VertexData of the cylinder, cone or prism
  83263. */
  83264. static CreateCylinder(options: {
  83265. height?: number;
  83266. diameterTop?: number;
  83267. diameterBottom?: number;
  83268. diameter?: number;
  83269. tessellation?: number;
  83270. subdivisions?: number;
  83271. arc?: number;
  83272. faceColors?: Color4[];
  83273. faceUV?: Vector4[];
  83274. hasRings?: boolean;
  83275. enclose?: boolean;
  83276. sideOrientation?: number;
  83277. frontUVs?: Vector4;
  83278. backUVs?: Vector4;
  83279. }): VertexData;
  83280. /**
  83281. * Creates the VertexData for a torus
  83282. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83283. * * diameter the diameter of the torus, optional default 1
  83284. * * thickness the diameter of the tube forming the torus, optional default 0.5
  83285. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83286. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83287. * * 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)
  83288. * * 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)
  83289. * @returns the VertexData of the torus
  83290. */
  83291. static CreateTorus(options: {
  83292. diameter?: number;
  83293. thickness?: number;
  83294. tessellation?: number;
  83295. sideOrientation?: number;
  83296. frontUVs?: Vector4;
  83297. backUVs?: Vector4;
  83298. }): VertexData;
  83299. /**
  83300. * Creates the VertexData of the LineSystem
  83301. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  83302. * - lines an array of lines, each line being an array of successive Vector3
  83303. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  83304. * @returns the VertexData of the LineSystem
  83305. */
  83306. static CreateLineSystem(options: {
  83307. lines: Vector3[][];
  83308. colors?: Nullable<Color4[][]>;
  83309. }): VertexData;
  83310. /**
  83311. * Create the VertexData for a DashedLines
  83312. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  83313. * - points an array successive Vector3
  83314. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  83315. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  83316. * - dashNb the intended total number of dashes, optional, default 200
  83317. * @returns the VertexData for the DashedLines
  83318. */
  83319. static CreateDashedLines(options: {
  83320. points: Vector3[];
  83321. dashSize?: number;
  83322. gapSize?: number;
  83323. dashNb?: number;
  83324. }): VertexData;
  83325. /**
  83326. * Creates the VertexData for a Ground
  83327. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83328. * - width the width (x direction) of the ground, optional, default 1
  83329. * - height the height (z direction) of the ground, optional, default 1
  83330. * - subdivisions the number of subdivisions per side, optional, default 1
  83331. * @returns the VertexData of the Ground
  83332. */
  83333. static CreateGround(options: {
  83334. width?: number;
  83335. height?: number;
  83336. subdivisions?: number;
  83337. subdivisionsX?: number;
  83338. subdivisionsY?: number;
  83339. }): VertexData;
  83340. /**
  83341. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  83342. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83343. * * xmin the ground minimum X coordinate, optional, default -1
  83344. * * zmin the ground minimum Z coordinate, optional, default -1
  83345. * * xmax the ground maximum X coordinate, optional, default 1
  83346. * * zmax the ground maximum Z coordinate, optional, default 1
  83347. * * 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}
  83348. * * 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}
  83349. * @returns the VertexData of the TiledGround
  83350. */
  83351. static CreateTiledGround(options: {
  83352. xmin: number;
  83353. zmin: number;
  83354. xmax: number;
  83355. zmax: number;
  83356. subdivisions?: {
  83357. w: number;
  83358. h: number;
  83359. };
  83360. precision?: {
  83361. w: number;
  83362. h: number;
  83363. };
  83364. }): VertexData;
  83365. /**
  83366. * Creates the VertexData of the Ground designed from a heightmap
  83367. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  83368. * * width the width (x direction) of the ground
  83369. * * height the height (z direction) of the ground
  83370. * * subdivisions the number of subdivisions per side
  83371. * * minHeight the minimum altitude on the ground, optional, default 0
  83372. * * maxHeight the maximum altitude on the ground, optional default 1
  83373. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  83374. * * buffer the array holding the image color data
  83375. * * bufferWidth the width of image
  83376. * * bufferHeight the height of image
  83377. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  83378. * @returns the VertexData of the Ground designed from a heightmap
  83379. */
  83380. static CreateGroundFromHeightMap(options: {
  83381. width: number;
  83382. height: number;
  83383. subdivisions: number;
  83384. minHeight: number;
  83385. maxHeight: number;
  83386. colorFilter: Color3;
  83387. buffer: Uint8Array;
  83388. bufferWidth: number;
  83389. bufferHeight: number;
  83390. alphaFilter: number;
  83391. }): VertexData;
  83392. /**
  83393. * Creates the VertexData for a Plane
  83394. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  83395. * * size sets the width and height of the plane to the value of size, optional default 1
  83396. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  83397. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  83398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83399. * * 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)
  83400. * * 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)
  83401. * @returns the VertexData of the box
  83402. */
  83403. static CreatePlane(options: {
  83404. size?: number;
  83405. width?: number;
  83406. height?: number;
  83407. sideOrientation?: number;
  83408. frontUVs?: Vector4;
  83409. backUVs?: Vector4;
  83410. }): VertexData;
  83411. /**
  83412. * Creates the VertexData of the Disc or regular Polygon
  83413. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  83414. * * radius the radius of the disc, optional default 0.5
  83415. * * tessellation the number of polygon sides, optional, default 64
  83416. * * 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
  83417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83418. * * 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)
  83419. * * 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)
  83420. * @returns the VertexData of the box
  83421. */
  83422. static CreateDisc(options: {
  83423. radius?: number;
  83424. tessellation?: number;
  83425. arc?: number;
  83426. sideOrientation?: number;
  83427. frontUVs?: Vector4;
  83428. backUVs?: Vector4;
  83429. }): VertexData;
  83430. /**
  83431. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83432. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83433. * @param polygon a mesh built from polygonTriangulation.build()
  83434. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83435. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83436. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83437. * @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)
  83438. * @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)
  83439. * @returns the VertexData of the Polygon
  83440. */
  83441. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83442. /**
  83443. * Creates the VertexData of the IcoSphere
  83444. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83445. * * radius the radius of the IcoSphere, optional default 1
  83446. * * radiusX allows stretching in the x direction, optional, default radius
  83447. * * radiusY allows stretching in the y direction, optional, default radius
  83448. * * radiusZ allows stretching in the z direction, optional, default radius
  83449. * * flat when true creates a flat shaded mesh, optional, default true
  83450. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83451. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83452. * * 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)
  83453. * * 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)
  83454. * @returns the VertexData of the IcoSphere
  83455. */
  83456. static CreateIcoSphere(options: {
  83457. radius?: number;
  83458. radiusX?: number;
  83459. radiusY?: number;
  83460. radiusZ?: number;
  83461. flat?: boolean;
  83462. subdivisions?: number;
  83463. sideOrientation?: number;
  83464. frontUVs?: Vector4;
  83465. backUVs?: Vector4;
  83466. }): VertexData;
  83467. /**
  83468. * Creates the VertexData for a Polyhedron
  83469. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83470. * * type provided types are:
  83471. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83472. * * 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)
  83473. * * size the size of the IcoSphere, optional default 1
  83474. * * sizeX allows stretching in the x direction, optional, default size
  83475. * * sizeY allows stretching in the y direction, optional, default size
  83476. * * sizeZ allows stretching in the z direction, optional, default size
  83477. * * 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
  83478. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83479. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83480. * * flat when true creates a flat shaded mesh, optional, default true
  83481. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83483. * * 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)
  83484. * * 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)
  83485. * @returns the VertexData of the Polyhedron
  83486. */
  83487. static CreatePolyhedron(options: {
  83488. type?: number;
  83489. size?: number;
  83490. sizeX?: number;
  83491. sizeY?: number;
  83492. sizeZ?: number;
  83493. custom?: any;
  83494. faceUV?: Vector4[];
  83495. faceColors?: Color4[];
  83496. flat?: boolean;
  83497. sideOrientation?: number;
  83498. frontUVs?: Vector4;
  83499. backUVs?: Vector4;
  83500. }): VertexData;
  83501. /**
  83502. * Creates the VertexData for a TorusKnot
  83503. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83504. * * radius the radius of the torus knot, optional, default 2
  83505. * * tube the thickness of the tube, optional, default 0.5
  83506. * * radialSegments the number of sides on each tube segments, optional, default 32
  83507. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83508. * * p the number of windings around the z axis, optional, default 2
  83509. * * q the number of windings around the x axis, optional, default 3
  83510. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83511. * * 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)
  83512. * * 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)
  83513. * @returns the VertexData of the Torus Knot
  83514. */
  83515. static CreateTorusKnot(options: {
  83516. radius?: number;
  83517. tube?: number;
  83518. radialSegments?: number;
  83519. tubularSegments?: number;
  83520. p?: number;
  83521. q?: number;
  83522. sideOrientation?: number;
  83523. frontUVs?: Vector4;
  83524. backUVs?: Vector4;
  83525. }): VertexData;
  83526. /**
  83527. * Compute normals for given positions and indices
  83528. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83529. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83530. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83531. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83532. * * facetNormals : optional array of facet normals (vector3)
  83533. * * facetPositions : optional array of facet positions (vector3)
  83534. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83535. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83536. * * bInfo : optional bounding info, required for facetPartitioning computation
  83537. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83538. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83539. * * useRightHandedSystem: optional boolean to for right handed system computation
  83540. * * depthSort : optional boolean to enable the facet depth sort computation
  83541. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83542. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83543. */
  83544. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83545. facetNormals?: any;
  83546. facetPositions?: any;
  83547. facetPartitioning?: any;
  83548. ratio?: number;
  83549. bInfo?: any;
  83550. bbSize?: Vector3;
  83551. subDiv?: any;
  83552. useRightHandedSystem?: boolean;
  83553. depthSort?: boolean;
  83554. distanceTo?: Vector3;
  83555. depthSortedFacets?: any;
  83556. }): void;
  83557. /** @hidden */
  83558. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83559. /**
  83560. * Applies VertexData created from the imported parameters to the geometry
  83561. * @param parsedVertexData the parsed data from an imported file
  83562. * @param geometry the geometry to apply the VertexData to
  83563. */
  83564. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83565. }
  83566. }
  83567. declare module BABYLON {
  83568. /**
  83569. * Class containing static functions to help procedurally build meshes
  83570. */
  83571. export class DiscBuilder {
  83572. /**
  83573. * Creates a plane polygonal mesh. By default, this is a disc
  83574. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83575. * * 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
  83576. * * 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
  83577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83580. * @param name defines the name of the mesh
  83581. * @param options defines the options used to create the mesh
  83582. * @param scene defines the hosting scene
  83583. * @returns the plane polygonal mesh
  83584. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83585. */
  83586. static CreateDisc(name: string, options: {
  83587. radius?: number;
  83588. tessellation?: number;
  83589. arc?: number;
  83590. updatable?: boolean;
  83591. sideOrientation?: number;
  83592. frontUVs?: Vector4;
  83593. backUVs?: Vector4;
  83594. }, scene?: Nullable<Scene>): Mesh;
  83595. }
  83596. }
  83597. declare module BABYLON {
  83598. /**
  83599. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83600. *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.
  83601. * The SPS is also a particle system. It provides some methods to manage the particles.
  83602. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83603. *
  83604. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83605. */
  83606. export class SolidParticleSystem implements IDisposable {
  83607. /**
  83608. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83609. * Example : var p = SPS.particles[i];
  83610. */
  83611. particles: SolidParticle[];
  83612. /**
  83613. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83614. */
  83615. nbParticles: number;
  83616. /**
  83617. * If the particles must ever face the camera (default false). Useful for planar particles.
  83618. */
  83619. billboard: boolean;
  83620. /**
  83621. * Recompute normals when adding a shape
  83622. */
  83623. recomputeNormals: boolean;
  83624. /**
  83625. * This a counter ofr your own usage. It's not set by any SPS functions.
  83626. */
  83627. counter: number;
  83628. /**
  83629. * The SPS name. This name is also given to the underlying mesh.
  83630. */
  83631. name: string;
  83632. /**
  83633. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83634. */
  83635. mesh: Mesh;
  83636. /**
  83637. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83638. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83639. */
  83640. vars: any;
  83641. /**
  83642. * This array is populated when the SPS is set as 'pickable'.
  83643. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83644. * Each element of this array is an object `{idx: int, faceId: int}`.
  83645. * `idx` is the picked particle index in the `SPS.particles` array
  83646. * `faceId` is the picked face index counted within this particle.
  83647. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83648. */
  83649. pickedParticles: {
  83650. idx: number;
  83651. faceId: number;
  83652. }[];
  83653. /**
  83654. * This array is populated when `enableDepthSort` is set to true.
  83655. * Each element of this array is an instance of the class DepthSortedParticle.
  83656. */
  83657. depthSortedParticles: DepthSortedParticle[];
  83658. /**
  83659. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83660. * @hidden
  83661. */
  83662. _bSphereOnly: boolean;
  83663. /**
  83664. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83665. * @hidden
  83666. */
  83667. _bSphereRadiusFactor: number;
  83668. private _scene;
  83669. private _positions;
  83670. private _indices;
  83671. private _normals;
  83672. private _colors;
  83673. private _uvs;
  83674. private _indices32;
  83675. private _positions32;
  83676. private _normals32;
  83677. private _fixedNormal32;
  83678. private _colors32;
  83679. private _uvs32;
  83680. private _index;
  83681. private _updatable;
  83682. private _pickable;
  83683. private _isVisibilityBoxLocked;
  83684. private _alwaysVisible;
  83685. private _depthSort;
  83686. private _shapeCounter;
  83687. private _copy;
  83688. private _color;
  83689. private _computeParticleColor;
  83690. private _computeParticleTexture;
  83691. private _computeParticleRotation;
  83692. private _computeParticleVertex;
  83693. private _computeBoundingBox;
  83694. private _depthSortParticles;
  83695. private _camera;
  83696. private _mustUnrotateFixedNormals;
  83697. private _particlesIntersect;
  83698. private _needs32Bits;
  83699. /**
  83700. * Creates a SPS (Solid Particle System) object.
  83701. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83702. * @param scene (Scene) is the scene in which the SPS is added.
  83703. * @param options defines the options of the sps e.g.
  83704. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83705. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83706. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83707. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83708. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83709. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83710. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83711. */
  83712. constructor(name: string, scene: Scene, options?: {
  83713. updatable?: boolean;
  83714. isPickable?: boolean;
  83715. enableDepthSort?: boolean;
  83716. particleIntersection?: boolean;
  83717. boundingSphereOnly?: boolean;
  83718. bSphereRadiusFactor?: number;
  83719. });
  83720. /**
  83721. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83722. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83723. * @returns the created mesh
  83724. */
  83725. buildMesh(): Mesh;
  83726. /**
  83727. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83728. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83729. * Thus the particles generated from `digest()` have their property `position` set yet.
  83730. * @param mesh ( Mesh ) is the mesh to be digested
  83731. * @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
  83732. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83733. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83734. * @returns the current SPS
  83735. */
  83736. digest(mesh: Mesh, options?: {
  83737. facetNb?: number;
  83738. number?: number;
  83739. delta?: number;
  83740. }): SolidParticleSystem;
  83741. private _unrotateFixedNormals;
  83742. private _resetCopy;
  83743. private _meshBuilder;
  83744. private _posToShape;
  83745. private _uvsToShapeUV;
  83746. private _addParticle;
  83747. /**
  83748. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83749. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83750. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83751. * @param nb (positive integer) the number of particles to be created from this model
  83752. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83753. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83754. * @returns the number of shapes in the system
  83755. */
  83756. addShape(mesh: Mesh, nb: number, options?: {
  83757. positionFunction?: any;
  83758. vertexFunction?: any;
  83759. }): number;
  83760. private _rebuildParticle;
  83761. /**
  83762. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83763. * @returns the SPS.
  83764. */
  83765. rebuildMesh(): SolidParticleSystem;
  83766. /**
  83767. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83768. * This method calls `updateParticle()` for each particle of the SPS.
  83769. * For an animated SPS, it is usually called within the render loop.
  83770. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83771. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83772. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83773. * @returns the SPS.
  83774. */
  83775. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83776. /**
  83777. * Disposes the SPS.
  83778. */
  83779. dispose(): void;
  83780. /**
  83781. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83782. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83783. * @returns the SPS.
  83784. */
  83785. refreshVisibleSize(): SolidParticleSystem;
  83786. /**
  83787. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83788. * @param size the size (float) of the visibility box
  83789. * note : this doesn't lock the SPS mesh bounding box.
  83790. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83791. */
  83792. setVisibilityBox(size: number): void;
  83793. /**
  83794. * Gets whether the SPS as always visible or not
  83795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83796. */
  83797. /**
  83798. * Sets the SPS as always visible or not
  83799. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83800. */
  83801. isAlwaysVisible: boolean;
  83802. /**
  83803. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83804. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83805. */
  83806. /**
  83807. * Gets if 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. isVisibilityBoxLocked: boolean;
  83811. /**
  83812. * Tells to `setParticles()` to compute the particle rotations or not.
  83813. * Default value : true. The SPS is faster when it's set to false.
  83814. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83815. */
  83816. /**
  83817. * Gets if `setParticles()` computes the particle rotations or not.
  83818. * Default value : true. The SPS is faster when it's set to false.
  83819. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83820. */
  83821. computeParticleRotation: boolean;
  83822. /**
  83823. * Tells to `setParticles()` to compute the particle colors or not.
  83824. * Default value : true. The SPS is faster when it's set to false.
  83825. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83826. */
  83827. /**
  83828. * Gets if `setParticles()` computes the particle colors or not.
  83829. * Default value : true. The SPS is faster when it's set to false.
  83830. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83831. */
  83832. computeParticleColor: boolean;
  83833. /**
  83834. * Gets if `setParticles()` computes the particle textures or not.
  83835. * Default value : true. The SPS is faster when it's set to false.
  83836. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83837. */
  83838. computeParticleTexture: boolean;
  83839. /**
  83840. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83841. * Default value : false. The SPS is faster when it's set to false.
  83842. * Note : the particle custom vertex positions aren't stored values.
  83843. */
  83844. /**
  83845. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83846. * Default value : false. The SPS is faster when it's set to false.
  83847. * Note : the particle custom vertex positions aren't stored values.
  83848. */
  83849. computeParticleVertex: boolean;
  83850. /**
  83851. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83852. */
  83853. /**
  83854. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83855. */
  83856. computeBoundingBox: boolean;
  83857. /**
  83858. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83859. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83860. * Default : `true`
  83861. */
  83862. /**
  83863. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83864. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83865. * Default : `true`
  83866. */
  83867. depthSortParticles: boolean;
  83868. /**
  83869. * This function does nothing. It may be overwritten to set all the particle first values.
  83870. * The SPS doesn't call this function, you may have to call it by your own.
  83871. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83872. */
  83873. initParticles(): void;
  83874. /**
  83875. * This function does nothing. It may be overwritten to recycle a particle.
  83876. * The SPS doesn't call this function, you may have to call it by your own.
  83877. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83878. * @param particle The particle to recycle
  83879. * @returns the recycled particle
  83880. */
  83881. recycleParticle(particle: SolidParticle): SolidParticle;
  83882. /**
  83883. * Updates a particle : this function should be overwritten by the user.
  83884. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83885. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83886. * @example : just set a particle position or velocity and recycle conditions
  83887. * @param particle The particle to update
  83888. * @returns the updated particle
  83889. */
  83890. updateParticle(particle: SolidParticle): SolidParticle;
  83891. /**
  83892. * Updates a vertex of a particle : it can be overwritten by the user.
  83893. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83894. * @param particle the current particle
  83895. * @param vertex the current index of the current particle
  83896. * @param pt the index of the current vertex in the particle shape
  83897. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83898. * @example : just set a vertex particle position
  83899. * @returns the updated vertex
  83900. */
  83901. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83902. /**
  83903. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83904. * This does nothing and may be overwritten by the user.
  83905. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83906. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83907. * @param update the boolean update value actually passed to setParticles()
  83908. */
  83909. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83910. /**
  83911. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83912. * This will be passed three parameters.
  83913. * This does nothing and may be overwritten by the user.
  83914. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83915. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83916. * @param update the boolean update value actually passed to setParticles()
  83917. */
  83918. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83919. }
  83920. }
  83921. declare module BABYLON {
  83922. /**
  83923. * Represents one particle of a solid particle system.
  83924. */
  83925. export class SolidParticle {
  83926. /**
  83927. * particle global index
  83928. */
  83929. idx: number;
  83930. /**
  83931. * The color of the particle
  83932. */
  83933. color: Nullable<Color4>;
  83934. /**
  83935. * The world space position of the particle.
  83936. */
  83937. position: Vector3;
  83938. /**
  83939. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83940. */
  83941. rotation: Vector3;
  83942. /**
  83943. * The world space rotation quaternion of the particle.
  83944. */
  83945. rotationQuaternion: Nullable<Quaternion>;
  83946. /**
  83947. * The scaling of the particle.
  83948. */
  83949. scaling: Vector3;
  83950. /**
  83951. * The uvs of the particle.
  83952. */
  83953. uvs: Vector4;
  83954. /**
  83955. * The current speed of the particle.
  83956. */
  83957. velocity: Vector3;
  83958. /**
  83959. * The pivot point in the particle local space.
  83960. */
  83961. pivot: Vector3;
  83962. /**
  83963. * Must the particle be translated from its pivot point in its local space ?
  83964. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83965. * Default : false
  83966. */
  83967. translateFromPivot: boolean;
  83968. /**
  83969. * Is the particle active or not ?
  83970. */
  83971. alive: boolean;
  83972. /**
  83973. * Is the particle visible or not ?
  83974. */
  83975. isVisible: boolean;
  83976. /**
  83977. * Index of this particle in the global "positions" array (Internal use)
  83978. * @hidden
  83979. */
  83980. _pos: number;
  83981. /**
  83982. * @hidden Index of this particle in the global "indices" array (Internal use)
  83983. */
  83984. _ind: number;
  83985. /**
  83986. * @hidden ModelShape of this particle (Internal use)
  83987. */
  83988. _model: ModelShape;
  83989. /**
  83990. * ModelShape id of this particle
  83991. */
  83992. shapeId: number;
  83993. /**
  83994. * Index of the particle in its shape id (Internal use)
  83995. */
  83996. idxInShape: number;
  83997. /**
  83998. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  83999. */
  84000. _modelBoundingInfo: BoundingInfo;
  84001. /**
  84002. * @hidden Particle BoundingInfo object (Internal use)
  84003. */
  84004. _boundingInfo: BoundingInfo;
  84005. /**
  84006. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  84007. */
  84008. _sps: SolidParticleSystem;
  84009. /**
  84010. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  84011. */
  84012. _stillInvisible: boolean;
  84013. /**
  84014. * @hidden Last computed particle rotation matrix
  84015. */
  84016. _rotationMatrix: number[];
  84017. /**
  84018. * Parent particle Id, if any.
  84019. * Default null.
  84020. */
  84021. parentId: Nullable<number>;
  84022. /**
  84023. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  84024. * The possible values are :
  84025. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84026. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84027. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84028. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84029. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84030. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  84031. * */
  84032. cullingStrategy: number;
  84033. /**
  84034. * @hidden Internal global position in the SPS.
  84035. */
  84036. _globalPosition: Vector3;
  84037. /**
  84038. * Creates a Solid Particle object.
  84039. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  84040. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  84041. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  84042. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  84043. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  84044. * @param shapeId (integer) is the model shape identifier in the SPS.
  84045. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  84046. * @param sps defines the sps it is associated to
  84047. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  84048. */
  84049. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  84050. /**
  84051. * Legacy support, changed scale to scaling
  84052. */
  84053. /**
  84054. * Legacy support, changed scale to scaling
  84055. */
  84056. scale: Vector3;
  84057. /**
  84058. * Legacy support, changed quaternion to rotationQuaternion
  84059. */
  84060. /**
  84061. * Legacy support, changed quaternion to rotationQuaternion
  84062. */
  84063. quaternion: Nullable<Quaternion>;
  84064. /**
  84065. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  84066. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  84067. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  84068. * @returns true if it intersects
  84069. */
  84070. intersectsMesh(target: Mesh | SolidParticle): boolean;
  84071. /**
  84072. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  84073. * A particle is in the frustum if its bounding box intersects the frustum
  84074. * @param frustumPlanes defines the frustum to test
  84075. * @returns true if the particle is in the frustum planes
  84076. */
  84077. isInFrustum(frustumPlanes: Plane[]): boolean;
  84078. /**
  84079. * get the rotation matrix of the particle
  84080. * @hidden
  84081. */
  84082. getRotationMatrix(m: Matrix): void;
  84083. }
  84084. /**
  84085. * Represents the shape of the model used by one particle of a solid particle system.
  84086. * SPS internal tool, don't use it manually.
  84087. */
  84088. export class ModelShape {
  84089. /**
  84090. * The shape id
  84091. * @hidden
  84092. */
  84093. shapeID: number;
  84094. /**
  84095. * flat array of model positions (internal use)
  84096. * @hidden
  84097. */
  84098. _shape: Vector3[];
  84099. /**
  84100. * flat array of model UVs (internal use)
  84101. * @hidden
  84102. */
  84103. _shapeUV: number[];
  84104. /**
  84105. * length of the shape in the model indices array (internal use)
  84106. * @hidden
  84107. */
  84108. _indicesLength: number;
  84109. /**
  84110. * Custom position function (internal use)
  84111. * @hidden
  84112. */
  84113. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  84114. /**
  84115. * Custom vertex function (internal use)
  84116. * @hidden
  84117. */
  84118. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  84119. /**
  84120. * 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.
  84121. * SPS internal tool, don't use it manually.
  84122. * @hidden
  84123. */
  84124. 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>);
  84125. }
  84126. /**
  84127. * Represents a Depth Sorted Particle in the solid particle system.
  84128. */
  84129. export class DepthSortedParticle {
  84130. /**
  84131. * Index of the particle in the "indices" array
  84132. */
  84133. ind: number;
  84134. /**
  84135. * Length of the particle shape in the "indices" array
  84136. */
  84137. indicesLength: number;
  84138. /**
  84139. * Squared distance from the particle to the camera
  84140. */
  84141. sqDistance: number;
  84142. }
  84143. }
  84144. declare module BABYLON {
  84145. /**
  84146. * @hidden
  84147. */
  84148. export class _MeshCollisionData {
  84149. _checkCollisions: boolean;
  84150. _collisionMask: number;
  84151. _collisionGroup: number;
  84152. _collider: Nullable<Collider>;
  84153. _oldPositionForCollisions: Vector3;
  84154. _diffPositionForCollisions: Vector3;
  84155. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  84156. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  84157. }
  84158. }
  84159. declare module BABYLON {
  84160. /**
  84161. * Class used to store all common mesh properties
  84162. */
  84163. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  84164. /** No occlusion */
  84165. static OCCLUSION_TYPE_NONE: number;
  84166. /** Occlusion set to optimisitic */
  84167. static OCCLUSION_TYPE_OPTIMISTIC: number;
  84168. /** Occlusion set to strict */
  84169. static OCCLUSION_TYPE_STRICT: number;
  84170. /** Use an accurante occlusion algorithm */
  84171. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  84172. /** Use a conservative occlusion algorithm */
  84173. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  84174. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  84175. * Test order :
  84176. * Is the bounding sphere outside the frustum ?
  84177. * If not, are the bounding box vertices outside the frustum ?
  84178. * It not, then the cullable object is in the frustum.
  84179. */
  84180. static readonly CULLINGSTRATEGY_STANDARD: number;
  84181. /** Culling strategy : Bounding Sphere Only.
  84182. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  84183. * It's also less accurate than the standard because some not visible objects can still be selected.
  84184. * Test : is the bounding sphere outside the frustum ?
  84185. * If not, then the cullable object is in the frustum.
  84186. */
  84187. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  84188. /** Culling strategy : Optimistic Inclusion.
  84189. * This in an inclusion test first, then the standard exclusion test.
  84190. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  84191. * 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.
  84192. * Anyway, it's as accurate as the standard strategy.
  84193. * Test :
  84194. * Is the cullable object bounding sphere center in the frustum ?
  84195. * If not, apply the default culling strategy.
  84196. */
  84197. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  84198. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  84199. * This in an inclusion test first, then the bounding sphere only exclusion test.
  84200. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  84201. * 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.
  84202. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  84203. * Test :
  84204. * Is the cullable object bounding sphere center in the frustum ?
  84205. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  84206. */
  84207. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  84208. /**
  84209. * No billboard
  84210. */
  84211. static readonly BILLBOARDMODE_NONE: number;
  84212. /** Billboard on X axis */
  84213. static readonly BILLBOARDMODE_X: number;
  84214. /** Billboard on Y axis */
  84215. static readonly BILLBOARDMODE_Y: number;
  84216. /** Billboard on Z axis */
  84217. static readonly BILLBOARDMODE_Z: number;
  84218. /** Billboard on all axes */
  84219. static readonly BILLBOARDMODE_ALL: number;
  84220. private _internalAbstractMeshDataInfo;
  84221. /**
  84222. * The culling strategy to use to check whether the mesh must be rendered or not.
  84223. * This value can be changed at any time and will be used on the next render mesh selection.
  84224. * The possible values are :
  84225. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84226. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84227. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84228. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84229. * Please read each static variable documentation to get details about the culling process.
  84230. * */
  84231. cullingStrategy: number;
  84232. /**
  84233. * Gets the number of facets in the mesh
  84234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84235. */
  84236. readonly facetNb: number;
  84237. /**
  84238. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  84239. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84240. */
  84241. partitioningSubdivisions: number;
  84242. /**
  84243. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  84244. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  84245. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84246. */
  84247. partitioningBBoxRatio: number;
  84248. /**
  84249. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  84250. * Works only for updatable meshes.
  84251. * Doesn't work with multi-materials
  84252. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84253. */
  84254. mustDepthSortFacets: boolean;
  84255. /**
  84256. * The location (Vector3) where the facet depth sort must be computed from.
  84257. * By default, the active camera position.
  84258. * Used only when facet depth sort is enabled
  84259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84260. */
  84261. facetDepthSortFrom: Vector3;
  84262. /**
  84263. * gets a boolean indicating if facetData is enabled
  84264. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84265. */
  84266. readonly isFacetDataEnabled: boolean;
  84267. /** @hidden */
  84268. _updateNonUniformScalingState(value: boolean): boolean;
  84269. /**
  84270. * An event triggered when this mesh collides with another one
  84271. */
  84272. onCollideObservable: Observable<AbstractMesh>;
  84273. /** Set a function to call when this mesh collides with another one */
  84274. onCollide: () => void;
  84275. /**
  84276. * An event triggered when the collision's position changes
  84277. */
  84278. onCollisionPositionChangeObservable: Observable<Vector3>;
  84279. /** Set a function to call when the collision's position changes */
  84280. onCollisionPositionChange: () => void;
  84281. /**
  84282. * An event triggered when material is changed
  84283. */
  84284. onMaterialChangedObservable: Observable<AbstractMesh>;
  84285. /**
  84286. * Gets or sets the orientation for POV movement & rotation
  84287. */
  84288. definedFacingForward: boolean;
  84289. /** @hidden */
  84290. _occlusionQuery: Nullable<WebGLQuery>;
  84291. /** @hidden */
  84292. _isActive: boolean;
  84293. /** @hidden */
  84294. _onlyForInstances: boolean;
  84295. /** @hidden */
  84296. _renderingGroup: Nullable<RenderingGroup>;
  84297. /**
  84298. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84299. */
  84300. /**
  84301. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84302. */
  84303. visibility: number;
  84304. /** Gets or sets the alpha index used to sort transparent meshes
  84305. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  84306. */
  84307. alphaIndex: number;
  84308. /**
  84309. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  84310. */
  84311. isVisible: boolean;
  84312. /**
  84313. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84314. */
  84315. isPickable: boolean;
  84316. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  84317. showSubMeshesBoundingBox: boolean;
  84318. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  84319. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  84320. */
  84321. isBlocker: boolean;
  84322. /**
  84323. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  84324. */
  84325. enablePointerMoveEvents: boolean;
  84326. /**
  84327. * Specifies the rendering group id for this mesh (0 by default)
  84328. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84329. */
  84330. renderingGroupId: number;
  84331. private _material;
  84332. /** Gets or sets current material */
  84333. material: Nullable<Material>;
  84334. /**
  84335. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84336. * @see http://doc.babylonjs.com/babylon101/shadows
  84337. */
  84338. receiveShadows: boolean;
  84339. /** Defines color to use when rendering outline */
  84340. outlineColor: Color3;
  84341. /** Define width to use when rendering outline */
  84342. outlineWidth: number;
  84343. /** Defines color to use when rendering overlay */
  84344. overlayColor: Color3;
  84345. /** Defines alpha to use when rendering overlay */
  84346. overlayAlpha: number;
  84347. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84348. hasVertexAlpha: boolean;
  84349. /** 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) */
  84350. useVertexColors: boolean;
  84351. /**
  84352. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  84353. */
  84354. computeBonesUsingShaders: boolean;
  84355. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84356. numBoneInfluencers: number;
  84357. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84358. applyFog: boolean;
  84359. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  84360. useOctreeForRenderingSelection: boolean;
  84361. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  84362. useOctreeForPicking: boolean;
  84363. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  84364. useOctreeForCollisions: boolean;
  84365. /**
  84366. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84367. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84368. */
  84369. layerMask: number;
  84370. /**
  84371. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  84372. */
  84373. alwaysSelectAsActiveMesh: boolean;
  84374. /**
  84375. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  84376. */
  84377. doNotSyncBoundingInfo: boolean;
  84378. /**
  84379. * Gets or sets the current action manager
  84380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84381. */
  84382. actionManager: Nullable<AbstractActionManager>;
  84383. private _meshCollisionData;
  84384. /**
  84385. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  84386. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84387. */
  84388. ellipsoid: Vector3;
  84389. /**
  84390. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  84391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84392. */
  84393. ellipsoidOffset: Vector3;
  84394. /**
  84395. * Gets or sets a collision mask used to mask collisions (default is -1).
  84396. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84397. */
  84398. collisionMask: number;
  84399. /**
  84400. * Gets or sets the current collision group mask (-1 by default).
  84401. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84402. */
  84403. collisionGroup: number;
  84404. /**
  84405. * Defines edge width used when edgesRenderer is enabled
  84406. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84407. */
  84408. edgesWidth: number;
  84409. /**
  84410. * Defines edge color used when edgesRenderer is enabled
  84411. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84412. */
  84413. edgesColor: Color4;
  84414. /** @hidden */
  84415. _edgesRenderer: Nullable<IEdgesRenderer>;
  84416. /** @hidden */
  84417. _masterMesh: Nullable<AbstractMesh>;
  84418. /** @hidden */
  84419. _boundingInfo: Nullable<BoundingInfo>;
  84420. /** @hidden */
  84421. _renderId: number;
  84422. /**
  84423. * Gets or sets the list of subMeshes
  84424. * @see http://doc.babylonjs.com/how_to/multi_materials
  84425. */
  84426. subMeshes: SubMesh[];
  84427. /** @hidden */
  84428. _intersectionsInProgress: AbstractMesh[];
  84429. /** @hidden */
  84430. _unIndexed: boolean;
  84431. /** @hidden */
  84432. _lightSources: Light[];
  84433. /** Gets the list of lights affecting that mesh */
  84434. readonly lightSources: Light[];
  84435. /** @hidden */
  84436. readonly _positions: Nullable<Vector3[]>;
  84437. /** @hidden */
  84438. _waitingData: {
  84439. lods: Nullable<any>;
  84440. actions: Nullable<any>;
  84441. freezeWorldMatrix: Nullable<boolean>;
  84442. };
  84443. /** @hidden */
  84444. _bonesTransformMatrices: Nullable<Float32Array>;
  84445. /**
  84446. * Gets or sets a skeleton to apply skining transformations
  84447. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84448. */
  84449. skeleton: Nullable<Skeleton>;
  84450. /**
  84451. * An event triggered when the mesh is rebuilt.
  84452. */
  84453. onRebuildObservable: Observable<AbstractMesh>;
  84454. /**
  84455. * Creates a new AbstractMesh
  84456. * @param name defines the name of the mesh
  84457. * @param scene defines the hosting scene
  84458. */
  84459. constructor(name: string, scene?: Nullable<Scene>);
  84460. /**
  84461. * Returns the string "AbstractMesh"
  84462. * @returns "AbstractMesh"
  84463. */
  84464. getClassName(): string;
  84465. /**
  84466. * Gets a string representation of the current mesh
  84467. * @param fullDetails defines a boolean indicating if full details must be included
  84468. * @returns a string representation of the current mesh
  84469. */
  84470. toString(fullDetails?: boolean): string;
  84471. /**
  84472. * @hidden
  84473. */
  84474. protected _getEffectiveParent(): Nullable<Node>;
  84475. /** @hidden */
  84476. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84477. /** @hidden */
  84478. _rebuild(): void;
  84479. /** @hidden */
  84480. _resyncLightSources(): void;
  84481. /** @hidden */
  84482. _resyncLighSource(light: Light): void;
  84483. /** @hidden */
  84484. _unBindEffect(): void;
  84485. /** @hidden */
  84486. _removeLightSource(light: Light): void;
  84487. private _markSubMeshesAsDirty;
  84488. /** @hidden */
  84489. _markSubMeshesAsLightDirty(): void;
  84490. /** @hidden */
  84491. _markSubMeshesAsAttributesDirty(): void;
  84492. /** @hidden */
  84493. _markSubMeshesAsMiscDirty(): void;
  84494. /**
  84495. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84496. */
  84497. scaling: Vector3;
  84498. /**
  84499. * Returns true if the mesh is blocked. Implemented by child classes
  84500. */
  84501. readonly isBlocked: boolean;
  84502. /**
  84503. * Returns the mesh itself by default. Implemented by child classes
  84504. * @param camera defines the camera to use to pick the right LOD level
  84505. * @returns the currentAbstractMesh
  84506. */
  84507. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84508. /**
  84509. * Returns 0 by default. Implemented by child classes
  84510. * @returns an integer
  84511. */
  84512. getTotalVertices(): number;
  84513. /**
  84514. * Returns a positive integer : the total number of indices in this mesh geometry.
  84515. * @returns the numner of indices or zero if the mesh has no geometry.
  84516. */
  84517. getTotalIndices(): number;
  84518. /**
  84519. * Returns null by default. Implemented by child classes
  84520. * @returns null
  84521. */
  84522. getIndices(): Nullable<IndicesArray>;
  84523. /**
  84524. * Returns the array of the requested vertex data kind. Implemented by child classes
  84525. * @param kind defines the vertex data kind to use
  84526. * @returns null
  84527. */
  84528. getVerticesData(kind: string): Nullable<FloatArray>;
  84529. /**
  84530. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84531. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84532. * Note that a new underlying VertexBuffer object is created each call.
  84533. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84534. * @param kind defines vertex data kind:
  84535. * * VertexBuffer.PositionKind
  84536. * * VertexBuffer.UVKind
  84537. * * VertexBuffer.UV2Kind
  84538. * * VertexBuffer.UV3Kind
  84539. * * VertexBuffer.UV4Kind
  84540. * * VertexBuffer.UV5Kind
  84541. * * VertexBuffer.UV6Kind
  84542. * * VertexBuffer.ColorKind
  84543. * * VertexBuffer.MatricesIndicesKind
  84544. * * VertexBuffer.MatricesIndicesExtraKind
  84545. * * VertexBuffer.MatricesWeightsKind
  84546. * * VertexBuffer.MatricesWeightsExtraKind
  84547. * @param data defines the data source
  84548. * @param updatable defines if the data must be flagged as updatable (or static)
  84549. * @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
  84550. * @returns the current mesh
  84551. */
  84552. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84553. /**
  84554. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84555. * If the mesh has no geometry, it is simply returned as it is.
  84556. * @param kind defines vertex data kind:
  84557. * * VertexBuffer.PositionKind
  84558. * * VertexBuffer.UVKind
  84559. * * VertexBuffer.UV2Kind
  84560. * * VertexBuffer.UV3Kind
  84561. * * VertexBuffer.UV4Kind
  84562. * * VertexBuffer.UV5Kind
  84563. * * VertexBuffer.UV6Kind
  84564. * * VertexBuffer.ColorKind
  84565. * * VertexBuffer.MatricesIndicesKind
  84566. * * VertexBuffer.MatricesIndicesExtraKind
  84567. * * VertexBuffer.MatricesWeightsKind
  84568. * * VertexBuffer.MatricesWeightsExtraKind
  84569. * @param data defines the data source
  84570. * @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
  84571. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84572. * @returns the current mesh
  84573. */
  84574. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84575. /**
  84576. * Sets the mesh indices,
  84577. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84578. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84579. * @param totalVertices Defines the total number of vertices
  84580. * @returns the current mesh
  84581. */
  84582. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84583. /**
  84584. * Gets a boolean indicating if specific vertex data is present
  84585. * @param kind defines the vertex data kind to use
  84586. * @returns true is data kind is present
  84587. */
  84588. isVerticesDataPresent(kind: string): boolean;
  84589. /**
  84590. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84591. * @returns a BoundingInfo
  84592. */
  84593. getBoundingInfo(): BoundingInfo;
  84594. /**
  84595. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84596. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84597. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84598. * @returns the current mesh
  84599. */
  84600. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84601. /**
  84602. * Overwrite the current bounding info
  84603. * @param boundingInfo defines the new bounding info
  84604. * @returns the current mesh
  84605. */
  84606. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84607. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84608. readonly useBones: boolean;
  84609. /** @hidden */
  84610. _preActivate(): void;
  84611. /** @hidden */
  84612. _preActivateForIntermediateRendering(renderId: number): void;
  84613. /** @hidden */
  84614. _activate(renderId: number): boolean;
  84615. /** @hidden */
  84616. _postActivate(): void;
  84617. /** @hidden */
  84618. _freeze(): void;
  84619. /** @hidden */
  84620. _unFreeze(): void;
  84621. /**
  84622. * Gets the current world matrix
  84623. * @returns a Matrix
  84624. */
  84625. getWorldMatrix(): Matrix;
  84626. /** @hidden */
  84627. _getWorldMatrixDeterminant(): number;
  84628. /**
  84629. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  84630. */
  84631. readonly isAnInstance: boolean;
  84632. /**
  84633. * Perform relative position change from the point of view of behind the front of the mesh.
  84634. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84635. * Supports definition of mesh facing forward or backward
  84636. * @param amountRight defines the distance on the right axis
  84637. * @param amountUp defines the distance on the up axis
  84638. * @param amountForward defines the distance on the forward axis
  84639. * @returns the current mesh
  84640. */
  84641. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84642. /**
  84643. * Calculate relative position change from the point of view of behind the front of the mesh.
  84644. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84645. * Supports definition of mesh facing forward or backward
  84646. * @param amountRight defines the distance on the right axis
  84647. * @param amountUp defines the distance on the up axis
  84648. * @param amountForward defines the distance on the forward axis
  84649. * @returns the new displacement vector
  84650. */
  84651. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84652. /**
  84653. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84654. * Supports definition of mesh facing forward or backward
  84655. * @param flipBack defines the flip
  84656. * @param twirlClockwise defines the twirl
  84657. * @param tiltRight defines the tilt
  84658. * @returns the current mesh
  84659. */
  84660. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84661. /**
  84662. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84663. * Supports definition of mesh facing forward or backward.
  84664. * @param flipBack defines the flip
  84665. * @param twirlClockwise defines the twirl
  84666. * @param tiltRight defines the tilt
  84667. * @returns the new rotation vector
  84668. */
  84669. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84670. /**
  84671. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84672. * This means the mesh underlying bounding box and sphere are recomputed.
  84673. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84674. * @returns the current mesh
  84675. */
  84676. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84677. /** @hidden */
  84678. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84679. /** @hidden */
  84680. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84681. /** @hidden */
  84682. _updateBoundingInfo(): AbstractMesh;
  84683. /** @hidden */
  84684. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84685. /** @hidden */
  84686. protected _afterComputeWorldMatrix(): void;
  84687. /** @hidden */
  84688. readonly _effectiveMesh: AbstractMesh;
  84689. /**
  84690. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84691. * A mesh is in the frustum if its bounding box intersects the frustum
  84692. * @param frustumPlanes defines the frustum to test
  84693. * @returns true if the mesh is in the frustum planes
  84694. */
  84695. isInFrustum(frustumPlanes: Plane[]): boolean;
  84696. /**
  84697. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84698. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84699. * @param frustumPlanes defines the frustum to test
  84700. * @returns true if the mesh is completely in the frustum planes
  84701. */
  84702. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84703. /**
  84704. * True if the mesh intersects another mesh or a SolidParticle object
  84705. * @param mesh defines a target mesh or SolidParticle to test
  84706. * @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)
  84707. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84708. * @returns true if there is an intersection
  84709. */
  84710. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84711. /**
  84712. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84713. * @param point defines the point to test
  84714. * @returns true if there is an intersection
  84715. */
  84716. intersectsPoint(point: Vector3): boolean;
  84717. /**
  84718. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84719. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84720. */
  84721. checkCollisions: boolean;
  84722. /**
  84723. * Gets Collider object used to compute collisions (not physics)
  84724. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84725. */
  84726. readonly collider: Nullable<Collider>;
  84727. /**
  84728. * Move the mesh using collision engine
  84729. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84730. * @param displacement defines the requested displacement vector
  84731. * @returns the current mesh
  84732. */
  84733. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84734. private _onCollisionPositionChange;
  84735. /** @hidden */
  84736. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84737. /** @hidden */
  84738. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84739. /** @hidden */
  84740. _checkCollision(collider: Collider): AbstractMesh;
  84741. /** @hidden */
  84742. _generatePointsArray(): boolean;
  84743. /**
  84744. * Checks if the passed Ray intersects with the mesh
  84745. * @param ray defines the ray to use
  84746. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84747. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84748. * @returns the picking info
  84749. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84750. */
  84751. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84752. /**
  84753. * Clones the current mesh
  84754. * @param name defines the mesh name
  84755. * @param newParent defines the new mesh parent
  84756. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84757. * @returns the new mesh
  84758. */
  84759. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84760. /**
  84761. * Disposes all the submeshes of the current meshnp
  84762. * @returns the current mesh
  84763. */
  84764. releaseSubMeshes(): AbstractMesh;
  84765. /**
  84766. * Releases resources associated with this abstract mesh.
  84767. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84768. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84769. */
  84770. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84771. /**
  84772. * Adds the passed mesh as a child to the current mesh
  84773. * @param mesh defines the child mesh
  84774. * @returns the current mesh
  84775. */
  84776. addChild(mesh: AbstractMesh): AbstractMesh;
  84777. /**
  84778. * Removes the passed mesh from the current mesh children list
  84779. * @param mesh defines the child mesh
  84780. * @returns the current mesh
  84781. */
  84782. removeChild(mesh: AbstractMesh): AbstractMesh;
  84783. /** @hidden */
  84784. private _initFacetData;
  84785. /**
  84786. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84787. * This method can be called within the render loop.
  84788. * 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
  84789. * @returns the current mesh
  84790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84791. */
  84792. updateFacetData(): AbstractMesh;
  84793. /**
  84794. * Returns the facetLocalNormals array.
  84795. * The normals are expressed in the mesh local spac
  84796. * @returns an array of Vector3
  84797. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84798. */
  84799. getFacetLocalNormals(): Vector3[];
  84800. /**
  84801. * Returns the facetLocalPositions array.
  84802. * The facet positions are expressed in the mesh local space
  84803. * @returns an array of Vector3
  84804. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84805. */
  84806. getFacetLocalPositions(): Vector3[];
  84807. /**
  84808. * Returns the facetLocalPartioning array
  84809. * @returns an array of array of numbers
  84810. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84811. */
  84812. getFacetLocalPartitioning(): number[][];
  84813. /**
  84814. * Returns the i-th facet position in the world system.
  84815. * This method allocates a new Vector3 per call
  84816. * @param i defines the facet index
  84817. * @returns a new Vector3
  84818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84819. */
  84820. getFacetPosition(i: number): Vector3;
  84821. /**
  84822. * Sets the reference Vector3 with the i-th facet position in the world system
  84823. * @param i defines the facet index
  84824. * @param ref defines the target vector
  84825. * @returns the current mesh
  84826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84827. */
  84828. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84829. /**
  84830. * Returns the i-th facet normal in the world system.
  84831. * This method allocates a new Vector3 per call
  84832. * @param i defines the facet index
  84833. * @returns a new Vector3
  84834. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84835. */
  84836. getFacetNormal(i: number): Vector3;
  84837. /**
  84838. * Sets the reference Vector3 with the i-th facet normal in the world system
  84839. * @param i defines the facet index
  84840. * @param ref defines the target vector
  84841. * @returns the current mesh
  84842. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84843. */
  84844. getFacetNormalToRef(i: number, ref: Vector3): this;
  84845. /**
  84846. * 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)
  84847. * @param x defines x coordinate
  84848. * @param y defines y coordinate
  84849. * @param z defines z coordinate
  84850. * @returns the array of facet indexes
  84851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84852. */
  84853. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  84854. /**
  84855. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  84856. * @param projected sets as the (x,y,z) world projection on the facet
  84857. * @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
  84858. * @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
  84859. * @param x defines x coordinate
  84860. * @param y defines y coordinate
  84861. * @param z defines z coordinate
  84862. * @returns the face index if found (or null instead)
  84863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84864. */
  84865. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84866. /**
  84867. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  84868. * @param projected sets as the (x,y,z) local projection on the facet
  84869. * @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
  84870. * @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
  84871. * @param x defines x coordinate
  84872. * @param y defines y coordinate
  84873. * @param z defines z coordinate
  84874. * @returns the face index if found (or null instead)
  84875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84876. */
  84877. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84878. /**
  84879. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  84880. * @returns the parameters
  84881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84882. */
  84883. getFacetDataParameters(): any;
  84884. /**
  84885. * Disables the feature FacetData and frees the related memory
  84886. * @returns the current mesh
  84887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84888. */
  84889. disableFacetData(): AbstractMesh;
  84890. /**
  84891. * Updates the AbstractMesh indices array
  84892. * @param indices defines the data source
  84893. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84894. * @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)
  84895. * @returns the current mesh
  84896. */
  84897. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  84898. /**
  84899. * Creates new normals data for the mesh
  84900. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84901. * @returns the current mesh
  84902. */
  84903. createNormals(updatable: boolean): AbstractMesh;
  84904. /**
  84905. * Align the mesh with a normal
  84906. * @param normal defines the normal to use
  84907. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84908. * @returns the current mesh
  84909. */
  84910. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84911. /** @hidden */
  84912. _checkOcclusionQuery(): boolean;
  84913. }
  84914. }
  84915. declare module BABYLON {
  84916. /**
  84917. * Interface used to define ActionEvent
  84918. */
  84919. export interface IActionEvent {
  84920. /** The mesh or sprite that triggered the action */
  84921. source: any;
  84922. /** The X mouse cursor position at the time of the event */
  84923. pointerX: number;
  84924. /** The Y mouse cursor position at the time of the event */
  84925. pointerY: number;
  84926. /** The mesh that is currently pointed at (can be null) */
  84927. meshUnderPointer: Nullable<AbstractMesh>;
  84928. /** the original (browser) event that triggered the ActionEvent */
  84929. sourceEvent?: any;
  84930. /** additional data for the event */
  84931. additionalData?: any;
  84932. }
  84933. /**
  84934. * ActionEvent is the event being sent when an action is triggered.
  84935. */
  84936. export class ActionEvent implements IActionEvent {
  84937. /** The mesh or sprite that triggered the action */
  84938. source: any;
  84939. /** The X mouse cursor position at the time of the event */
  84940. pointerX: number;
  84941. /** The Y mouse cursor position at the time of the event */
  84942. pointerY: number;
  84943. /** The mesh that is currently pointed at (can be null) */
  84944. meshUnderPointer: Nullable<AbstractMesh>;
  84945. /** the original (browser) event that triggered the ActionEvent */
  84946. sourceEvent?: any;
  84947. /** additional data for the event */
  84948. additionalData?: any;
  84949. /**
  84950. * Creates a new ActionEvent
  84951. * @param source The mesh or sprite that triggered the action
  84952. * @param pointerX The X mouse cursor position at the time of the event
  84953. * @param pointerY The Y mouse cursor position at the time of the event
  84954. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84955. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84956. * @param additionalData additional data for the event
  84957. */
  84958. constructor(
  84959. /** The mesh or sprite that triggered the action */
  84960. source: any,
  84961. /** The X mouse cursor position at the time of the event */
  84962. pointerX: number,
  84963. /** The Y mouse cursor position at the time of the event */
  84964. pointerY: number,
  84965. /** The mesh that is currently pointed at (can be null) */
  84966. meshUnderPointer: Nullable<AbstractMesh>,
  84967. /** the original (browser) event that triggered the ActionEvent */
  84968. sourceEvent?: any,
  84969. /** additional data for the event */
  84970. additionalData?: any);
  84971. /**
  84972. * Helper function to auto-create an ActionEvent from a source mesh.
  84973. * @param source The source mesh that triggered the event
  84974. * @param evt The original (browser) event
  84975. * @param additionalData additional data for the event
  84976. * @returns the new ActionEvent
  84977. */
  84978. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84979. /**
  84980. * Helper function to auto-create an ActionEvent from a source sprite
  84981. * @param source The source sprite that triggered the event
  84982. * @param scene Scene associated with the sprite
  84983. * @param evt The original (browser) event
  84984. * @param additionalData additional data for the event
  84985. * @returns the new ActionEvent
  84986. */
  84987. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84988. /**
  84989. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84990. * @param scene the scene where the event occurred
  84991. * @param evt The original (browser) event
  84992. * @returns the new ActionEvent
  84993. */
  84994. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  84995. /**
  84996. * Helper function to auto-create an ActionEvent from a primitive
  84997. * @param prim defines the target primitive
  84998. * @param pointerPos defines the pointer position
  84999. * @param evt The original (browser) event
  85000. * @param additionalData additional data for the event
  85001. * @returns the new ActionEvent
  85002. */
  85003. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  85004. }
  85005. }
  85006. declare module BABYLON {
  85007. /**
  85008. * Abstract class used to decouple action Manager from scene and meshes.
  85009. * Do not instantiate.
  85010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  85011. */
  85012. export abstract class AbstractActionManager implements IDisposable {
  85013. /** Gets the list of active triggers */
  85014. static Triggers: {
  85015. [key: string]: number;
  85016. };
  85017. /** Gets the cursor to use when hovering items */
  85018. hoverCursor: string;
  85019. /** Gets the list of actions */
  85020. actions: IAction[];
  85021. /**
  85022. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  85023. */
  85024. isRecursive: boolean;
  85025. /**
  85026. * Releases all associated resources
  85027. */
  85028. abstract dispose(): void;
  85029. /**
  85030. * Does this action manager has pointer triggers
  85031. */
  85032. abstract readonly hasPointerTriggers: boolean;
  85033. /**
  85034. * Does this action manager has pick triggers
  85035. */
  85036. abstract readonly hasPickTriggers: boolean;
  85037. /**
  85038. * Process a specific trigger
  85039. * @param trigger defines the trigger to process
  85040. * @param evt defines the event details to be processed
  85041. */
  85042. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  85043. /**
  85044. * Does this action manager handles actions of any of the given triggers
  85045. * @param triggers defines the triggers to be tested
  85046. * @return a boolean indicating whether one (or more) of the triggers is handled
  85047. */
  85048. abstract hasSpecificTriggers(triggers: number[]): boolean;
  85049. /**
  85050. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  85051. * speed.
  85052. * @param triggerA defines the trigger to be tested
  85053. * @param triggerB defines the trigger to be tested
  85054. * @return a boolean indicating whether one (or more) of the triggers is handled
  85055. */
  85056. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  85057. /**
  85058. * Does this action manager handles actions of a given trigger
  85059. * @param trigger defines the trigger to be tested
  85060. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  85061. * @return whether the trigger is handled
  85062. */
  85063. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  85064. /**
  85065. * Serialize this manager to a JSON object
  85066. * @param name defines the property name to store this manager
  85067. * @returns a JSON representation of this manager
  85068. */
  85069. abstract serialize(name: string): any;
  85070. /**
  85071. * Registers an action to this action manager
  85072. * @param action defines the action to be registered
  85073. * @return the action amended (prepared) after registration
  85074. */
  85075. abstract registerAction(action: IAction): Nullable<IAction>;
  85076. /**
  85077. * Unregisters an action to this action manager
  85078. * @param action defines the action to be unregistered
  85079. * @return a boolean indicating whether the action has been unregistered
  85080. */
  85081. abstract unregisterAction(action: IAction): Boolean;
  85082. /**
  85083. * Does exist one action manager with at least one trigger
  85084. **/
  85085. static readonly HasTriggers: boolean;
  85086. /**
  85087. * Does exist one action manager with at least one pick trigger
  85088. **/
  85089. static readonly HasPickTriggers: boolean;
  85090. /**
  85091. * Does exist one action manager that handles actions of a given trigger
  85092. * @param trigger defines the trigger to be tested
  85093. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  85094. **/
  85095. static HasSpecificTrigger(trigger: number): boolean;
  85096. }
  85097. }
  85098. declare module BABYLON {
  85099. /**
  85100. * Defines how a node can be built from a string name.
  85101. */
  85102. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  85103. /**
  85104. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  85105. */
  85106. export class Node implements IBehaviorAware<Node> {
  85107. /** @hidden */
  85108. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  85109. private static _NodeConstructors;
  85110. /**
  85111. * Add a new node constructor
  85112. * @param type defines the type name of the node to construct
  85113. * @param constructorFunc defines the constructor function
  85114. */
  85115. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  85116. /**
  85117. * Returns a node constructor based on type name
  85118. * @param type defines the type name
  85119. * @param name defines the new node name
  85120. * @param scene defines the hosting scene
  85121. * @param options defines optional options to transmit to constructors
  85122. * @returns the new constructor or null
  85123. */
  85124. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  85125. /**
  85126. * Gets or sets the name of the node
  85127. */
  85128. name: string;
  85129. /**
  85130. * Gets or sets the id of the node
  85131. */
  85132. id: string;
  85133. /**
  85134. * Gets or sets the unique id of the node
  85135. */
  85136. uniqueId: number;
  85137. /**
  85138. * Gets or sets a string used to store user defined state for the node
  85139. */
  85140. state: string;
  85141. /**
  85142. * Gets or sets an object used to store user defined information for the node
  85143. */
  85144. metadata: any;
  85145. /**
  85146. * For internal use only. Please do not use.
  85147. */
  85148. reservedDataStore: any;
  85149. /**
  85150. * List of inspectable custom properties (used by the Inspector)
  85151. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85152. */
  85153. inspectableCustomProperties: IInspectable[];
  85154. /**
  85155. * Gets or sets a boolean used to define if the node must be serialized
  85156. */
  85157. doNotSerialize: boolean;
  85158. /** @hidden */
  85159. _isDisposed: boolean;
  85160. /**
  85161. * Gets a list of Animations associated with the node
  85162. */
  85163. animations: Animation[];
  85164. protected _ranges: {
  85165. [name: string]: Nullable<AnimationRange>;
  85166. };
  85167. /**
  85168. * Callback raised when the node is ready to be used
  85169. */
  85170. onReady: Nullable<(node: Node) => void>;
  85171. private _isEnabled;
  85172. private _isParentEnabled;
  85173. private _isReady;
  85174. /** @hidden */
  85175. _currentRenderId: number;
  85176. private _parentUpdateId;
  85177. /** @hidden */
  85178. _childUpdateId: number;
  85179. /** @hidden */
  85180. _waitingParentId: Nullable<string>;
  85181. /** @hidden */
  85182. _scene: Scene;
  85183. /** @hidden */
  85184. _cache: any;
  85185. private _parentNode;
  85186. private _children;
  85187. /** @hidden */
  85188. _worldMatrix: Matrix;
  85189. /** @hidden */
  85190. _worldMatrixDeterminant: number;
  85191. /** @hidden */
  85192. _worldMatrixDeterminantIsDirty: boolean;
  85193. /** @hidden */
  85194. private _sceneRootNodesIndex;
  85195. /**
  85196. * Gets a boolean indicating if the node has been disposed
  85197. * @returns true if the node was disposed
  85198. */
  85199. isDisposed(): boolean;
  85200. /**
  85201. * Gets or sets the parent of the node (without keeping the current position in the scene)
  85202. * @see https://doc.babylonjs.com/how_to/parenting
  85203. */
  85204. parent: Nullable<Node>;
  85205. private addToSceneRootNodes;
  85206. private removeFromSceneRootNodes;
  85207. private _animationPropertiesOverride;
  85208. /**
  85209. * Gets or sets the animation properties override
  85210. */
  85211. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85212. /**
  85213. * Gets a string idenfifying the name of the class
  85214. * @returns "Node" string
  85215. */
  85216. getClassName(): string;
  85217. /** @hidden */
  85218. readonly _isNode: boolean;
  85219. /**
  85220. * An event triggered when the mesh is disposed
  85221. */
  85222. onDisposeObservable: Observable<Node>;
  85223. private _onDisposeObserver;
  85224. /**
  85225. * Sets a callback that will be raised when the node will be disposed
  85226. */
  85227. onDispose: () => void;
  85228. /**
  85229. * Creates a new Node
  85230. * @param name the name and id to be given to this node
  85231. * @param scene the scene this node will be added to
  85232. * @param addToRootNodes the node will be added to scene.rootNodes
  85233. */
  85234. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  85235. /**
  85236. * Gets the scene of the node
  85237. * @returns a scene
  85238. */
  85239. getScene(): Scene;
  85240. /**
  85241. * Gets the engine of the node
  85242. * @returns a Engine
  85243. */
  85244. getEngine(): Engine;
  85245. private _behaviors;
  85246. /**
  85247. * Attach a behavior to the node
  85248. * @see http://doc.babylonjs.com/features/behaviour
  85249. * @param behavior defines the behavior to attach
  85250. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  85251. * @returns the current Node
  85252. */
  85253. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  85254. /**
  85255. * Remove an attached behavior
  85256. * @see http://doc.babylonjs.com/features/behaviour
  85257. * @param behavior defines the behavior to attach
  85258. * @returns the current Node
  85259. */
  85260. removeBehavior(behavior: Behavior<Node>): Node;
  85261. /**
  85262. * Gets the list of attached behaviors
  85263. * @see http://doc.babylonjs.com/features/behaviour
  85264. */
  85265. readonly behaviors: Behavior<Node>[];
  85266. /**
  85267. * Gets an attached behavior by name
  85268. * @param name defines the name of the behavior to look for
  85269. * @see http://doc.babylonjs.com/features/behaviour
  85270. * @returns null if behavior was not found else the requested behavior
  85271. */
  85272. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  85273. /**
  85274. * Returns the latest update of the World matrix
  85275. * @returns a Matrix
  85276. */
  85277. getWorldMatrix(): Matrix;
  85278. /** @hidden */
  85279. _getWorldMatrixDeterminant(): number;
  85280. /**
  85281. * Returns directly the latest state of the mesh World matrix.
  85282. * A Matrix is returned.
  85283. */
  85284. readonly worldMatrixFromCache: Matrix;
  85285. /** @hidden */
  85286. _initCache(): void;
  85287. /** @hidden */
  85288. updateCache(force?: boolean): void;
  85289. /** @hidden */
  85290. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  85291. /** @hidden */
  85292. _updateCache(ignoreParentClass?: boolean): void;
  85293. /** @hidden */
  85294. _isSynchronized(): boolean;
  85295. /** @hidden */
  85296. _markSyncedWithParent(): void;
  85297. /** @hidden */
  85298. isSynchronizedWithParent(): boolean;
  85299. /** @hidden */
  85300. isSynchronized(): boolean;
  85301. /**
  85302. * Is this node ready to be used/rendered
  85303. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85304. * @return true if the node is ready
  85305. */
  85306. isReady(completeCheck?: boolean): boolean;
  85307. /**
  85308. * Is this node enabled?
  85309. * 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
  85310. * @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
  85311. * @return whether this node (and its parent) is enabled
  85312. */
  85313. isEnabled(checkAncestors?: boolean): boolean;
  85314. /** @hidden */
  85315. protected _syncParentEnabledState(): void;
  85316. /**
  85317. * Set the enabled state of this node
  85318. * @param value defines the new enabled state
  85319. */
  85320. setEnabled(value: boolean): void;
  85321. /**
  85322. * Is this node a descendant of the given node?
  85323. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  85324. * @param ancestor defines the parent node to inspect
  85325. * @returns a boolean indicating if this node is a descendant of the given node
  85326. */
  85327. isDescendantOf(ancestor: Node): boolean;
  85328. /** @hidden */
  85329. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  85330. /**
  85331. * Will return all nodes that have this node as ascendant
  85332. * @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
  85333. * @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
  85334. * @return all children nodes of all types
  85335. */
  85336. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  85337. /**
  85338. * Get all child-meshes of this node
  85339. * @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)
  85340. * @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
  85341. * @returns an array of AbstractMesh
  85342. */
  85343. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  85344. /**
  85345. * Get all direct children of this node
  85346. * @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
  85347. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  85348. * @returns an array of Node
  85349. */
  85350. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  85351. /** @hidden */
  85352. _setReady(state: boolean): void;
  85353. /**
  85354. * Get an animation by name
  85355. * @param name defines the name of the animation to look for
  85356. * @returns null if not found else the requested animation
  85357. */
  85358. getAnimationByName(name: string): Nullable<Animation>;
  85359. /**
  85360. * Creates an animation range for this node
  85361. * @param name defines the name of the range
  85362. * @param from defines the starting key
  85363. * @param to defines the end key
  85364. */
  85365. createAnimationRange(name: string, from: number, to: number): void;
  85366. /**
  85367. * Delete a specific animation range
  85368. * @param name defines the name of the range to delete
  85369. * @param deleteFrames defines if animation frames from the range must be deleted as well
  85370. */
  85371. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85372. /**
  85373. * Get an animation range by name
  85374. * @param name defines the name of the animation range to look for
  85375. * @returns null if not found else the requested animation range
  85376. */
  85377. getAnimationRange(name: string): Nullable<AnimationRange>;
  85378. /**
  85379. * Gets the list of all animation ranges defined on this node
  85380. * @returns an array
  85381. */
  85382. getAnimationRanges(): Nullable<AnimationRange>[];
  85383. /**
  85384. * Will start the animation sequence
  85385. * @param name defines the range frames for animation sequence
  85386. * @param loop defines if the animation should loop (false by default)
  85387. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  85388. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  85389. * @returns the object created for this animation. If range does not exist, it will return null
  85390. */
  85391. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85392. /**
  85393. * Serialize animation ranges into a JSON compatible object
  85394. * @returns serialization object
  85395. */
  85396. serializeAnimationRanges(): any;
  85397. /**
  85398. * Computes the world matrix of the node
  85399. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85400. * @returns the world matrix
  85401. */
  85402. computeWorldMatrix(force?: boolean): Matrix;
  85403. /**
  85404. * Releases resources associated with this node.
  85405. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85406. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85407. */
  85408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85409. /**
  85410. * Parse animation range data from a serialization object and store them into a given node
  85411. * @param node defines where to store the animation ranges
  85412. * @param parsedNode defines the serialization object to read data from
  85413. * @param scene defines the hosting scene
  85414. */
  85415. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  85416. /**
  85417. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  85418. * @param includeDescendants Include bounding info from descendants as well (true by default)
  85419. * @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
  85420. * @returns the new bounding vectors
  85421. */
  85422. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  85423. min: Vector3;
  85424. max: Vector3;
  85425. };
  85426. }
  85427. }
  85428. declare module BABYLON {
  85429. /**
  85430. * @hidden
  85431. */
  85432. export class _IAnimationState {
  85433. key: number;
  85434. repeatCount: number;
  85435. workValue?: any;
  85436. loopMode?: number;
  85437. offsetValue?: any;
  85438. highLimitValue?: any;
  85439. }
  85440. /**
  85441. * Class used to store any kind of animation
  85442. */
  85443. export class Animation {
  85444. /**Name of the animation */
  85445. name: string;
  85446. /**Property to animate */
  85447. targetProperty: string;
  85448. /**The frames per second of the animation */
  85449. framePerSecond: number;
  85450. /**The data type of the animation */
  85451. dataType: number;
  85452. /**The loop mode of the animation */
  85453. loopMode?: number | undefined;
  85454. /**Specifies if blending should be enabled */
  85455. enableBlending?: boolean | undefined;
  85456. /**
  85457. * Use matrix interpolation instead of using direct key value when animating matrices
  85458. */
  85459. static AllowMatricesInterpolation: boolean;
  85460. /**
  85461. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85462. */
  85463. static AllowMatrixDecomposeForInterpolation: boolean;
  85464. /**
  85465. * Stores the key frames of the animation
  85466. */
  85467. private _keys;
  85468. /**
  85469. * Stores the easing function of the animation
  85470. */
  85471. private _easingFunction;
  85472. /**
  85473. * @hidden Internal use only
  85474. */
  85475. _runtimeAnimations: RuntimeAnimation[];
  85476. /**
  85477. * The set of event that will be linked to this animation
  85478. */
  85479. private _events;
  85480. /**
  85481. * Stores an array of target property paths
  85482. */
  85483. targetPropertyPath: string[];
  85484. /**
  85485. * Stores the blending speed of the animation
  85486. */
  85487. blendingSpeed: number;
  85488. /**
  85489. * Stores the animation ranges for the animation
  85490. */
  85491. private _ranges;
  85492. /**
  85493. * @hidden Internal use
  85494. */
  85495. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85496. /**
  85497. * Sets up an animation
  85498. * @param property The property to animate
  85499. * @param animationType The animation type to apply
  85500. * @param framePerSecond The frames per second of the animation
  85501. * @param easingFunction The easing function used in the animation
  85502. * @returns The created animation
  85503. */
  85504. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85505. /**
  85506. * Create and start an animation on a node
  85507. * @param name defines the name of the global animation that will be run on all nodes
  85508. * @param node defines the root node where the animation will take place
  85509. * @param targetProperty defines property to animate
  85510. * @param framePerSecond defines the number of frame per second yo use
  85511. * @param totalFrame defines the number of frames in total
  85512. * @param from defines the initial value
  85513. * @param to defines the final value
  85514. * @param loopMode defines which loop mode you want to use (off by default)
  85515. * @param easingFunction defines the easing function to use (linear by default)
  85516. * @param onAnimationEnd defines the callback to call when animation end
  85517. * @returns the animatable created for this animation
  85518. */
  85519. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85520. /**
  85521. * Create and start an animation on a node and its descendants
  85522. * @param name defines the name of the global animation that will be run on all nodes
  85523. * @param node defines the root node where the animation will take place
  85524. * @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
  85525. * @param targetProperty defines property to animate
  85526. * @param framePerSecond defines the number of frame per second to use
  85527. * @param totalFrame defines the number of frames in total
  85528. * @param from defines the initial value
  85529. * @param to defines the final value
  85530. * @param loopMode defines which loop mode you want to use (off by default)
  85531. * @param easingFunction defines the easing function to use (linear by default)
  85532. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85533. * @returns the list of animatables created for all nodes
  85534. * @example https://www.babylonjs-playground.com/#MH0VLI
  85535. */
  85536. 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[]>;
  85537. /**
  85538. * Creates a new animation, merges it with the existing animations and starts it
  85539. * @param name Name of the animation
  85540. * @param node Node which contains the scene that begins the animations
  85541. * @param targetProperty Specifies which property to animate
  85542. * @param framePerSecond The frames per second of the animation
  85543. * @param totalFrame The total number of frames
  85544. * @param from The frame at the beginning of the animation
  85545. * @param to The frame at the end of the animation
  85546. * @param loopMode Specifies the loop mode of the animation
  85547. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85548. * @param onAnimationEnd Callback to run once the animation is complete
  85549. * @returns Nullable animation
  85550. */
  85551. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85552. /**
  85553. * Transition property of an host to the target Value
  85554. * @param property The property to transition
  85555. * @param targetValue The target Value of the property
  85556. * @param host The object where the property to animate belongs
  85557. * @param scene Scene used to run the animation
  85558. * @param frameRate Framerate (in frame/s) to use
  85559. * @param transition The transition type we want to use
  85560. * @param duration The duration of the animation, in milliseconds
  85561. * @param onAnimationEnd Callback trigger at the end of the animation
  85562. * @returns Nullable animation
  85563. */
  85564. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85565. /**
  85566. * Return the array of runtime animations currently using this animation
  85567. */
  85568. readonly runtimeAnimations: RuntimeAnimation[];
  85569. /**
  85570. * Specifies if any of the runtime animations are currently running
  85571. */
  85572. readonly hasRunningRuntimeAnimations: boolean;
  85573. /**
  85574. * Initializes the animation
  85575. * @param name Name of the animation
  85576. * @param targetProperty Property to animate
  85577. * @param framePerSecond The frames per second of the animation
  85578. * @param dataType The data type of the animation
  85579. * @param loopMode The loop mode of the animation
  85580. * @param enableBlending Specifies if blending should be enabled
  85581. */
  85582. constructor(
  85583. /**Name of the animation */
  85584. name: string,
  85585. /**Property to animate */
  85586. targetProperty: string,
  85587. /**The frames per second of the animation */
  85588. framePerSecond: number,
  85589. /**The data type of the animation */
  85590. dataType: number,
  85591. /**The loop mode of the animation */
  85592. loopMode?: number | undefined,
  85593. /**Specifies if blending should be enabled */
  85594. enableBlending?: boolean | undefined);
  85595. /**
  85596. * Converts the animation to a string
  85597. * @param fullDetails support for multiple levels of logging within scene loading
  85598. * @returns String form of the animation
  85599. */
  85600. toString(fullDetails?: boolean): string;
  85601. /**
  85602. * Add an event to this animation
  85603. * @param event Event to add
  85604. */
  85605. addEvent(event: AnimationEvent): void;
  85606. /**
  85607. * Remove all events found at the given frame
  85608. * @param frame The frame to remove events from
  85609. */
  85610. removeEvents(frame: number): void;
  85611. /**
  85612. * Retrieves all the events from the animation
  85613. * @returns Events from the animation
  85614. */
  85615. getEvents(): AnimationEvent[];
  85616. /**
  85617. * Creates an animation range
  85618. * @param name Name of the animation range
  85619. * @param from Starting frame of the animation range
  85620. * @param to Ending frame of the animation
  85621. */
  85622. createRange(name: string, from: number, to: number): void;
  85623. /**
  85624. * Deletes an animation range by name
  85625. * @param name Name of the animation range to delete
  85626. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85627. */
  85628. deleteRange(name: string, deleteFrames?: boolean): void;
  85629. /**
  85630. * Gets the animation range by name, or null if not defined
  85631. * @param name Name of the animation range
  85632. * @returns Nullable animation range
  85633. */
  85634. getRange(name: string): Nullable<AnimationRange>;
  85635. /**
  85636. * Gets the key frames from the animation
  85637. * @returns The key frames of the animation
  85638. */
  85639. getKeys(): Array<IAnimationKey>;
  85640. /**
  85641. * Gets the highest frame rate of the animation
  85642. * @returns Highest frame rate of the animation
  85643. */
  85644. getHighestFrame(): number;
  85645. /**
  85646. * Gets the easing function of the animation
  85647. * @returns Easing function of the animation
  85648. */
  85649. getEasingFunction(): IEasingFunction;
  85650. /**
  85651. * Sets the easing function of the animation
  85652. * @param easingFunction A custom mathematical formula for animation
  85653. */
  85654. setEasingFunction(easingFunction: EasingFunction): void;
  85655. /**
  85656. * Interpolates a scalar linearly
  85657. * @param startValue Start value of the animation curve
  85658. * @param endValue End value of the animation curve
  85659. * @param gradient Scalar amount to interpolate
  85660. * @returns Interpolated scalar value
  85661. */
  85662. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85663. /**
  85664. * Interpolates a scalar cubically
  85665. * @param startValue Start value of the animation curve
  85666. * @param outTangent End tangent of the animation
  85667. * @param endValue End value of the animation curve
  85668. * @param inTangent Start tangent of the animation curve
  85669. * @param gradient Scalar amount to interpolate
  85670. * @returns Interpolated scalar value
  85671. */
  85672. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85673. /**
  85674. * Interpolates a quaternion using a spherical linear interpolation
  85675. * @param startValue Start value of the animation curve
  85676. * @param endValue End value of the animation curve
  85677. * @param gradient Scalar amount to interpolate
  85678. * @returns Interpolated quaternion value
  85679. */
  85680. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85681. /**
  85682. * Interpolates a quaternion cubically
  85683. * @param startValue Start value of the animation curve
  85684. * @param outTangent End tangent of the animation curve
  85685. * @param endValue End value of the animation curve
  85686. * @param inTangent Start tangent of the animation curve
  85687. * @param gradient Scalar amount to interpolate
  85688. * @returns Interpolated quaternion value
  85689. */
  85690. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85691. /**
  85692. * Interpolates a Vector3 linearl
  85693. * @param startValue Start value of the animation curve
  85694. * @param endValue End value of the animation curve
  85695. * @param gradient Scalar amount to interpolate
  85696. * @returns Interpolated scalar value
  85697. */
  85698. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85699. /**
  85700. * Interpolates a Vector3 cubically
  85701. * @param startValue Start value of the animation curve
  85702. * @param outTangent End tangent of the animation
  85703. * @param endValue End value of the animation curve
  85704. * @param inTangent Start tangent of the animation curve
  85705. * @param gradient Scalar amount to interpolate
  85706. * @returns InterpolatedVector3 value
  85707. */
  85708. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85709. /**
  85710. * Interpolates a Vector2 linearly
  85711. * @param startValue Start value of the animation curve
  85712. * @param endValue End value of the animation curve
  85713. * @param gradient Scalar amount to interpolate
  85714. * @returns Interpolated Vector2 value
  85715. */
  85716. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85717. /**
  85718. * Interpolates a Vector2 cubically
  85719. * @param startValue Start value of the animation curve
  85720. * @param outTangent End tangent of the animation
  85721. * @param endValue End value of the animation curve
  85722. * @param inTangent Start tangent of the animation curve
  85723. * @param gradient Scalar amount to interpolate
  85724. * @returns Interpolated Vector2 value
  85725. */
  85726. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85727. /**
  85728. * Interpolates a size linearly
  85729. * @param startValue Start value of the animation curve
  85730. * @param endValue End value of the animation curve
  85731. * @param gradient Scalar amount to interpolate
  85732. * @returns Interpolated Size value
  85733. */
  85734. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85735. /**
  85736. * Interpolates a Color3 linearly
  85737. * @param startValue Start value of the animation curve
  85738. * @param endValue End value of the animation curve
  85739. * @param gradient Scalar amount to interpolate
  85740. * @returns Interpolated Color3 value
  85741. */
  85742. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85743. /**
  85744. * @hidden Internal use only
  85745. */
  85746. _getKeyValue(value: any): any;
  85747. /**
  85748. * @hidden Internal use only
  85749. */
  85750. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85751. /**
  85752. * Defines the function to use to interpolate matrices
  85753. * @param startValue defines the start matrix
  85754. * @param endValue defines the end matrix
  85755. * @param gradient defines the gradient between both matrices
  85756. * @param result defines an optional target matrix where to store the interpolation
  85757. * @returns the interpolated matrix
  85758. */
  85759. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85760. /**
  85761. * Makes a copy of the animation
  85762. * @returns Cloned animation
  85763. */
  85764. clone(): Animation;
  85765. /**
  85766. * Sets the key frames of the animation
  85767. * @param values The animation key frames to set
  85768. */
  85769. setKeys(values: Array<IAnimationKey>): void;
  85770. /**
  85771. * Serializes the animation to an object
  85772. * @returns Serialized object
  85773. */
  85774. serialize(): any;
  85775. /**
  85776. * Float animation type
  85777. */
  85778. private static _ANIMATIONTYPE_FLOAT;
  85779. /**
  85780. * Vector3 animation type
  85781. */
  85782. private static _ANIMATIONTYPE_VECTOR3;
  85783. /**
  85784. * Quaternion animation type
  85785. */
  85786. private static _ANIMATIONTYPE_QUATERNION;
  85787. /**
  85788. * Matrix animation type
  85789. */
  85790. private static _ANIMATIONTYPE_MATRIX;
  85791. /**
  85792. * Color3 animation type
  85793. */
  85794. private static _ANIMATIONTYPE_COLOR3;
  85795. /**
  85796. * Vector2 animation type
  85797. */
  85798. private static _ANIMATIONTYPE_VECTOR2;
  85799. /**
  85800. * Size animation type
  85801. */
  85802. private static _ANIMATIONTYPE_SIZE;
  85803. /**
  85804. * Relative Loop Mode
  85805. */
  85806. private static _ANIMATIONLOOPMODE_RELATIVE;
  85807. /**
  85808. * Cycle Loop Mode
  85809. */
  85810. private static _ANIMATIONLOOPMODE_CYCLE;
  85811. /**
  85812. * Constant Loop Mode
  85813. */
  85814. private static _ANIMATIONLOOPMODE_CONSTANT;
  85815. /**
  85816. * Get the float animation type
  85817. */
  85818. static readonly ANIMATIONTYPE_FLOAT: number;
  85819. /**
  85820. * Get the Vector3 animation type
  85821. */
  85822. static readonly ANIMATIONTYPE_VECTOR3: number;
  85823. /**
  85824. * Get the Vector2 animation type
  85825. */
  85826. static readonly ANIMATIONTYPE_VECTOR2: number;
  85827. /**
  85828. * Get the Size animation type
  85829. */
  85830. static readonly ANIMATIONTYPE_SIZE: number;
  85831. /**
  85832. * Get the Quaternion animation type
  85833. */
  85834. static readonly ANIMATIONTYPE_QUATERNION: number;
  85835. /**
  85836. * Get the Matrix animation type
  85837. */
  85838. static readonly ANIMATIONTYPE_MATRIX: number;
  85839. /**
  85840. * Get the Color3 animation type
  85841. */
  85842. static readonly ANIMATIONTYPE_COLOR3: number;
  85843. /**
  85844. * Get the Relative Loop Mode
  85845. */
  85846. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  85847. /**
  85848. * Get the Cycle Loop Mode
  85849. */
  85850. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  85851. /**
  85852. * Get the Constant Loop Mode
  85853. */
  85854. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  85855. /** @hidden */
  85856. static _UniversalLerp(left: any, right: any, amount: number): any;
  85857. /**
  85858. * Parses an animation object and creates an animation
  85859. * @param parsedAnimation Parsed animation object
  85860. * @returns Animation object
  85861. */
  85862. static Parse(parsedAnimation: any): Animation;
  85863. /**
  85864. * Appends the serialized animations from the source animations
  85865. * @param source Source containing the animations
  85866. * @param destination Target to store the animations
  85867. */
  85868. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85869. }
  85870. }
  85871. declare module BABYLON {
  85872. /**
  85873. * Base class of all the textures in babylon.
  85874. * It groups all the common properties the materials, post process, lights... might need
  85875. * in order to make a correct use of the texture.
  85876. */
  85877. export class BaseTexture implements IAnimatable {
  85878. /**
  85879. * Default anisotropic filtering level for the application.
  85880. * It is set to 4 as a good tradeoff between perf and quality.
  85881. */
  85882. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  85883. /**
  85884. * Gets or sets the unique id of the texture
  85885. */
  85886. uniqueId: number;
  85887. /**
  85888. * Define the name of the texture.
  85889. */
  85890. name: string;
  85891. /**
  85892. * Gets or sets an object used to store user defined information.
  85893. */
  85894. metadata: any;
  85895. /**
  85896. * For internal use only. Please do not use.
  85897. */
  85898. reservedDataStore: any;
  85899. private _hasAlpha;
  85900. /**
  85901. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  85902. */
  85903. hasAlpha: boolean;
  85904. /**
  85905. * Defines if the alpha value should be determined via the rgb values.
  85906. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  85907. */
  85908. getAlphaFromRGB: boolean;
  85909. /**
  85910. * Intensity or strength of the texture.
  85911. * It is commonly used by materials to fine tune the intensity of the texture
  85912. */
  85913. level: number;
  85914. /**
  85915. * Define the UV chanel to use starting from 0 and defaulting to 0.
  85916. * This is part of the texture as textures usually maps to one uv set.
  85917. */
  85918. coordinatesIndex: number;
  85919. private _coordinatesMode;
  85920. /**
  85921. * How a texture is mapped.
  85922. *
  85923. * | Value | Type | Description |
  85924. * | ----- | ----------------------------------- | ----------- |
  85925. * | 0 | EXPLICIT_MODE | |
  85926. * | 1 | SPHERICAL_MODE | |
  85927. * | 2 | PLANAR_MODE | |
  85928. * | 3 | CUBIC_MODE | |
  85929. * | 4 | PROJECTION_MODE | |
  85930. * | 5 | SKYBOX_MODE | |
  85931. * | 6 | INVCUBIC_MODE | |
  85932. * | 7 | EQUIRECTANGULAR_MODE | |
  85933. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85934. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85935. */
  85936. coordinatesMode: number;
  85937. /**
  85938. * | Value | Type | Description |
  85939. * | ----- | ------------------ | ----------- |
  85940. * | 0 | CLAMP_ADDRESSMODE | |
  85941. * | 1 | WRAP_ADDRESSMODE | |
  85942. * | 2 | MIRROR_ADDRESSMODE | |
  85943. */
  85944. wrapU: number;
  85945. /**
  85946. * | Value | Type | Description |
  85947. * | ----- | ------------------ | ----------- |
  85948. * | 0 | CLAMP_ADDRESSMODE | |
  85949. * | 1 | WRAP_ADDRESSMODE | |
  85950. * | 2 | MIRROR_ADDRESSMODE | |
  85951. */
  85952. wrapV: number;
  85953. /**
  85954. * | Value | Type | Description |
  85955. * | ----- | ------------------ | ----------- |
  85956. * | 0 | CLAMP_ADDRESSMODE | |
  85957. * | 1 | WRAP_ADDRESSMODE | |
  85958. * | 2 | MIRROR_ADDRESSMODE | |
  85959. */
  85960. wrapR: number;
  85961. /**
  85962. * With compliant hardware and browser (supporting anisotropic filtering)
  85963. * this defines the level of anisotropic filtering in the texture.
  85964. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85965. */
  85966. anisotropicFilteringLevel: number;
  85967. /**
  85968. * Define if the texture is a cube texture or if false a 2d texture.
  85969. */
  85970. isCube: boolean;
  85971. /**
  85972. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85973. */
  85974. is3D: boolean;
  85975. /**
  85976. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85977. * HDR texture are usually stored in linear space.
  85978. * This only impacts the PBR and Background materials
  85979. */
  85980. gammaSpace: boolean;
  85981. /**
  85982. * Gets whether or not the texture contains RGBD data.
  85983. */
  85984. readonly isRGBD: boolean;
  85985. /**
  85986. * Is Z inverted in the texture (useful in a cube texture).
  85987. */
  85988. invertZ: boolean;
  85989. /**
  85990. * Are mip maps generated for this texture or not.
  85991. */
  85992. readonly noMipmap: boolean;
  85993. /**
  85994. * @hidden
  85995. */
  85996. lodLevelInAlpha: boolean;
  85997. /**
  85998. * With prefiltered texture, defined the offset used during the prefiltering steps.
  85999. */
  86000. lodGenerationOffset: number;
  86001. /**
  86002. * With prefiltered texture, defined the scale used during the prefiltering steps.
  86003. */
  86004. lodGenerationScale: number;
  86005. /**
  86006. * Define if the texture is a render target.
  86007. */
  86008. isRenderTarget: boolean;
  86009. /**
  86010. * Define the unique id of the texture in the scene.
  86011. */
  86012. readonly uid: string;
  86013. /**
  86014. * Return a string representation of the texture.
  86015. * @returns the texture as a string
  86016. */
  86017. toString(): string;
  86018. /**
  86019. * Get the class name of the texture.
  86020. * @returns "BaseTexture"
  86021. */
  86022. getClassName(): string;
  86023. /**
  86024. * Define the list of animation attached to the texture.
  86025. */
  86026. animations: Animation[];
  86027. /**
  86028. * An event triggered when the texture is disposed.
  86029. */
  86030. onDisposeObservable: Observable<BaseTexture>;
  86031. private _onDisposeObserver;
  86032. /**
  86033. * Callback triggered when the texture has been disposed.
  86034. * Kept for back compatibility, you can use the onDisposeObservable instead.
  86035. */
  86036. onDispose: () => void;
  86037. /**
  86038. * Define the current state of the loading sequence when in delayed load mode.
  86039. */
  86040. delayLoadState: number;
  86041. private _scene;
  86042. /** @hidden */
  86043. _texture: Nullable<InternalTexture>;
  86044. private _uid;
  86045. /**
  86046. * Define if the texture is preventinga material to render or not.
  86047. * If not and the texture is not ready, the engine will use a default black texture instead.
  86048. */
  86049. readonly isBlocking: boolean;
  86050. /**
  86051. * Instantiates a new BaseTexture.
  86052. * Base class of all the textures in babylon.
  86053. * It groups all the common properties the materials, post process, lights... might need
  86054. * in order to make a correct use of the texture.
  86055. * @param scene Define the scene the texture blongs to
  86056. */
  86057. constructor(scene: Nullable<Scene>);
  86058. /**
  86059. * Get the scene the texture belongs to.
  86060. * @returns the scene or null if undefined
  86061. */
  86062. getScene(): Nullable<Scene>;
  86063. /**
  86064. * Get the texture transform matrix used to offset tile the texture for istance.
  86065. * @returns the transformation matrix
  86066. */
  86067. getTextureMatrix(): Matrix;
  86068. /**
  86069. * Get the texture reflection matrix used to rotate/transform the reflection.
  86070. * @returns the reflection matrix
  86071. */
  86072. getReflectionTextureMatrix(): Matrix;
  86073. /**
  86074. * Get the underlying lower level texture from Babylon.
  86075. * @returns the insternal texture
  86076. */
  86077. getInternalTexture(): Nullable<InternalTexture>;
  86078. /**
  86079. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  86080. * @returns true if ready or not blocking
  86081. */
  86082. isReadyOrNotBlocking(): boolean;
  86083. /**
  86084. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86085. * @returns true if fully ready
  86086. */
  86087. isReady(): boolean;
  86088. private _cachedSize;
  86089. /**
  86090. * Get the size of the texture.
  86091. * @returns the texture size.
  86092. */
  86093. getSize(): ISize;
  86094. /**
  86095. * Get the base size of the texture.
  86096. * It can be different from the size if the texture has been resized for POT for instance
  86097. * @returns the base size
  86098. */
  86099. getBaseSize(): ISize;
  86100. /**
  86101. * Update the sampling mode of the texture.
  86102. * Default is Trilinear mode.
  86103. *
  86104. * | Value | Type | Description |
  86105. * | ----- | ------------------ | ----------- |
  86106. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86107. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86108. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86109. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86110. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86111. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86112. * | 7 | NEAREST_LINEAR | |
  86113. * | 8 | NEAREST_NEAREST | |
  86114. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86115. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86116. * | 11 | LINEAR_LINEAR | |
  86117. * | 12 | LINEAR_NEAREST | |
  86118. *
  86119. * > _mag_: magnification filter (close to the viewer)
  86120. * > _min_: minification filter (far from the viewer)
  86121. * > _mip_: filter used between mip map levels
  86122. *@param samplingMode Define the new sampling mode of the texture
  86123. */
  86124. updateSamplingMode(samplingMode: number): void;
  86125. /**
  86126. * Scales the texture if is `canRescale()`
  86127. * @param ratio the resize factor we want to use to rescale
  86128. */
  86129. scale(ratio: number): void;
  86130. /**
  86131. * Get if the texture can rescale.
  86132. */
  86133. readonly canRescale: boolean;
  86134. /** @hidden */
  86135. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  86136. /** @hidden */
  86137. _rebuild(): void;
  86138. /**
  86139. * Triggers the load sequence in delayed load mode.
  86140. */
  86141. delayLoad(): void;
  86142. /**
  86143. * Clones the texture.
  86144. * @returns the cloned texture
  86145. */
  86146. clone(): Nullable<BaseTexture>;
  86147. /**
  86148. * Get the texture underlying type (INT, FLOAT...)
  86149. */
  86150. readonly textureType: number;
  86151. /**
  86152. * Get the texture underlying format (RGB, RGBA...)
  86153. */
  86154. readonly textureFormat: number;
  86155. /**
  86156. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  86157. * This will returns an RGBA array buffer containing either in values (0-255) or
  86158. * float values (0-1) depending of the underlying buffer type.
  86159. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  86160. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  86161. * @param buffer defines a user defined buffer to fill with data (can be null)
  86162. * @returns The Array buffer containing the pixels data.
  86163. */
  86164. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  86165. /**
  86166. * Release and destroy the underlying lower level texture aka internalTexture.
  86167. */
  86168. releaseInternalTexture(): void;
  86169. /**
  86170. * Get the polynomial representation of the texture data.
  86171. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  86172. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  86173. */
  86174. sphericalPolynomial: Nullable<SphericalPolynomial>;
  86175. /** @hidden */
  86176. readonly _lodTextureHigh: Nullable<BaseTexture>;
  86177. /** @hidden */
  86178. readonly _lodTextureMid: Nullable<BaseTexture>;
  86179. /** @hidden */
  86180. readonly _lodTextureLow: Nullable<BaseTexture>;
  86181. /**
  86182. * Dispose the texture and release its associated resources.
  86183. */
  86184. dispose(): void;
  86185. /**
  86186. * Serialize the texture into a JSON representation that can be parsed later on.
  86187. * @returns the JSON representation of the texture
  86188. */
  86189. serialize(): any;
  86190. /**
  86191. * Helper function to be called back once a list of texture contains only ready textures.
  86192. * @param textures Define the list of textures to wait for
  86193. * @param callback Define the callback triggered once the entire list will be ready
  86194. */
  86195. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  86196. }
  86197. }
  86198. declare module BABYLON {
  86199. /**
  86200. * Uniform buffer objects.
  86201. *
  86202. * Handles blocks of uniform on the GPU.
  86203. *
  86204. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86205. *
  86206. * For more information, please refer to :
  86207. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86208. */
  86209. export class UniformBuffer {
  86210. private _engine;
  86211. private _buffer;
  86212. private _data;
  86213. private _bufferData;
  86214. private _dynamic?;
  86215. private _uniformLocations;
  86216. private _uniformSizes;
  86217. private _uniformLocationPointer;
  86218. private _needSync;
  86219. private _noUBO;
  86220. private _currentEffect;
  86221. private static _MAX_UNIFORM_SIZE;
  86222. private static _tempBuffer;
  86223. /**
  86224. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86225. * This is dynamic to allow compat with webgl 1 and 2.
  86226. * You will need to pass the name of the uniform as well as the value.
  86227. */
  86228. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86229. /**
  86230. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86231. * This is dynamic to allow compat with webgl 1 and 2.
  86232. * You will need to pass the name of the uniform as well as the value.
  86233. */
  86234. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86235. /**
  86236. * Lambda to Update a single float in a uniform buffer.
  86237. * This is dynamic to allow compat with webgl 1 and 2.
  86238. * You will need to pass the name of the uniform as well as the value.
  86239. */
  86240. updateFloat: (name: string, x: number) => void;
  86241. /**
  86242. * Lambda to Update a vec2 of float in a uniform buffer.
  86243. * This is dynamic to allow compat with webgl 1 and 2.
  86244. * You will need to pass the name of the uniform as well as the value.
  86245. */
  86246. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86247. /**
  86248. * Lambda to Update a vec3 of float in a uniform buffer.
  86249. * This is dynamic to allow compat with webgl 1 and 2.
  86250. * You will need to pass the name of the uniform as well as the value.
  86251. */
  86252. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86253. /**
  86254. * Lambda to Update a vec4 of float in a uniform buffer.
  86255. * This is dynamic to allow compat with webgl 1 and 2.
  86256. * You will need to pass the name of the uniform as well as the value.
  86257. */
  86258. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86259. /**
  86260. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86261. * This is dynamic to allow compat with webgl 1 and 2.
  86262. * You will need to pass the name of the uniform as well as the value.
  86263. */
  86264. updateMatrix: (name: string, mat: Matrix) => void;
  86265. /**
  86266. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86267. * This is dynamic to allow compat with webgl 1 and 2.
  86268. * You will need to pass the name of the uniform as well as the value.
  86269. */
  86270. updateVector3: (name: string, vector: Vector3) => void;
  86271. /**
  86272. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86273. * This is dynamic to allow compat with webgl 1 and 2.
  86274. * You will need to pass the name of the uniform as well as the value.
  86275. */
  86276. updateVector4: (name: string, vector: Vector4) => void;
  86277. /**
  86278. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86279. * This is dynamic to allow compat with webgl 1 and 2.
  86280. * You will need to pass the name of the uniform as well as the value.
  86281. */
  86282. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86283. /**
  86284. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86285. * This is dynamic to allow compat with webgl 1 and 2.
  86286. * You will need to pass the name of the uniform as well as the value.
  86287. */
  86288. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86289. /**
  86290. * Instantiates a new Uniform buffer objects.
  86291. *
  86292. * Handles blocks of uniform on the GPU.
  86293. *
  86294. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86295. *
  86296. * For more information, please refer to :
  86297. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86298. * @param engine Define the engine the buffer is associated with
  86299. * @param data Define the data contained in the buffer
  86300. * @param dynamic Define if the buffer is updatable
  86301. */
  86302. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86303. /**
  86304. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86305. * or just falling back on setUniformXXX calls.
  86306. */
  86307. readonly useUbo: boolean;
  86308. /**
  86309. * Indicates if the WebGL underlying uniform buffer is in sync
  86310. * with the javascript cache data.
  86311. */
  86312. readonly isSync: boolean;
  86313. /**
  86314. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86315. * Also, a dynamic UniformBuffer will disable cache verification and always
  86316. * update the underlying WebGL uniform buffer to the GPU.
  86317. * @returns if Dynamic, otherwise false
  86318. */
  86319. isDynamic(): boolean;
  86320. /**
  86321. * The data cache on JS side.
  86322. * @returns the underlying data as a float array
  86323. */
  86324. getData(): Float32Array;
  86325. /**
  86326. * The underlying WebGL Uniform buffer.
  86327. * @returns the webgl buffer
  86328. */
  86329. getBuffer(): Nullable<DataBuffer>;
  86330. /**
  86331. * std140 layout specifies how to align data within an UBO structure.
  86332. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86333. * for specs.
  86334. */
  86335. private _fillAlignment;
  86336. /**
  86337. * Adds an uniform in the buffer.
  86338. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86339. * for the layout to be correct !
  86340. * @param name Name of the uniform, as used in the uniform block in the shader.
  86341. * @param size Data size, or data directly.
  86342. */
  86343. addUniform(name: string, size: number | number[]): void;
  86344. /**
  86345. * Adds a Matrix 4x4 to the uniform buffer.
  86346. * @param name Name of the uniform, as used in the uniform block in the shader.
  86347. * @param mat A 4x4 matrix.
  86348. */
  86349. addMatrix(name: string, mat: Matrix): void;
  86350. /**
  86351. * Adds a vec2 to the uniform buffer.
  86352. * @param name Name of the uniform, as used in the uniform block in the shader.
  86353. * @param x Define the x component value of the vec2
  86354. * @param y Define the y component value of the vec2
  86355. */
  86356. addFloat2(name: string, x: number, y: number): void;
  86357. /**
  86358. * Adds a vec3 to the uniform buffer.
  86359. * @param name Name of the uniform, as used in the uniform block in the shader.
  86360. * @param x Define the x component value of the vec3
  86361. * @param y Define the y component value of the vec3
  86362. * @param z Define the z component value of the vec3
  86363. */
  86364. addFloat3(name: string, x: number, y: number, z: number): void;
  86365. /**
  86366. * Adds a vec3 to the uniform buffer.
  86367. * @param name Name of the uniform, as used in the uniform block in the shader.
  86368. * @param color Define the vec3 from a Color
  86369. */
  86370. addColor3(name: string, color: Color3): void;
  86371. /**
  86372. * Adds a vec4 to the uniform buffer.
  86373. * @param name Name of the uniform, as used in the uniform block in the shader.
  86374. * @param color Define the rgb components from a Color
  86375. * @param alpha Define the a component of the vec4
  86376. */
  86377. addColor4(name: string, color: Color3, alpha: number): void;
  86378. /**
  86379. * Adds a vec3 to the uniform buffer.
  86380. * @param name Name of the uniform, as used in the uniform block in the shader.
  86381. * @param vector Define the vec3 components from a Vector
  86382. */
  86383. addVector3(name: string, vector: Vector3): void;
  86384. /**
  86385. * Adds a Matrix 3x3 to the uniform buffer.
  86386. * @param name Name of the uniform, as used in the uniform block in the shader.
  86387. */
  86388. addMatrix3x3(name: string): void;
  86389. /**
  86390. * Adds a Matrix 2x2 to the uniform buffer.
  86391. * @param name Name of the uniform, as used in the uniform block in the shader.
  86392. */
  86393. addMatrix2x2(name: string): void;
  86394. /**
  86395. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86396. */
  86397. create(): void;
  86398. /** @hidden */
  86399. _rebuild(): void;
  86400. /**
  86401. * Updates the WebGL Uniform Buffer on the GPU.
  86402. * If the `dynamic` flag is set to true, no cache comparison is done.
  86403. * Otherwise, the buffer will be updated only if the cache differs.
  86404. */
  86405. update(): void;
  86406. /**
  86407. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86408. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86409. * @param data Define the flattened data
  86410. * @param size Define the size of the data.
  86411. */
  86412. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86413. private _updateMatrix3x3ForUniform;
  86414. private _updateMatrix3x3ForEffect;
  86415. private _updateMatrix2x2ForEffect;
  86416. private _updateMatrix2x2ForUniform;
  86417. private _updateFloatForEffect;
  86418. private _updateFloatForUniform;
  86419. private _updateFloat2ForEffect;
  86420. private _updateFloat2ForUniform;
  86421. private _updateFloat3ForEffect;
  86422. private _updateFloat3ForUniform;
  86423. private _updateFloat4ForEffect;
  86424. private _updateFloat4ForUniform;
  86425. private _updateMatrixForEffect;
  86426. private _updateMatrixForUniform;
  86427. private _updateVector3ForEffect;
  86428. private _updateVector3ForUniform;
  86429. private _updateVector4ForEffect;
  86430. private _updateVector4ForUniform;
  86431. private _updateColor3ForEffect;
  86432. private _updateColor3ForUniform;
  86433. private _updateColor4ForEffect;
  86434. private _updateColor4ForUniform;
  86435. /**
  86436. * Sets a sampler uniform on the effect.
  86437. * @param name Define the name of the sampler.
  86438. * @param texture Define the texture to set in the sampler
  86439. */
  86440. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86441. /**
  86442. * Directly updates the value of the uniform in the cache AND on the GPU.
  86443. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86444. * @param data Define the flattened data
  86445. */
  86446. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86447. /**
  86448. * Binds this uniform buffer to an effect.
  86449. * @param effect Define the effect to bind the buffer to
  86450. * @param name Name of the uniform block in the shader.
  86451. */
  86452. bindToEffect(effect: Effect, name: string): void;
  86453. /**
  86454. * Disposes the uniform buffer.
  86455. */
  86456. dispose(): void;
  86457. }
  86458. }
  86459. declare module BABYLON {
  86460. /**
  86461. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86463. */
  86464. export class Analyser {
  86465. /**
  86466. * Gets or sets the smoothing
  86467. * @ignorenaming
  86468. */
  86469. SMOOTHING: number;
  86470. /**
  86471. * Gets or sets the FFT table size
  86472. * @ignorenaming
  86473. */
  86474. FFT_SIZE: number;
  86475. /**
  86476. * Gets or sets the bar graph amplitude
  86477. * @ignorenaming
  86478. */
  86479. BARGRAPHAMPLITUDE: number;
  86480. /**
  86481. * Gets or sets the position of the debug canvas
  86482. * @ignorenaming
  86483. */
  86484. DEBUGCANVASPOS: {
  86485. x: number;
  86486. y: number;
  86487. };
  86488. /**
  86489. * Gets or sets the debug canvas size
  86490. * @ignorenaming
  86491. */
  86492. DEBUGCANVASSIZE: {
  86493. width: number;
  86494. height: number;
  86495. };
  86496. private _byteFreqs;
  86497. private _byteTime;
  86498. private _floatFreqs;
  86499. private _webAudioAnalyser;
  86500. private _debugCanvas;
  86501. private _debugCanvasContext;
  86502. private _scene;
  86503. private _registerFunc;
  86504. private _audioEngine;
  86505. /**
  86506. * Creates a new analyser
  86507. * @param scene defines hosting scene
  86508. */
  86509. constructor(scene: Scene);
  86510. /**
  86511. * Get the number of data values you will have to play with for the visualization
  86512. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86513. * @returns a number
  86514. */
  86515. getFrequencyBinCount(): number;
  86516. /**
  86517. * Gets the current frequency data as a byte array
  86518. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86519. * @returns a Uint8Array
  86520. */
  86521. getByteFrequencyData(): Uint8Array;
  86522. /**
  86523. * Gets the current waveform as a byte array
  86524. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86525. * @returns a Uint8Array
  86526. */
  86527. getByteTimeDomainData(): Uint8Array;
  86528. /**
  86529. * Gets the current frequency data as a float array
  86530. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86531. * @returns a Float32Array
  86532. */
  86533. getFloatFrequencyData(): Float32Array;
  86534. /**
  86535. * Renders the debug canvas
  86536. */
  86537. drawDebugCanvas(): void;
  86538. /**
  86539. * Stops rendering the debug canvas and removes it
  86540. */
  86541. stopDebugCanvas(): void;
  86542. /**
  86543. * Connects two audio nodes
  86544. * @param inputAudioNode defines first node to connect
  86545. * @param outputAudioNode defines second node to connect
  86546. */
  86547. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86548. /**
  86549. * Releases all associated resources
  86550. */
  86551. dispose(): void;
  86552. }
  86553. }
  86554. declare module BABYLON {
  86555. /**
  86556. * This represents an audio engine and it is responsible
  86557. * to play, synchronize and analyse sounds throughout the application.
  86558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86559. */
  86560. export interface IAudioEngine extends IDisposable {
  86561. /**
  86562. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86563. */
  86564. readonly canUseWebAudio: boolean;
  86565. /**
  86566. * Gets the current AudioContext if available.
  86567. */
  86568. readonly audioContext: Nullable<AudioContext>;
  86569. /**
  86570. * The master gain node defines the global audio volume of your audio engine.
  86571. */
  86572. readonly masterGain: GainNode;
  86573. /**
  86574. * Gets whether or not mp3 are supported by your browser.
  86575. */
  86576. readonly isMP3supported: boolean;
  86577. /**
  86578. * Gets whether or not ogg are supported by your browser.
  86579. */
  86580. readonly isOGGsupported: boolean;
  86581. /**
  86582. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86583. * @ignoreNaming
  86584. */
  86585. WarnedWebAudioUnsupported: boolean;
  86586. /**
  86587. * Defines if the audio engine relies on a custom unlocked button.
  86588. * In this case, the embedded button will not be displayed.
  86589. */
  86590. useCustomUnlockedButton: boolean;
  86591. /**
  86592. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86593. */
  86594. readonly unlocked: boolean;
  86595. /**
  86596. * Event raised when audio has been unlocked on the browser.
  86597. */
  86598. onAudioUnlockedObservable: Observable<AudioEngine>;
  86599. /**
  86600. * Event raised when audio has been locked on the browser.
  86601. */
  86602. onAudioLockedObservable: Observable<AudioEngine>;
  86603. /**
  86604. * Flags the audio engine in Locked state.
  86605. * This happens due to new browser policies preventing audio to autoplay.
  86606. */
  86607. lock(): void;
  86608. /**
  86609. * Unlocks the audio engine once a user action has been done on the dom.
  86610. * This is helpful to resume play once browser policies have been satisfied.
  86611. */
  86612. unlock(): void;
  86613. }
  86614. /**
  86615. * This represents the default audio engine used in babylon.
  86616. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86618. */
  86619. export class AudioEngine implements IAudioEngine {
  86620. private _audioContext;
  86621. private _audioContextInitialized;
  86622. private _muteButton;
  86623. private _hostElement;
  86624. /**
  86625. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86626. */
  86627. canUseWebAudio: boolean;
  86628. /**
  86629. * The master gain node defines the global audio volume of your audio engine.
  86630. */
  86631. masterGain: GainNode;
  86632. /**
  86633. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86634. * @ignoreNaming
  86635. */
  86636. WarnedWebAudioUnsupported: boolean;
  86637. /**
  86638. * Gets whether or not mp3 are supported by your browser.
  86639. */
  86640. isMP3supported: boolean;
  86641. /**
  86642. * Gets whether or not ogg are supported by your browser.
  86643. */
  86644. isOGGsupported: boolean;
  86645. /**
  86646. * Gets whether audio has been unlocked on the device.
  86647. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86648. * a user interaction has happened.
  86649. */
  86650. unlocked: boolean;
  86651. /**
  86652. * Defines if the audio engine relies on a custom unlocked button.
  86653. * In this case, the embedded button will not be displayed.
  86654. */
  86655. useCustomUnlockedButton: boolean;
  86656. /**
  86657. * Event raised when audio has been unlocked on the browser.
  86658. */
  86659. onAudioUnlockedObservable: Observable<AudioEngine>;
  86660. /**
  86661. * Event raised when audio has been locked on the browser.
  86662. */
  86663. onAudioLockedObservable: Observable<AudioEngine>;
  86664. /**
  86665. * Gets the current AudioContext if available.
  86666. */
  86667. readonly audioContext: Nullable<AudioContext>;
  86668. private _connectedAnalyser;
  86669. /**
  86670. * Instantiates a new audio engine.
  86671. *
  86672. * There should be only one per page as some browsers restrict the number
  86673. * of audio contexts you can create.
  86674. * @param hostElement defines the host element where to display the mute icon if necessary
  86675. */
  86676. constructor(hostElement?: Nullable<HTMLElement>);
  86677. /**
  86678. * Flags the audio engine in Locked state.
  86679. * This happens due to new browser policies preventing audio to autoplay.
  86680. */
  86681. lock(): void;
  86682. /**
  86683. * Unlocks the audio engine once a user action has been done on the dom.
  86684. * This is helpful to resume play once browser policies have been satisfied.
  86685. */
  86686. unlock(): void;
  86687. private _resumeAudioContext;
  86688. private _initializeAudioContext;
  86689. private _tryToRun;
  86690. private _triggerRunningState;
  86691. private _triggerSuspendedState;
  86692. private _displayMuteButton;
  86693. private _moveButtonToTopLeft;
  86694. private _onResize;
  86695. private _hideMuteButton;
  86696. /**
  86697. * Destroy and release the resources associated with the audio ccontext.
  86698. */
  86699. dispose(): void;
  86700. /**
  86701. * Gets the global volume sets on the master gain.
  86702. * @returns the global volume if set or -1 otherwise
  86703. */
  86704. getGlobalVolume(): number;
  86705. /**
  86706. * Sets the global volume of your experience (sets on the master gain).
  86707. * @param newVolume Defines the new global volume of the application
  86708. */
  86709. setGlobalVolume(newVolume: number): void;
  86710. /**
  86711. * Connect the audio engine to an audio analyser allowing some amazing
  86712. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86714. * @param analyser The analyser to connect to the engine
  86715. */
  86716. connectToAnalyser(analyser: Analyser): void;
  86717. }
  86718. }
  86719. declare module BABYLON {
  86720. /**
  86721. * Interface used to present a loading screen while loading a scene
  86722. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86723. */
  86724. export interface ILoadingScreen {
  86725. /**
  86726. * Function called to display the loading screen
  86727. */
  86728. displayLoadingUI: () => void;
  86729. /**
  86730. * Function called to hide the loading screen
  86731. */
  86732. hideLoadingUI: () => void;
  86733. /**
  86734. * Gets or sets the color to use for the background
  86735. */
  86736. loadingUIBackgroundColor: string;
  86737. /**
  86738. * Gets or sets the text to display while loading
  86739. */
  86740. loadingUIText: string;
  86741. }
  86742. /**
  86743. * Class used for the default loading screen
  86744. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86745. */
  86746. export class DefaultLoadingScreen implements ILoadingScreen {
  86747. private _renderingCanvas;
  86748. private _loadingText;
  86749. private _loadingDivBackgroundColor;
  86750. private _loadingDiv;
  86751. private _loadingTextDiv;
  86752. /**
  86753. * Creates a new default loading screen
  86754. * @param _renderingCanvas defines the canvas used to render the scene
  86755. * @param _loadingText defines the default text to display
  86756. * @param _loadingDivBackgroundColor defines the default background color
  86757. */
  86758. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86759. /**
  86760. * Function called to display the loading screen
  86761. */
  86762. displayLoadingUI(): void;
  86763. /**
  86764. * Function called to hide the loading screen
  86765. */
  86766. hideLoadingUI(): void;
  86767. /**
  86768. * Gets or sets the text to display while loading
  86769. */
  86770. loadingUIText: string;
  86771. /**
  86772. * Gets or sets the color to use for the background
  86773. */
  86774. loadingUIBackgroundColor: string;
  86775. private _resizeLoadingUI;
  86776. }
  86777. }
  86778. declare module BABYLON {
  86779. /** @hidden */
  86780. export class WebGLPipelineContext implements IPipelineContext {
  86781. engine: Engine;
  86782. program: Nullable<WebGLProgram>;
  86783. context?: WebGLRenderingContext;
  86784. vertexShader?: WebGLShader;
  86785. fragmentShader?: WebGLShader;
  86786. isParallelCompiled: boolean;
  86787. onCompiled?: () => void;
  86788. transformFeedback?: WebGLTransformFeedback | null;
  86789. readonly isAsync: boolean;
  86790. readonly isReady: boolean;
  86791. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86792. }
  86793. }
  86794. declare module BABYLON {
  86795. /** @hidden */
  86796. export class WebGLDataBuffer extends DataBuffer {
  86797. private _buffer;
  86798. constructor(resource: WebGLBuffer);
  86799. readonly underlyingResource: any;
  86800. }
  86801. }
  86802. declare module BABYLON {
  86803. /**
  86804. * Settings for finer control over video usage
  86805. */
  86806. export interface VideoTextureSettings {
  86807. /**
  86808. * Applies `autoplay` to video, if specified
  86809. */
  86810. autoPlay?: boolean;
  86811. /**
  86812. * Applies `loop` to video, if specified
  86813. */
  86814. loop?: boolean;
  86815. /**
  86816. * Automatically updates internal texture from video at every frame in the render loop
  86817. */
  86818. autoUpdateTexture: boolean;
  86819. /**
  86820. * Image src displayed during the video loading or until the user interacts with the video.
  86821. */
  86822. poster?: string;
  86823. }
  86824. /**
  86825. * If you want to display a video in your scene, this is the special texture for that.
  86826. * This special texture works similar to other textures, with the exception of a few parameters.
  86827. * @see https://doc.babylonjs.com/how_to/video_texture
  86828. */
  86829. export class VideoTexture extends Texture {
  86830. /**
  86831. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86832. */
  86833. readonly autoUpdateTexture: boolean;
  86834. /**
  86835. * The video instance used by the texture internally
  86836. */
  86837. readonly video: HTMLVideoElement;
  86838. private _onUserActionRequestedObservable;
  86839. /**
  86840. * Event triggerd when a dom action is required by the user to play the video.
  86841. * This happens due to recent changes in browser policies preventing video to auto start.
  86842. */
  86843. readonly onUserActionRequestedObservable: Observable<Texture>;
  86844. private _generateMipMaps;
  86845. private _engine;
  86846. private _stillImageCaptured;
  86847. private _displayingPosterTexture;
  86848. private _settings;
  86849. private _createInternalTextureOnEvent;
  86850. /**
  86851. * Creates a video texture.
  86852. * If you want to display a video in your scene, this is the special texture for that.
  86853. * This special texture works similar to other textures, with the exception of a few parameters.
  86854. * @see https://doc.babylonjs.com/how_to/video_texture
  86855. * @param name optional name, will detect from video source, if not defined
  86856. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86857. * @param scene is obviously the current scene.
  86858. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86859. * @param invertY is false by default but can be used to invert video on Y axis
  86860. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86861. * @param settings allows finer control over video usage
  86862. */
  86863. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86864. private _getName;
  86865. private _getVideo;
  86866. private _createInternalTexture;
  86867. private reset;
  86868. /**
  86869. * @hidden Internal method to initiate `update`.
  86870. */
  86871. _rebuild(): void;
  86872. /**
  86873. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86874. */
  86875. update(): void;
  86876. /**
  86877. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86878. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86879. */
  86880. updateTexture(isVisible: boolean): void;
  86881. protected _updateInternalTexture: () => void;
  86882. /**
  86883. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86884. * @param url New url.
  86885. */
  86886. updateURL(url: string): void;
  86887. /**
  86888. * Dispose the texture and release its associated resources.
  86889. */
  86890. dispose(): void;
  86891. /**
  86892. * Creates a video texture straight from a stream.
  86893. * @param scene Define the scene the texture should be created in
  86894. * @param stream Define the stream the texture should be created from
  86895. * @returns The created video texture as a promise
  86896. */
  86897. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86898. /**
  86899. * Creates a video texture straight from your WebCam video feed.
  86900. * @param scene Define the scene the texture should be created in
  86901. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86902. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86903. * @returns The created video texture as a promise
  86904. */
  86905. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86906. minWidth: number;
  86907. maxWidth: number;
  86908. minHeight: number;
  86909. maxHeight: number;
  86910. deviceId: string;
  86911. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86912. /**
  86913. * Creates a video texture straight from your WebCam video feed.
  86914. * @param scene Define the scene the texture should be created in
  86915. * @param onReady Define a callback to triggered once the texture will be ready
  86916. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86917. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86918. */
  86919. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86920. minWidth: number;
  86921. maxWidth: number;
  86922. minHeight: number;
  86923. maxHeight: number;
  86924. deviceId: string;
  86925. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86926. }
  86927. }
  86928. declare module BABYLON {
  86929. /**
  86930. * Interface for attribute information associated with buffer instanciation
  86931. */
  86932. export class InstancingAttributeInfo {
  86933. /**
  86934. * Index/offset of the attribute in the vertex shader
  86935. */
  86936. index: number;
  86937. /**
  86938. * size of the attribute, 1, 2, 3 or 4
  86939. */
  86940. attributeSize: number;
  86941. /**
  86942. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86943. * default is FLOAT
  86944. */
  86945. attribyteType: number;
  86946. /**
  86947. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86948. */
  86949. normalized: boolean;
  86950. /**
  86951. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86952. */
  86953. offset: number;
  86954. /**
  86955. * Name of the GLSL attribute, for debugging purpose only
  86956. */
  86957. attributeName: string;
  86958. }
  86959. /**
  86960. * Define options used to create a depth texture
  86961. */
  86962. export class DepthTextureCreationOptions {
  86963. /** Specifies whether or not a stencil should be allocated in the texture */
  86964. generateStencil?: boolean;
  86965. /** Specifies whether or not bilinear filtering is enable on the texture */
  86966. bilinearFiltering?: boolean;
  86967. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86968. comparisonFunction?: number;
  86969. /** Specifies if the created texture is a cube texture */
  86970. isCube?: boolean;
  86971. }
  86972. /**
  86973. * Class used to describe the capabilities of the engine relatively to the current browser
  86974. */
  86975. export class EngineCapabilities {
  86976. /** Maximum textures units per fragment shader */
  86977. maxTexturesImageUnits: number;
  86978. /** Maximum texture units per vertex shader */
  86979. maxVertexTextureImageUnits: number;
  86980. /** Maximum textures units in the entire pipeline */
  86981. maxCombinedTexturesImageUnits: number;
  86982. /** Maximum texture size */
  86983. maxTextureSize: number;
  86984. /** Maximum cube texture size */
  86985. maxCubemapTextureSize: number;
  86986. /** Maximum render texture size */
  86987. maxRenderTextureSize: number;
  86988. /** Maximum number of vertex attributes */
  86989. maxVertexAttribs: number;
  86990. /** Maximum number of varyings */
  86991. maxVaryingVectors: number;
  86992. /** Maximum number of uniforms per vertex shader */
  86993. maxVertexUniformVectors: number;
  86994. /** Maximum number of uniforms per fragment shader */
  86995. maxFragmentUniformVectors: number;
  86996. /** Defines if standard derivates (dx/dy) are supported */
  86997. standardDerivatives: boolean;
  86998. /** Defines if s3tc texture compression is supported */
  86999. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  87000. /** Defines if pvrtc texture compression is supported */
  87001. pvrtc: any;
  87002. /** Defines if etc1 texture compression is supported */
  87003. etc1: any;
  87004. /** Defines if etc2 texture compression is supported */
  87005. etc2: any;
  87006. /** Defines if astc texture compression is supported */
  87007. astc: any;
  87008. /** Defines if float textures are supported */
  87009. textureFloat: boolean;
  87010. /** Defines if vertex array objects are supported */
  87011. vertexArrayObject: boolean;
  87012. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  87013. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  87014. /** Gets the maximum level of anisotropy supported */
  87015. maxAnisotropy: number;
  87016. /** Defines if instancing is supported */
  87017. instancedArrays: boolean;
  87018. /** Defines if 32 bits indices are supported */
  87019. uintIndices: boolean;
  87020. /** Defines if high precision shaders are supported */
  87021. highPrecisionShaderSupported: boolean;
  87022. /** Defines if depth reading in the fragment shader is supported */
  87023. fragmentDepthSupported: boolean;
  87024. /** Defines if float texture linear filtering is supported*/
  87025. textureFloatLinearFiltering: boolean;
  87026. /** Defines if rendering to float textures is supported */
  87027. textureFloatRender: boolean;
  87028. /** Defines if half float textures are supported*/
  87029. textureHalfFloat: boolean;
  87030. /** Defines if half float texture linear filtering is supported*/
  87031. textureHalfFloatLinearFiltering: boolean;
  87032. /** Defines if rendering to half float textures is supported */
  87033. textureHalfFloatRender: boolean;
  87034. /** Defines if textureLOD shader command is supported */
  87035. textureLOD: boolean;
  87036. /** Defines if draw buffers extension is supported */
  87037. drawBuffersExtension: boolean;
  87038. /** Defines if depth textures are supported */
  87039. depthTextureExtension: boolean;
  87040. /** Defines if float color buffer are supported */
  87041. colorBufferFloat: boolean;
  87042. /** Gets disjoint timer query extension (null if not supported) */
  87043. timerQuery: EXT_disjoint_timer_query;
  87044. /** Defines if timestamp can be used with timer query */
  87045. canUseTimestampForTimerQuery: boolean;
  87046. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  87047. multiview: any;
  87048. /** Function used to let the system compiles shaders in background */
  87049. parallelShaderCompile: {
  87050. COMPLETION_STATUS_KHR: number;
  87051. };
  87052. }
  87053. /** Interface defining initialization parameters for Engine class */
  87054. export interface EngineOptions extends WebGLContextAttributes {
  87055. /**
  87056. * Defines if the engine should no exceed a specified device ratio
  87057. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  87058. */
  87059. limitDeviceRatio?: number;
  87060. /**
  87061. * Defines if webvr should be enabled automatically
  87062. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87063. */
  87064. autoEnableWebVR?: boolean;
  87065. /**
  87066. * Defines if webgl2 should be turned off even if supported
  87067. * @see http://doc.babylonjs.com/features/webgl2
  87068. */
  87069. disableWebGL2Support?: boolean;
  87070. /**
  87071. * Defines if webaudio should be initialized as well
  87072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87073. */
  87074. audioEngine?: boolean;
  87075. /**
  87076. * Defines if animations should run using a deterministic lock step
  87077. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87078. */
  87079. deterministicLockstep?: boolean;
  87080. /** Defines the maximum steps to use with deterministic lock step mode */
  87081. lockstepMaxSteps?: number;
  87082. /**
  87083. * Defines that engine should ignore context lost events
  87084. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  87085. */
  87086. doNotHandleContextLost?: boolean;
  87087. /**
  87088. * Defines that engine should ignore modifying touch action attribute and style
  87089. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  87090. */
  87091. doNotHandleTouchAction?: boolean;
  87092. /**
  87093. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  87094. */
  87095. useHighPrecisionFloats?: boolean;
  87096. }
  87097. /**
  87098. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  87099. */
  87100. export class Engine {
  87101. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  87102. static ExceptionList: ({
  87103. key: string;
  87104. capture: string;
  87105. captureConstraint: number;
  87106. targets: string[];
  87107. } | {
  87108. key: string;
  87109. capture: null;
  87110. captureConstraint: null;
  87111. targets: string[];
  87112. })[];
  87113. /** Gets the list of created engines */
  87114. static readonly Instances: Engine[];
  87115. /**
  87116. * Gets the latest created engine
  87117. */
  87118. static readonly LastCreatedEngine: Nullable<Engine>;
  87119. /**
  87120. * Gets the latest created scene
  87121. */
  87122. static readonly LastCreatedScene: Nullable<Scene>;
  87123. /**
  87124. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  87125. * @param flag defines which part of the materials must be marked as dirty
  87126. * @param predicate defines a predicate used to filter which materials should be affected
  87127. */
  87128. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  87129. /**
  87130. * Hidden
  87131. */
  87132. static _TextureLoaders: IInternalTextureLoader[];
  87133. /** Defines that alpha blending is disabled */
  87134. static readonly ALPHA_DISABLE: number;
  87135. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  87136. static readonly ALPHA_ADD: number;
  87137. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  87138. static readonly ALPHA_COMBINE: number;
  87139. /** Defines that alpha blending to DEST - SRC * DEST */
  87140. static readonly ALPHA_SUBTRACT: number;
  87141. /** Defines that alpha blending to SRC * DEST */
  87142. static readonly ALPHA_MULTIPLY: number;
  87143. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  87144. static readonly ALPHA_MAXIMIZED: number;
  87145. /** Defines that alpha blending to SRC + DEST */
  87146. static readonly ALPHA_ONEONE: number;
  87147. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  87148. static readonly ALPHA_PREMULTIPLIED: number;
  87149. /**
  87150. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  87151. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  87152. */
  87153. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  87154. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  87155. static readonly ALPHA_INTERPOLATE: number;
  87156. /**
  87157. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  87158. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  87159. */
  87160. static readonly ALPHA_SCREENMODE: number;
  87161. /** Defines that the ressource is not delayed*/
  87162. static readonly DELAYLOADSTATE_NONE: number;
  87163. /** Defines that the ressource was successfully delay loaded */
  87164. static readonly DELAYLOADSTATE_LOADED: number;
  87165. /** Defines that the ressource is currently delay loading */
  87166. static readonly DELAYLOADSTATE_LOADING: number;
  87167. /** Defines that the ressource is delayed and has not started loading */
  87168. static readonly DELAYLOADSTATE_NOTLOADED: number;
  87169. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  87170. static readonly NEVER: number;
  87171. /** 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 */
  87172. static readonly ALWAYS: number;
  87173. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  87174. static readonly LESS: number;
  87175. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  87176. static readonly EQUAL: number;
  87177. /** 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 */
  87178. static readonly LEQUAL: number;
  87179. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  87180. static readonly GREATER: number;
  87181. /** 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 */
  87182. static readonly GEQUAL: number;
  87183. /** 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 */
  87184. static readonly NOTEQUAL: number;
  87185. /** Passed to stencilOperation to specify that stencil value must be kept */
  87186. static readonly KEEP: number;
  87187. /** Passed to stencilOperation to specify that stencil value must be replaced */
  87188. static readonly REPLACE: number;
  87189. /** Passed to stencilOperation to specify that stencil value must be incremented */
  87190. static readonly INCR: number;
  87191. /** Passed to stencilOperation to specify that stencil value must be decremented */
  87192. static readonly DECR: number;
  87193. /** Passed to stencilOperation to specify that stencil value must be inverted */
  87194. static readonly INVERT: number;
  87195. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  87196. static readonly INCR_WRAP: number;
  87197. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  87198. static readonly DECR_WRAP: number;
  87199. /** Texture is not repeating outside of 0..1 UVs */
  87200. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  87201. /** Texture is repeating outside of 0..1 UVs */
  87202. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  87203. /** Texture is repeating and mirrored */
  87204. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  87205. /** ALPHA */
  87206. static readonly TEXTUREFORMAT_ALPHA: number;
  87207. /** LUMINANCE */
  87208. static readonly TEXTUREFORMAT_LUMINANCE: number;
  87209. /** LUMINANCE_ALPHA */
  87210. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  87211. /** RGB */
  87212. static readonly TEXTUREFORMAT_RGB: number;
  87213. /** RGBA */
  87214. static readonly TEXTUREFORMAT_RGBA: number;
  87215. /** RED */
  87216. static readonly TEXTUREFORMAT_RED: number;
  87217. /** RED (2nd reference) */
  87218. static readonly TEXTUREFORMAT_R: number;
  87219. /** RG */
  87220. static readonly TEXTUREFORMAT_RG: number;
  87221. /** RED_INTEGER */
  87222. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  87223. /** RED_INTEGER (2nd reference) */
  87224. static readonly TEXTUREFORMAT_R_INTEGER: number;
  87225. /** RG_INTEGER */
  87226. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  87227. /** RGB_INTEGER */
  87228. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  87229. /** RGBA_INTEGER */
  87230. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  87231. /** UNSIGNED_BYTE */
  87232. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  87233. /** UNSIGNED_BYTE (2nd reference) */
  87234. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  87235. /** FLOAT */
  87236. static readonly TEXTURETYPE_FLOAT: number;
  87237. /** HALF_FLOAT */
  87238. static readonly TEXTURETYPE_HALF_FLOAT: number;
  87239. /** BYTE */
  87240. static readonly TEXTURETYPE_BYTE: number;
  87241. /** SHORT */
  87242. static readonly TEXTURETYPE_SHORT: number;
  87243. /** UNSIGNED_SHORT */
  87244. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  87245. /** INT */
  87246. static readonly TEXTURETYPE_INT: number;
  87247. /** UNSIGNED_INT */
  87248. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  87249. /** UNSIGNED_SHORT_4_4_4_4 */
  87250. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  87251. /** UNSIGNED_SHORT_5_5_5_1 */
  87252. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  87253. /** UNSIGNED_SHORT_5_6_5 */
  87254. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  87255. /** UNSIGNED_INT_2_10_10_10_REV */
  87256. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  87257. /** UNSIGNED_INT_24_8 */
  87258. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  87259. /** UNSIGNED_INT_10F_11F_11F_REV */
  87260. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  87261. /** UNSIGNED_INT_5_9_9_9_REV */
  87262. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  87263. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  87264. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  87265. /** nearest is mag = nearest and min = nearest and mip = linear */
  87266. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  87267. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87268. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  87269. /** Trilinear is mag = linear and min = linear and mip = linear */
  87270. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  87271. /** nearest is mag = nearest and min = nearest and mip = linear */
  87272. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  87273. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87274. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  87275. /** Trilinear is mag = linear and min = linear and mip = linear */
  87276. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  87277. /** mag = nearest and min = nearest and mip = nearest */
  87278. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  87279. /** mag = nearest and min = linear and mip = nearest */
  87280. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  87281. /** mag = nearest and min = linear and mip = linear */
  87282. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  87283. /** mag = nearest and min = linear and mip = none */
  87284. static readonly TEXTURE_NEAREST_LINEAR: number;
  87285. /** mag = nearest and min = nearest and mip = none */
  87286. static readonly TEXTURE_NEAREST_NEAREST: number;
  87287. /** mag = linear and min = nearest and mip = nearest */
  87288. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  87289. /** mag = linear and min = nearest and mip = linear */
  87290. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  87291. /** mag = linear and min = linear and mip = none */
  87292. static readonly TEXTURE_LINEAR_LINEAR: number;
  87293. /** mag = linear and min = nearest and mip = none */
  87294. static readonly TEXTURE_LINEAR_NEAREST: number;
  87295. /** Explicit coordinates mode */
  87296. static readonly TEXTURE_EXPLICIT_MODE: number;
  87297. /** Spherical coordinates mode */
  87298. static readonly TEXTURE_SPHERICAL_MODE: number;
  87299. /** Planar coordinates mode */
  87300. static readonly TEXTURE_PLANAR_MODE: number;
  87301. /** Cubic coordinates mode */
  87302. static readonly TEXTURE_CUBIC_MODE: number;
  87303. /** Projection coordinates mode */
  87304. static readonly TEXTURE_PROJECTION_MODE: number;
  87305. /** Skybox coordinates mode */
  87306. static readonly TEXTURE_SKYBOX_MODE: number;
  87307. /** Inverse Cubic coordinates mode */
  87308. static readonly TEXTURE_INVCUBIC_MODE: number;
  87309. /** Equirectangular coordinates mode */
  87310. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  87311. /** Equirectangular Fixed coordinates mode */
  87312. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  87313. /** Equirectangular Fixed Mirrored coordinates mode */
  87314. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87315. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  87316. static readonly SCALEMODE_FLOOR: number;
  87317. /** Defines that texture rescaling will look for the nearest power of 2 size */
  87318. static readonly SCALEMODE_NEAREST: number;
  87319. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  87320. static readonly SCALEMODE_CEILING: number;
  87321. /**
  87322. * Returns the current npm package of the sdk
  87323. */
  87324. static readonly NpmPackage: string;
  87325. /**
  87326. * Returns the current version of the framework
  87327. */
  87328. static readonly Version: string;
  87329. /**
  87330. * Returns a string describing the current engine
  87331. */
  87332. readonly description: string;
  87333. /**
  87334. * Gets or sets the epsilon value used by collision engine
  87335. */
  87336. static CollisionsEpsilon: number;
  87337. /**
  87338. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87339. */
  87340. static ShadersRepository: string;
  87341. /**
  87342. * Method called to create the default loading screen.
  87343. * This can be overriden in your own app.
  87344. * @param canvas The rendering canvas element
  87345. * @returns The loading screen
  87346. */
  87347. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  87348. /**
  87349. * Method called to create the default rescale post process on each engine.
  87350. */
  87351. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  87352. /**
  87353. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  87354. */
  87355. forcePOTTextures: boolean;
  87356. /**
  87357. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  87358. */
  87359. isFullscreen: boolean;
  87360. /**
  87361. * Gets a boolean indicating if the pointer is currently locked
  87362. */
  87363. isPointerLock: boolean;
  87364. /**
  87365. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  87366. */
  87367. cullBackFaces: boolean;
  87368. /**
  87369. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  87370. */
  87371. renderEvenInBackground: boolean;
  87372. /**
  87373. * Gets or sets a boolean indicating that cache can be kept between frames
  87374. */
  87375. preventCacheWipeBetweenFrames: boolean;
  87376. /**
  87377. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  87378. **/
  87379. enableOfflineSupport: boolean;
  87380. /**
  87381. * 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)
  87382. **/
  87383. disableManifestCheck: boolean;
  87384. /**
  87385. * Gets the list of created scenes
  87386. */
  87387. scenes: Scene[];
  87388. /**
  87389. * Event raised when a new scene is created
  87390. */
  87391. onNewSceneAddedObservable: Observable<Scene>;
  87392. /**
  87393. * Gets the list of created postprocesses
  87394. */
  87395. postProcesses: PostProcess[];
  87396. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  87397. validateShaderPrograms: boolean;
  87398. /**
  87399. * Observable event triggered each time the rendering canvas is resized
  87400. */
  87401. onResizeObservable: Observable<Engine>;
  87402. /**
  87403. * Observable event triggered each time the canvas loses focus
  87404. */
  87405. onCanvasBlurObservable: Observable<Engine>;
  87406. /**
  87407. * Observable event triggered each time the canvas gains focus
  87408. */
  87409. onCanvasFocusObservable: Observable<Engine>;
  87410. /**
  87411. * Observable event triggered each time the canvas receives pointerout event
  87412. */
  87413. onCanvasPointerOutObservable: Observable<PointerEvent>;
  87414. /**
  87415. * Observable event triggered before each texture is initialized
  87416. */
  87417. onBeforeTextureInitObservable: Observable<Texture>;
  87418. /**
  87419. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  87420. */
  87421. disableUniformBuffers: boolean;
  87422. /** @hidden */
  87423. _uniformBuffers: UniformBuffer[];
  87424. /**
  87425. * Gets a boolean indicating that the engine supports uniform buffers
  87426. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87427. */
  87428. readonly supportsUniformBuffers: boolean;
  87429. /**
  87430. * Observable raised when the engine begins a new frame
  87431. */
  87432. onBeginFrameObservable: Observable<Engine>;
  87433. /**
  87434. * If set, will be used to request the next animation frame for the render loop
  87435. */
  87436. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  87437. /**
  87438. * Observable raised when the engine ends the current frame
  87439. */
  87440. onEndFrameObservable: Observable<Engine>;
  87441. /**
  87442. * Observable raised when the engine is about to compile a shader
  87443. */
  87444. onBeforeShaderCompilationObservable: Observable<Engine>;
  87445. /**
  87446. * Observable raised when the engine has jsut compiled a shader
  87447. */
  87448. onAfterShaderCompilationObservable: Observable<Engine>;
  87449. /** @hidden */
  87450. _gl: WebGLRenderingContext;
  87451. private _renderingCanvas;
  87452. private _windowIsBackground;
  87453. private _webGLVersion;
  87454. protected _highPrecisionShadersAllowed: boolean;
  87455. /** @hidden */
  87456. readonly _shouldUseHighPrecisionShader: boolean;
  87457. /**
  87458. * Gets a boolean indicating that only power of 2 textures are supported
  87459. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87460. */
  87461. readonly needPOTTextures: boolean;
  87462. /** @hidden */
  87463. _badOS: boolean;
  87464. /** @hidden */
  87465. _badDesktopOS: boolean;
  87466. /**
  87467. * Gets the audio engine
  87468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87469. * @ignorenaming
  87470. */
  87471. static audioEngine: IAudioEngine;
  87472. /**
  87473. * Default AudioEngine factory responsible of creating the Audio Engine.
  87474. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87475. */
  87476. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87477. /**
  87478. * Default offline support factory responsible of creating a tool used to store data locally.
  87479. * By default, this will create a Database object if the workload has been embedded.
  87480. */
  87481. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87482. private _onFocus;
  87483. private _onBlur;
  87484. private _onCanvasPointerOut;
  87485. private _onCanvasBlur;
  87486. private _onCanvasFocus;
  87487. private _onFullscreenChange;
  87488. private _onPointerLockChange;
  87489. private _hardwareScalingLevel;
  87490. /** @hidden */
  87491. _caps: EngineCapabilities;
  87492. private _pointerLockRequested;
  87493. private _isStencilEnable;
  87494. private _colorWrite;
  87495. private _loadingScreen;
  87496. /** @hidden */
  87497. _drawCalls: PerfCounter;
  87498. private _glVersion;
  87499. private _glRenderer;
  87500. private _glVendor;
  87501. private _videoTextureSupported;
  87502. private _renderingQueueLaunched;
  87503. private _activeRenderLoops;
  87504. private _deterministicLockstep;
  87505. private _lockstepMaxSteps;
  87506. /**
  87507. * Observable signaled when a context lost event is raised
  87508. */
  87509. onContextLostObservable: Observable<Engine>;
  87510. /**
  87511. * Observable signaled when a context restored event is raised
  87512. */
  87513. onContextRestoredObservable: Observable<Engine>;
  87514. private _onContextLost;
  87515. private _onContextRestored;
  87516. private _contextWasLost;
  87517. /** @hidden */
  87518. _doNotHandleContextLost: boolean;
  87519. /**
  87520. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87521. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87522. */
  87523. doNotHandleContextLost: boolean;
  87524. private _performanceMonitor;
  87525. private _fps;
  87526. private _deltaTime;
  87527. /**
  87528. * Turn this value on if you want to pause FPS computation when in background
  87529. */
  87530. disablePerformanceMonitorInBackground: boolean;
  87531. /**
  87532. * Gets the performance monitor attached to this engine
  87533. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87534. */
  87535. readonly performanceMonitor: PerformanceMonitor;
  87536. /**
  87537. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87538. */
  87539. disableVertexArrayObjects: boolean;
  87540. /** @hidden */
  87541. protected _depthCullingState: _DepthCullingState;
  87542. /** @hidden */
  87543. protected _stencilState: _StencilState;
  87544. /** @hidden */
  87545. protected _alphaState: _AlphaState;
  87546. /** @hidden */
  87547. protected _alphaMode: number;
  87548. /** @hidden */
  87549. _internalTexturesCache: InternalTexture[];
  87550. /** @hidden */
  87551. protected _activeChannel: number;
  87552. private _currentTextureChannel;
  87553. /** @hidden */
  87554. protected _boundTexturesCache: {
  87555. [key: string]: Nullable<InternalTexture>;
  87556. };
  87557. /** @hidden */
  87558. protected _currentEffect: Nullable<Effect>;
  87559. /** @hidden */
  87560. protected _currentProgram: Nullable<WebGLProgram>;
  87561. private _compiledEffects;
  87562. private _vertexAttribArraysEnabled;
  87563. /** @hidden */
  87564. protected _cachedViewport: Nullable<Viewport>;
  87565. private _cachedVertexArrayObject;
  87566. /** @hidden */
  87567. protected _cachedVertexBuffers: any;
  87568. /** @hidden */
  87569. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  87570. /** @hidden */
  87571. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87572. /** @hidden */
  87573. _currentRenderTarget: Nullable<InternalTexture>;
  87574. private _uintIndicesCurrentlySet;
  87575. private _currentBoundBuffer;
  87576. /** @hidden */
  87577. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87578. private _currentBufferPointers;
  87579. private _currentInstanceLocations;
  87580. private _currentInstanceBuffers;
  87581. private _textureUnits;
  87582. /** @hidden */
  87583. _workingCanvas: Nullable<HTMLCanvasElement>;
  87584. /** @hidden */
  87585. _workingContext: Nullable<CanvasRenderingContext2D>;
  87586. private _rescalePostProcess;
  87587. private _dummyFramebuffer;
  87588. private _externalData;
  87589. /** @hidden */
  87590. _bindedRenderFunction: any;
  87591. private _vaoRecordInProgress;
  87592. private _mustWipeVertexAttributes;
  87593. private _emptyTexture;
  87594. private _emptyCubeTexture;
  87595. private _emptyTexture3D;
  87596. /** @hidden */
  87597. _frameHandler: number;
  87598. private _nextFreeTextureSlots;
  87599. private _maxSimultaneousTextures;
  87600. private _activeRequests;
  87601. private _texturesSupported;
  87602. /** @hidden */
  87603. _textureFormatInUse: Nullable<string>;
  87604. /**
  87605. * Gets the list of texture formats supported
  87606. */
  87607. readonly texturesSupported: Array<string>;
  87608. /**
  87609. * Gets the list of texture formats in use
  87610. */
  87611. readonly textureFormatInUse: Nullable<string>;
  87612. /**
  87613. * Gets the current viewport
  87614. */
  87615. readonly currentViewport: Nullable<Viewport>;
  87616. /**
  87617. * Gets the default empty texture
  87618. */
  87619. readonly emptyTexture: InternalTexture;
  87620. /**
  87621. * Gets the default empty 3D texture
  87622. */
  87623. readonly emptyTexture3D: InternalTexture;
  87624. /**
  87625. * Gets the default empty cube texture
  87626. */
  87627. readonly emptyCubeTexture: InternalTexture;
  87628. /**
  87629. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87630. */
  87631. readonly premultipliedAlpha: boolean;
  87632. /**
  87633. * Creates a new engine
  87634. * @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
  87635. * @param antialias defines enable antialiasing (default: false)
  87636. * @param options defines further options to be sent to the getContext() function
  87637. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87638. */
  87639. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87640. /**
  87641. * Initializes a webVR display and starts listening to display change events
  87642. * The onVRDisplayChangedObservable will be notified upon these changes
  87643. * @returns The onVRDisplayChangedObservable
  87644. */
  87645. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87646. /** @hidden */
  87647. _prepareVRComponent(): void;
  87648. /** @hidden */
  87649. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  87650. /** @hidden */
  87651. _submitVRFrame(): void;
  87652. /**
  87653. * Call this function to leave webVR mode
  87654. * Will do nothing if webVR is not supported or if there is no webVR device
  87655. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87656. */
  87657. disableVR(): void;
  87658. /**
  87659. * Gets a boolean indicating that the system is in VR mode and is presenting
  87660. * @returns true if VR mode is engaged
  87661. */
  87662. isVRPresenting(): boolean;
  87663. /** @hidden */
  87664. _requestVRFrame(): void;
  87665. private _disableTouchAction;
  87666. private _rebuildInternalTextures;
  87667. private _rebuildEffects;
  87668. /**
  87669. * Gets a boolean indicating if all created effects are ready
  87670. * @returns true if all effects are ready
  87671. */
  87672. areAllEffectsReady(): boolean;
  87673. private _rebuildBuffers;
  87674. private _initGLContext;
  87675. /**
  87676. * Gets version of the current webGL context
  87677. */
  87678. readonly webGLVersion: number;
  87679. /**
  87680. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87681. */
  87682. readonly isStencilEnable: boolean;
  87683. /** @hidden */
  87684. _prepareWorkingCanvas(): void;
  87685. /**
  87686. * Reset the texture cache to empty state
  87687. */
  87688. resetTextureCache(): void;
  87689. /**
  87690. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87691. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87692. * @returns true if engine is in deterministic lock step mode
  87693. */
  87694. isDeterministicLockStep(): boolean;
  87695. /**
  87696. * Gets the max steps when engine is running in deterministic lock step
  87697. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87698. * @returns the max steps
  87699. */
  87700. getLockstepMaxSteps(): number;
  87701. /**
  87702. * Gets an object containing information about the current webGL context
  87703. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87704. */
  87705. getGlInfo(): {
  87706. vendor: string;
  87707. renderer: string;
  87708. version: string;
  87709. };
  87710. /**
  87711. * Gets current aspect ratio
  87712. * @param camera defines the camera to use to get the aspect ratio
  87713. * @param useScreen defines if screen size must be used (or the current render target if any)
  87714. * @returns a number defining the aspect ratio
  87715. */
  87716. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87717. /**
  87718. * Gets current screen aspect ratio
  87719. * @returns a number defining the aspect ratio
  87720. */
  87721. getScreenAspectRatio(): number;
  87722. /**
  87723. * Gets the current render width
  87724. * @param useScreen defines if screen size must be used (or the current render target if any)
  87725. * @returns a number defining the current render width
  87726. */
  87727. getRenderWidth(useScreen?: boolean): number;
  87728. /**
  87729. * Gets the current render height
  87730. * @param useScreen defines if screen size must be used (or the current render target if any)
  87731. * @returns a number defining the current render height
  87732. */
  87733. getRenderHeight(useScreen?: boolean): number;
  87734. /**
  87735. * Gets the HTML canvas attached with the current webGL context
  87736. * @returns a HTML canvas
  87737. */
  87738. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87739. /**
  87740. * Gets the client rect of the HTML canvas attached with the current webGL context
  87741. * @returns a client rectanglee
  87742. */
  87743. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87744. /**
  87745. * Defines the hardware scaling level.
  87746. * By default the hardware scaling level is computed from the window device ratio.
  87747. * 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.
  87748. * @param level defines the level to use
  87749. */
  87750. setHardwareScalingLevel(level: number): void;
  87751. /**
  87752. * Gets the current hardware scaling level.
  87753. * By default the hardware scaling level is computed from the window device ratio.
  87754. * 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.
  87755. * @returns a number indicating the current hardware scaling level
  87756. */
  87757. getHardwareScalingLevel(): number;
  87758. /**
  87759. * Gets the list of loaded textures
  87760. * @returns an array containing all loaded textures
  87761. */
  87762. getLoadedTexturesCache(): InternalTexture[];
  87763. /**
  87764. * Gets the object containing all engine capabilities
  87765. * @returns the EngineCapabilities object
  87766. */
  87767. getCaps(): EngineCapabilities;
  87768. /**
  87769. * Gets the current depth function
  87770. * @returns a number defining the depth function
  87771. */
  87772. getDepthFunction(): Nullable<number>;
  87773. /**
  87774. * Sets the current depth function
  87775. * @param depthFunc defines the function to use
  87776. */
  87777. setDepthFunction(depthFunc: number): void;
  87778. /**
  87779. * Sets the current depth function to GREATER
  87780. */
  87781. setDepthFunctionToGreater(): void;
  87782. /**
  87783. * Sets the current depth function to GEQUAL
  87784. */
  87785. setDepthFunctionToGreaterOrEqual(): void;
  87786. /**
  87787. * Sets the current depth function to LESS
  87788. */
  87789. setDepthFunctionToLess(): void;
  87790. private _cachedStencilBuffer;
  87791. private _cachedStencilFunction;
  87792. private _cachedStencilMask;
  87793. private _cachedStencilOperationPass;
  87794. private _cachedStencilOperationFail;
  87795. private _cachedStencilOperationDepthFail;
  87796. private _cachedStencilReference;
  87797. /**
  87798. * Caches the the state of the stencil buffer
  87799. */
  87800. cacheStencilState(): void;
  87801. /**
  87802. * Restores the state of the stencil buffer
  87803. */
  87804. restoreStencilState(): void;
  87805. /**
  87806. * Sets the current depth function to LEQUAL
  87807. */
  87808. setDepthFunctionToLessOrEqual(): void;
  87809. /**
  87810. * Gets a boolean indicating if stencil buffer is enabled
  87811. * @returns the current stencil buffer state
  87812. */
  87813. getStencilBuffer(): boolean;
  87814. /**
  87815. * Enable or disable the stencil buffer
  87816. * @param enable defines if the stencil buffer must be enabled or disabled
  87817. */
  87818. setStencilBuffer(enable: boolean): void;
  87819. /**
  87820. * Gets the current stencil mask
  87821. * @returns a number defining the new stencil mask to use
  87822. */
  87823. getStencilMask(): number;
  87824. /**
  87825. * Sets the current stencil mask
  87826. * @param mask defines the new stencil mask to use
  87827. */
  87828. setStencilMask(mask: number): void;
  87829. /**
  87830. * Gets the current stencil function
  87831. * @returns a number defining the stencil function to use
  87832. */
  87833. getStencilFunction(): number;
  87834. /**
  87835. * Gets the current stencil reference value
  87836. * @returns a number defining the stencil reference value to use
  87837. */
  87838. getStencilFunctionReference(): number;
  87839. /**
  87840. * Gets the current stencil mask
  87841. * @returns a number defining the stencil mask to use
  87842. */
  87843. getStencilFunctionMask(): number;
  87844. /**
  87845. * Sets the current stencil function
  87846. * @param stencilFunc defines the new stencil function to use
  87847. */
  87848. setStencilFunction(stencilFunc: number): void;
  87849. /**
  87850. * Sets the current stencil reference
  87851. * @param reference defines the new stencil reference to use
  87852. */
  87853. setStencilFunctionReference(reference: number): void;
  87854. /**
  87855. * Sets the current stencil mask
  87856. * @param mask defines the new stencil mask to use
  87857. */
  87858. setStencilFunctionMask(mask: number): void;
  87859. /**
  87860. * Gets the current stencil operation when stencil fails
  87861. * @returns a number defining stencil operation to use when stencil fails
  87862. */
  87863. getStencilOperationFail(): number;
  87864. /**
  87865. * Gets the current stencil operation when depth fails
  87866. * @returns a number defining stencil operation to use when depth fails
  87867. */
  87868. getStencilOperationDepthFail(): number;
  87869. /**
  87870. * Gets the current stencil operation when stencil passes
  87871. * @returns a number defining stencil operation to use when stencil passes
  87872. */
  87873. getStencilOperationPass(): number;
  87874. /**
  87875. * Sets the stencil operation to use when stencil fails
  87876. * @param operation defines the stencil operation to use when stencil fails
  87877. */
  87878. setStencilOperationFail(operation: number): void;
  87879. /**
  87880. * Sets the stencil operation to use when depth fails
  87881. * @param operation defines the stencil operation to use when depth fails
  87882. */
  87883. setStencilOperationDepthFail(operation: number): void;
  87884. /**
  87885. * Sets the stencil operation to use when stencil passes
  87886. * @param operation defines the stencil operation to use when stencil passes
  87887. */
  87888. setStencilOperationPass(operation: number): void;
  87889. /**
  87890. * Sets a boolean indicating if the dithering state is enabled or disabled
  87891. * @param value defines the dithering state
  87892. */
  87893. setDitheringState(value: boolean): void;
  87894. /**
  87895. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87896. * @param value defines the rasterizer state
  87897. */
  87898. setRasterizerState(value: boolean): void;
  87899. /**
  87900. * stop executing a render loop function and remove it from the execution array
  87901. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87902. */
  87903. stopRenderLoop(renderFunction?: () => void): void;
  87904. /** @hidden */
  87905. _renderLoop(): void;
  87906. /**
  87907. * Register and execute a render loop. The engine can have more than one render function
  87908. * @param renderFunction defines the function to continuously execute
  87909. */
  87910. runRenderLoop(renderFunction: () => void): void;
  87911. /**
  87912. * Toggle full screen mode
  87913. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87914. */
  87915. switchFullscreen(requestPointerLock: boolean): void;
  87916. /**
  87917. * Enters full screen mode
  87918. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87919. */
  87920. enterFullscreen(requestPointerLock: boolean): void;
  87921. /**
  87922. * Exits full screen mode
  87923. */
  87924. exitFullscreen(): void;
  87925. /**
  87926. * Clear the current render buffer or the current render target (if any is set up)
  87927. * @param color defines the color to use
  87928. * @param backBuffer defines if the back buffer must be cleared
  87929. * @param depth defines if the depth buffer must be cleared
  87930. * @param stencil defines if the stencil buffer must be cleared
  87931. */
  87932. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87933. /**
  87934. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87935. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87936. * @param y defines the y-coordinate of the corner of the clear rectangle
  87937. * @param width defines the width of the clear rectangle
  87938. * @param height defines the height of the clear rectangle
  87939. * @param clearColor defines the clear color
  87940. */
  87941. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87942. /**
  87943. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87944. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87945. * @param y defines the y-coordinate of the corner of the clear rectangle
  87946. * @param width defines the width of the clear rectangle
  87947. * @param height defines the height of the clear rectangle
  87948. */
  87949. enableScissor(x: number, y: number, width: number, height: number): void;
  87950. /**
  87951. * Disable previously set scissor test rectangle
  87952. */
  87953. disableScissor(): void;
  87954. private _viewportCached;
  87955. /** @hidden */
  87956. _viewport(x: number, y: number, width: number, height: number): void;
  87957. /**
  87958. * Set the WebGL's viewport
  87959. * @param viewport defines the viewport element to be used
  87960. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87961. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87962. */
  87963. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87964. /**
  87965. * Directly set the WebGL Viewport
  87966. * @param x defines the x coordinate of the viewport (in screen space)
  87967. * @param y defines the y coordinate of the viewport (in screen space)
  87968. * @param width defines the width of the viewport (in screen space)
  87969. * @param height defines the height of the viewport (in screen space)
  87970. * @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
  87971. */
  87972. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87973. /**
  87974. * Begin a new frame
  87975. */
  87976. beginFrame(): void;
  87977. /**
  87978. * Enf the current frame
  87979. */
  87980. endFrame(): void;
  87981. /**
  87982. * Resize the view according to the canvas' size
  87983. */
  87984. resize(): void;
  87985. /**
  87986. * Force a specific size of the canvas
  87987. * @param width defines the new canvas' width
  87988. * @param height defines the new canvas' height
  87989. */
  87990. setSize(width: number, height: number): void;
  87991. /**
  87992. * Binds the frame buffer to the specified texture.
  87993. * @param texture The texture to render to or null for the default canvas
  87994. * @param faceIndex The face of the texture to render to in case of cube texture
  87995. * @param requiredWidth The width of the target to render to
  87996. * @param requiredHeight The height of the target to render to
  87997. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87998. * @param depthStencilTexture The depth stencil texture to use to render
  87999. * @param lodLevel defines le lod level to bind to the frame buffer
  88000. */
  88001. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  88002. /** @hidden */
  88003. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  88004. /**
  88005. * Unbind the current render target texture from the webGL context
  88006. * @param texture defines the render target texture to unbind
  88007. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  88008. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  88009. */
  88010. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  88011. /**
  88012. * Force the mipmap generation for the given render target texture
  88013. * @param texture defines the render target texture to use
  88014. */
  88015. generateMipMapsForCubemap(texture: InternalTexture): void;
  88016. /**
  88017. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  88018. */
  88019. flushFramebuffer(): void;
  88020. /**
  88021. * Unbind the current render target and bind the default framebuffer
  88022. */
  88023. restoreDefaultFramebuffer(): void;
  88024. /**
  88025. * Create an uniform buffer
  88026. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88027. * @param elements defines the content of the uniform buffer
  88028. * @returns the webGL uniform buffer
  88029. */
  88030. createUniformBuffer(elements: FloatArray): DataBuffer;
  88031. /**
  88032. * Create a dynamic uniform buffer
  88033. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88034. * @param elements defines the content of the uniform buffer
  88035. * @returns the webGL uniform buffer
  88036. */
  88037. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88038. /**
  88039. * Update an existing uniform buffer
  88040. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88041. * @param uniformBuffer defines the target uniform buffer
  88042. * @param elements defines the content to update
  88043. * @param offset defines the offset in the uniform buffer where update should start
  88044. * @param count defines the size of the data to update
  88045. */
  88046. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88047. private _resetVertexBufferBinding;
  88048. /**
  88049. * Creates a vertex buffer
  88050. * @param data the data for the vertex buffer
  88051. * @returns the new WebGL static buffer
  88052. */
  88053. createVertexBuffer(data: DataArray): DataBuffer;
  88054. /**
  88055. * Creates a dynamic vertex buffer
  88056. * @param data the data for the dynamic vertex buffer
  88057. * @returns the new WebGL dynamic buffer
  88058. */
  88059. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  88060. /**
  88061. * Update a dynamic index buffer
  88062. * @param indexBuffer defines the target index buffer
  88063. * @param indices defines the data to update
  88064. * @param offset defines the offset in the target index buffer where update should start
  88065. */
  88066. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  88067. /**
  88068. * Updates a dynamic vertex buffer.
  88069. * @param vertexBuffer the vertex buffer to update
  88070. * @param data the data used to update the vertex buffer
  88071. * @param byteOffset the byte offset of the data
  88072. * @param byteLength the byte length of the data
  88073. */
  88074. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  88075. private _resetIndexBufferBinding;
  88076. /**
  88077. * Creates a new index buffer
  88078. * @param indices defines the content of the index buffer
  88079. * @param updatable defines if the index buffer must be updatable
  88080. * @returns a new webGL buffer
  88081. */
  88082. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  88083. /**
  88084. * Bind a webGL buffer to the webGL context
  88085. * @param buffer defines the buffer to bind
  88086. */
  88087. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  88088. /**
  88089. * Bind an uniform buffer to the current webGL context
  88090. * @param buffer defines the buffer to bind
  88091. */
  88092. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88093. /**
  88094. * Bind a buffer to the current webGL context at a given location
  88095. * @param buffer defines the buffer to bind
  88096. * @param location defines the index where to bind the buffer
  88097. */
  88098. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88099. /**
  88100. * Bind a specific block at a given index in a specific shader program
  88101. * @param pipelineContext defines the pipeline context to use
  88102. * @param blockName defines the block name
  88103. * @param index defines the index where to bind the block
  88104. */
  88105. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88106. private bindIndexBuffer;
  88107. private bindBuffer;
  88108. /**
  88109. * update the bound buffer with the given data
  88110. * @param data defines the data to update
  88111. */
  88112. updateArrayBuffer(data: Float32Array): void;
  88113. private _vertexAttribPointer;
  88114. private _bindIndexBufferWithCache;
  88115. private _bindVertexBuffersAttributes;
  88116. /**
  88117. * Records a vertex array object
  88118. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88119. * @param vertexBuffers defines the list of vertex buffers to store
  88120. * @param indexBuffer defines the index buffer to store
  88121. * @param effect defines the effect to store
  88122. * @returns the new vertex array object
  88123. */
  88124. recordVertexArrayObject(vertexBuffers: {
  88125. [key: string]: VertexBuffer;
  88126. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  88127. /**
  88128. * Bind a specific vertex array object
  88129. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88130. * @param vertexArrayObject defines the vertex array object to bind
  88131. * @param indexBuffer defines the index buffer to bind
  88132. */
  88133. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  88134. /**
  88135. * Bind webGl buffers directly to the webGL context
  88136. * @param vertexBuffer defines the vertex buffer to bind
  88137. * @param indexBuffer defines the index buffer to bind
  88138. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  88139. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  88140. * @param effect defines the effect associated with the vertex buffer
  88141. */
  88142. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  88143. private _unbindVertexArrayObject;
  88144. /**
  88145. * Bind a list of vertex buffers to the webGL context
  88146. * @param vertexBuffers defines the list of vertex buffers to bind
  88147. * @param indexBuffer defines the index buffer to bind
  88148. * @param effect defines the effect associated with the vertex buffers
  88149. */
  88150. bindBuffers(vertexBuffers: {
  88151. [key: string]: Nullable<VertexBuffer>;
  88152. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  88153. /**
  88154. * Unbind all instance attributes
  88155. */
  88156. unbindInstanceAttributes(): void;
  88157. /**
  88158. * Release and free the memory of a vertex array object
  88159. * @param vao defines the vertex array object to delete
  88160. */
  88161. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  88162. /** @hidden */
  88163. _releaseBuffer(buffer: DataBuffer): boolean;
  88164. /**
  88165. * Creates a webGL buffer to use with instanciation
  88166. * @param capacity defines the size of the buffer
  88167. * @returns the webGL buffer
  88168. */
  88169. createInstancesBuffer(capacity: number): DataBuffer;
  88170. /**
  88171. * Delete a webGL buffer used with instanciation
  88172. * @param buffer defines the webGL buffer to delete
  88173. */
  88174. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  88175. /**
  88176. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  88177. * @param instancesBuffer defines the webGL buffer to update and bind
  88178. * @param data defines the data to store in the buffer
  88179. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  88180. */
  88181. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  88182. /**
  88183. * Apply all cached states (depth, culling, stencil and alpha)
  88184. */
  88185. applyStates(): void;
  88186. /**
  88187. * Send a draw order
  88188. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88189. * @param indexStart defines the starting index
  88190. * @param indexCount defines the number of index to draw
  88191. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88192. */
  88193. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  88194. /**
  88195. * Draw a list of points
  88196. * @param verticesStart defines the index of first vertex to draw
  88197. * @param verticesCount defines the count of vertices to draw
  88198. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88199. */
  88200. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88201. /**
  88202. * Draw a list of unindexed primitives
  88203. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88204. * @param verticesStart defines the index of first vertex to draw
  88205. * @param verticesCount defines the count of vertices to draw
  88206. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88207. */
  88208. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88209. /**
  88210. * Draw a list of indexed primitives
  88211. * @param fillMode defines the primitive to use
  88212. * @param indexStart defines the starting index
  88213. * @param indexCount defines the number of index to draw
  88214. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88215. */
  88216. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  88217. /**
  88218. * Draw a list of unindexed primitives
  88219. * @param fillMode defines the primitive to use
  88220. * @param verticesStart defines the index of first vertex to draw
  88221. * @param verticesCount defines the count of vertices to draw
  88222. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88223. */
  88224. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88225. private _drawMode;
  88226. /** @hidden */
  88227. _releaseEffect(effect: Effect): void;
  88228. /** @hidden */
  88229. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  88230. /**
  88231. * Create a new effect (used to store vertex/fragment shaders)
  88232. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  88233. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  88234. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  88235. * @param samplers defines an array of string used to represent textures
  88236. * @param defines defines the string containing the defines to use to compile the shaders
  88237. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  88238. * @param onCompiled defines a function to call when the effect creation is successful
  88239. * @param onError defines a function to call when the effect creation has failed
  88240. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  88241. * @returns the new Effect
  88242. */
  88243. 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;
  88244. private _compileShader;
  88245. private _compileRawShader;
  88246. /**
  88247. * Directly creates a webGL program
  88248. * @param pipelineContext defines the pipeline context to attach to
  88249. * @param vertexCode defines the vertex shader code to use
  88250. * @param fragmentCode defines the fragment shader code to use
  88251. * @param context defines the webGL context to use (if not set, the current one will be used)
  88252. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88253. * @returns the new webGL program
  88254. */
  88255. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88256. /**
  88257. * Creates a webGL program
  88258. * @param pipelineContext defines the pipeline context to attach to
  88259. * @param vertexCode defines the vertex shader code to use
  88260. * @param fragmentCode defines the fragment shader code to use
  88261. * @param defines defines the string containing the defines to use to compile the shaders
  88262. * @param context defines the webGL context to use (if not set, the current one will be used)
  88263. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88264. * @returns the new webGL program
  88265. */
  88266. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88267. /**
  88268. * Creates a new pipeline context
  88269. * @returns the new pipeline
  88270. */
  88271. createPipelineContext(): WebGLPipelineContext;
  88272. private _createShaderProgram;
  88273. private _finalizePipelineContext;
  88274. /** @hidden */
  88275. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  88276. /** @hidden */
  88277. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  88278. /** @hidden */
  88279. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  88280. /**
  88281. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  88282. * @param pipelineContext defines the pipeline context to use
  88283. * @param uniformsNames defines the list of uniform names
  88284. * @returns an array of webGL uniform locations
  88285. */
  88286. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  88287. /**
  88288. * Gets the lsit of active attributes for a given webGL program
  88289. * @param pipelineContext defines the pipeline context to use
  88290. * @param attributesNames defines the list of attribute names to get
  88291. * @returns an array of indices indicating the offset of each attribute
  88292. */
  88293. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  88294. /**
  88295. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  88296. * @param effect defines the effect to activate
  88297. */
  88298. enableEffect(effect: Nullable<Effect>): void;
  88299. /**
  88300. * Set the value of an uniform to an array of int32
  88301. * @param uniform defines the webGL uniform location where to store the value
  88302. * @param array defines the array of int32 to store
  88303. */
  88304. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88305. /**
  88306. * Set the value of an uniform to an array of int32 (stored as vec2)
  88307. * @param uniform defines the webGL uniform location where to store the value
  88308. * @param array defines the array of int32 to store
  88309. */
  88310. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88311. /**
  88312. * Set the value of an uniform to an array of int32 (stored as vec3)
  88313. * @param uniform defines the webGL uniform location where to store the value
  88314. * @param array defines the array of int32 to store
  88315. */
  88316. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88317. /**
  88318. * Set the value of an uniform to an array of int32 (stored as vec4)
  88319. * @param uniform defines the webGL uniform location where to store the value
  88320. * @param array defines the array of int32 to store
  88321. */
  88322. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88323. /**
  88324. * Set the value of an uniform to an array of float32
  88325. * @param uniform defines the webGL uniform location where to store the value
  88326. * @param array defines the array of float32 to store
  88327. */
  88328. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88329. /**
  88330. * Set the value of an uniform to an array of float32 (stored as vec2)
  88331. * @param uniform defines the webGL uniform location where to store the value
  88332. * @param array defines the array of float32 to store
  88333. */
  88334. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88335. /**
  88336. * Set the value of an uniform to an array of float32 (stored as vec3)
  88337. * @param uniform defines the webGL uniform location where to store the value
  88338. * @param array defines the array of float32 to store
  88339. */
  88340. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88341. /**
  88342. * Set the value of an uniform to an array of float32 (stored as vec4)
  88343. * @param uniform defines the webGL uniform location where to store the value
  88344. * @param array defines the array of float32 to store
  88345. */
  88346. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88347. /**
  88348. * Set the value of an uniform to an array of number
  88349. * @param uniform defines the webGL uniform location where to store the value
  88350. * @param array defines the array of number to store
  88351. */
  88352. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88353. /**
  88354. * Set the value of an uniform to an array of number (stored as vec2)
  88355. * @param uniform defines the webGL uniform location where to store the value
  88356. * @param array defines the array of number to store
  88357. */
  88358. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88359. /**
  88360. * Set the value of an uniform to an array of number (stored as vec3)
  88361. * @param uniform defines the webGL uniform location where to store the value
  88362. * @param array defines the array of number to store
  88363. */
  88364. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88365. /**
  88366. * Set the value of an uniform to an array of number (stored as vec4)
  88367. * @param uniform defines the webGL uniform location where to store the value
  88368. * @param array defines the array of number to store
  88369. */
  88370. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88371. /**
  88372. * Set the value of an uniform to an array of float32 (stored as matrices)
  88373. * @param uniform defines the webGL uniform location where to store the value
  88374. * @param matrices defines the array of float32 to store
  88375. */
  88376. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  88377. /**
  88378. * Set the value of an uniform to a matrix
  88379. * @param uniform defines the webGL uniform location where to store the value
  88380. * @param matrix defines the matrix to store
  88381. */
  88382. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  88383. /**
  88384. * Set the value of an uniform to a matrix (3x3)
  88385. * @param uniform defines the webGL uniform location where to store the value
  88386. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  88387. */
  88388. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88389. /**
  88390. * Set the value of an uniform to a matrix (2x2)
  88391. * @param uniform defines the webGL uniform location where to store the value
  88392. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  88393. */
  88394. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88395. /**
  88396. * Set the value of an uniform to a number (int)
  88397. * @param uniform defines the webGL uniform location where to store the value
  88398. * @param value defines the int number to store
  88399. */
  88400. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88401. /**
  88402. * Set the value of an uniform to a number (float)
  88403. * @param uniform defines the webGL uniform location where to store the value
  88404. * @param value defines the float number to store
  88405. */
  88406. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88407. /**
  88408. * Set the value of an uniform to a vec2
  88409. * @param uniform defines the webGL uniform location where to store the value
  88410. * @param x defines the 1st component of the value
  88411. * @param y defines the 2nd component of the value
  88412. */
  88413. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  88414. /**
  88415. * Set the value of an uniform to a vec3
  88416. * @param uniform defines the webGL uniform location where to store the value
  88417. * @param x defines the 1st component of the value
  88418. * @param y defines the 2nd component of the value
  88419. * @param z defines the 3rd component of the value
  88420. */
  88421. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88422. /**
  88423. * Set the value of an uniform to a boolean
  88424. * @param uniform defines the webGL uniform location where to store the value
  88425. * @param bool defines the boolean to store
  88426. */
  88427. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88428. /**
  88429. * Set the value of an uniform to a vec4
  88430. * @param uniform defines the webGL uniform location where to store the value
  88431. * @param x defines the 1st component of the value
  88432. * @param y defines the 2nd component of the value
  88433. * @param z defines the 3rd component of the value
  88434. * @param w defines the 4th component of the value
  88435. */
  88436. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88437. /**
  88438. * Set the value of an uniform to a Color3
  88439. * @param uniform defines the webGL uniform location where to store the value
  88440. * @param color3 defines the color to store
  88441. */
  88442. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88443. /**
  88444. * Set the value of an uniform to a Color3 and an alpha value
  88445. * @param uniform defines the webGL uniform location where to store the value
  88446. * @param color3 defines the color to store
  88447. * @param alpha defines the alpha component to store
  88448. */
  88449. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88450. /**
  88451. * Sets a Color4 on a uniform variable
  88452. * @param uniform defines the uniform location
  88453. * @param color4 defines the value to be set
  88454. */
  88455. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88456. /**
  88457. * Set various states to the webGL context
  88458. * @param culling defines backface culling state
  88459. * @param zOffset defines the value to apply to zOffset (0 by default)
  88460. * @param force defines if states must be applied even if cache is up to date
  88461. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88462. */
  88463. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88464. /**
  88465. * Set the z offset to apply to current rendering
  88466. * @param value defines the offset to apply
  88467. */
  88468. setZOffset(value: number): void;
  88469. /**
  88470. * Gets the current value of the zOffset
  88471. * @returns the current zOffset state
  88472. */
  88473. getZOffset(): number;
  88474. /**
  88475. * Enable or disable depth buffering
  88476. * @param enable defines the state to set
  88477. */
  88478. setDepthBuffer(enable: boolean): void;
  88479. /**
  88480. * Gets a boolean indicating if depth writing is enabled
  88481. * @returns the current depth writing state
  88482. */
  88483. getDepthWrite(): boolean;
  88484. /**
  88485. * Enable or disable depth writing
  88486. * @param enable defines the state to set
  88487. */
  88488. setDepthWrite(enable: boolean): void;
  88489. /**
  88490. * Enable or disable color writing
  88491. * @param enable defines the state to set
  88492. */
  88493. setColorWrite(enable: boolean): void;
  88494. /**
  88495. * Gets a boolean indicating if color writing is enabled
  88496. * @returns the current color writing state
  88497. */
  88498. getColorWrite(): boolean;
  88499. /**
  88500. * Sets alpha constants used by some alpha blending modes
  88501. * @param r defines the red component
  88502. * @param g defines the green component
  88503. * @param b defines the blue component
  88504. * @param a defines the alpha component
  88505. */
  88506. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88507. /**
  88508. * Sets the current alpha mode
  88509. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88510. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88511. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88512. */
  88513. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88514. /**
  88515. * Gets the current alpha mode
  88516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88517. * @returns the current alpha mode
  88518. */
  88519. getAlphaMode(): number;
  88520. /**
  88521. * Clears the list of texture accessible through engine.
  88522. * This can help preventing texture load conflict due to name collision.
  88523. */
  88524. clearInternalTexturesCache(): void;
  88525. /**
  88526. * Force the entire cache to be cleared
  88527. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88528. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88529. */
  88530. wipeCaches(bruteForce?: boolean): void;
  88531. /**
  88532. * Set the compressed texture format to use, based on the formats you have, and the formats
  88533. * supported by the hardware / browser.
  88534. *
  88535. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88536. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88537. * to API arguments needed to compressed textures. This puts the burden on the container
  88538. * generator to house the arcane code for determining these for current & future formats.
  88539. *
  88540. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88541. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88542. *
  88543. * Note: The result of this call is not taken into account when a texture is base64.
  88544. *
  88545. * @param formatsAvailable defines the list of those format families you have created
  88546. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88547. *
  88548. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88549. * @returns The extension selected.
  88550. */
  88551. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88552. /** @hidden */
  88553. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88554. min: number;
  88555. mag: number;
  88556. };
  88557. /** @hidden */
  88558. _createTexture(): WebGLTexture;
  88559. /**
  88560. * Usually called from Texture.ts.
  88561. * Passed information to create a WebGLTexture
  88562. * @param urlArg defines a value which contains one of the following:
  88563. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88564. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88565. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88566. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88567. * @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)
  88568. * @param scene needed for loading to the correct scene
  88569. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88570. * @param onLoad optional callback to be called upon successful completion
  88571. * @param onError optional callback to be called upon failure
  88572. * @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
  88573. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88574. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88575. * @param forcedExtension defines the extension to use to pick the right loader
  88576. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88577. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88578. */
  88579. 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;
  88580. private _rescaleTexture;
  88581. private _unpackFlipYCached;
  88582. /**
  88583. * In case you are sharing the context with other applications, it might
  88584. * be interested to not cache the unpack flip y state to ensure a consistent
  88585. * value would be set.
  88586. */
  88587. enableUnpackFlipYCached: boolean;
  88588. /** @hidden */
  88589. _unpackFlipY(value: boolean): void;
  88590. /** @hidden */
  88591. _getUnpackAlignement(): number;
  88592. /**
  88593. * Creates a dynamic texture
  88594. * @param width defines the width of the texture
  88595. * @param height defines the height of the texture
  88596. * @param generateMipMaps defines if the engine should generate the mip levels
  88597. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88598. * @returns the dynamic texture inside an InternalTexture
  88599. */
  88600. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88601. /**
  88602. * Update the sampling mode of a given texture
  88603. * @param samplingMode defines the required sampling mode
  88604. * @param texture defines the texture to update
  88605. */
  88606. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88607. /**
  88608. * Update the content of a dynamic texture
  88609. * @param texture defines the texture to update
  88610. * @param canvas defines the canvas containing the source
  88611. * @param invertY defines if data must be stored with Y axis inverted
  88612. * @param premulAlpha defines if alpha is stored as premultiplied
  88613. * @param format defines the format of the data
  88614. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88615. */
  88616. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88617. /**
  88618. * Update a video texture
  88619. * @param texture defines the texture to update
  88620. * @param video defines the video element to use
  88621. * @param invertY defines if data must be stored with Y axis inverted
  88622. */
  88623. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88624. /**
  88625. * Updates a depth texture Comparison Mode and Function.
  88626. * If the comparison Function is equal to 0, the mode will be set to none.
  88627. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88628. * @param texture The texture to set the comparison function for
  88629. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88630. */
  88631. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88632. /** @hidden */
  88633. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88634. width: number;
  88635. height: number;
  88636. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88637. /**
  88638. * Creates a depth stencil texture.
  88639. * This is only available in WebGL 2 or with the depth texture extension available.
  88640. * @param size The size of face edge in the texture.
  88641. * @param options The options defining the texture.
  88642. * @returns The texture
  88643. */
  88644. createDepthStencilTexture(size: number | {
  88645. width: number;
  88646. height: number;
  88647. }, options: DepthTextureCreationOptions): InternalTexture;
  88648. /**
  88649. * Creates a depth stencil texture.
  88650. * This is only available in WebGL 2 or with the depth texture extension available.
  88651. * @param size The size of face edge in the texture.
  88652. * @param options The options defining the texture.
  88653. * @returns The texture
  88654. */
  88655. private _createDepthStencilTexture;
  88656. /**
  88657. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88658. * @param renderTarget The render target to set the frame buffer for
  88659. */
  88660. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88661. /**
  88662. * Creates a new render target texture
  88663. * @param size defines the size of the texture
  88664. * @param options defines the options used to create the texture
  88665. * @returns a new render target texture stored in an InternalTexture
  88666. */
  88667. createRenderTargetTexture(size: number | {
  88668. width: number;
  88669. height: number;
  88670. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88671. /** @hidden */
  88672. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88673. /**
  88674. * Updates the sample count of a render target texture
  88675. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88676. * @param texture defines the texture to update
  88677. * @param samples defines the sample count to set
  88678. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88679. */
  88680. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88681. /** @hidden */
  88682. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88683. /** @hidden */
  88684. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88685. /** @hidden */
  88686. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88687. /** @hidden */
  88688. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88689. /**
  88690. * @hidden
  88691. */
  88692. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88693. private _prepareWebGLTextureContinuation;
  88694. private _prepareWebGLTexture;
  88695. /** @hidden */
  88696. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88697. /** @hidden */
  88698. _releaseFramebufferObjects(texture: InternalTexture): void;
  88699. /** @hidden */
  88700. _releaseTexture(texture: InternalTexture): void;
  88701. private setProgram;
  88702. private _boundUniforms;
  88703. /**
  88704. * Binds an effect to the webGL context
  88705. * @param effect defines the effect to bind
  88706. */
  88707. bindSamplers(effect: Effect): void;
  88708. private _activateCurrentTexture;
  88709. /** @hidden */
  88710. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88711. /** @hidden */
  88712. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88713. /**
  88714. * Sets a texture to the webGL context from a postprocess
  88715. * @param channel defines the channel to use
  88716. * @param postProcess defines the source postprocess
  88717. */
  88718. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88719. /**
  88720. * Binds the output of the passed in post process to the texture channel specified
  88721. * @param channel The channel the texture should be bound to
  88722. * @param postProcess The post process which's output should be bound
  88723. */
  88724. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88725. /**
  88726. * Unbind all textures from the webGL context
  88727. */
  88728. unbindAllTextures(): void;
  88729. /**
  88730. * Sets a texture to the according uniform.
  88731. * @param channel The texture channel
  88732. * @param uniform The uniform to set
  88733. * @param texture The texture to apply
  88734. */
  88735. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88736. /**
  88737. * Sets a depth stencil texture from a render target to the according uniform.
  88738. * @param channel The texture channel
  88739. * @param uniform The uniform to set
  88740. * @param texture The render target texture containing the depth stencil texture to apply
  88741. */
  88742. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88743. private _bindSamplerUniformToChannel;
  88744. private _getTextureWrapMode;
  88745. private _setTexture;
  88746. /**
  88747. * Sets an array of texture to the webGL context
  88748. * @param channel defines the channel where the texture array must be set
  88749. * @param uniform defines the associated uniform location
  88750. * @param textures defines the array of textures to bind
  88751. */
  88752. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88753. /** @hidden */
  88754. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88755. private _setTextureParameterFloat;
  88756. private _setTextureParameterInteger;
  88757. /**
  88758. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88759. * @param x defines the x coordinate of the rectangle where pixels must be read
  88760. * @param y defines the y coordinate of the rectangle where pixels must be read
  88761. * @param width defines the width of the rectangle where pixels must be read
  88762. * @param height defines the height of the rectangle where pixels must be read
  88763. * @returns a Uint8Array containing RGBA colors
  88764. */
  88765. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88766. /**
  88767. * Add an externaly attached data from its key.
  88768. * This method call will fail and return false, if such key already exists.
  88769. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88770. * @param key the unique key that identifies the data
  88771. * @param data the data object to associate to the key for this Engine instance
  88772. * @return true if no such key were already present and the data was added successfully, false otherwise
  88773. */
  88774. addExternalData<T>(key: string, data: T): boolean;
  88775. /**
  88776. * Get an externaly attached data from its key
  88777. * @param key the unique key that identifies the data
  88778. * @return the associated data, if present (can be null), or undefined if not present
  88779. */
  88780. getExternalData<T>(key: string): T;
  88781. /**
  88782. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88783. * @param key the unique key that identifies the data
  88784. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88785. * @return the associated data, can be null if the factory returned null.
  88786. */
  88787. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88788. /**
  88789. * Remove an externaly attached data from the Engine instance
  88790. * @param key the unique key that identifies the data
  88791. * @return true if the data was successfully removed, false if it doesn't exist
  88792. */
  88793. removeExternalData(key: string): boolean;
  88794. /**
  88795. * Unbind all vertex attributes from the webGL context
  88796. */
  88797. unbindAllAttributes(): void;
  88798. /**
  88799. * 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
  88800. */
  88801. releaseEffects(): void;
  88802. /**
  88803. * Dispose and release all associated resources
  88804. */
  88805. dispose(): void;
  88806. /**
  88807. * Display the loading screen
  88808. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88809. */
  88810. displayLoadingUI(): void;
  88811. /**
  88812. * Hide the loading screen
  88813. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88814. */
  88815. hideLoadingUI(): void;
  88816. /**
  88817. * Gets the current loading screen object
  88818. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88819. */
  88820. /**
  88821. * Sets the current loading screen object
  88822. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88823. */
  88824. loadingScreen: ILoadingScreen;
  88825. /**
  88826. * Sets the current loading screen text
  88827. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88828. */
  88829. loadingUIText: string;
  88830. /**
  88831. * Sets the current loading screen background color
  88832. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88833. */
  88834. loadingUIBackgroundColor: string;
  88835. /**
  88836. * Attach a new callback raised when context lost event is fired
  88837. * @param callback defines the callback to call
  88838. */
  88839. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88840. /**
  88841. * Attach a new callback raised when context restored event is fired
  88842. * @param callback defines the callback to call
  88843. */
  88844. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88845. /**
  88846. * Gets the source code of the vertex shader associated with a specific webGL program
  88847. * @param program defines the program to use
  88848. * @returns a string containing the source code of the vertex shader associated with the program
  88849. */
  88850. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88851. /**
  88852. * Gets the source code of the fragment shader associated with a specific webGL program
  88853. * @param program defines the program to use
  88854. * @returns a string containing the source code of the fragment shader associated with the program
  88855. */
  88856. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88857. /**
  88858. * Get the current error code of the webGL context
  88859. * @returns the error code
  88860. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88861. */
  88862. getError(): number;
  88863. /**
  88864. * Gets the current framerate
  88865. * @returns a number representing the framerate
  88866. */
  88867. getFps(): number;
  88868. /**
  88869. * Gets the time spent between current and previous frame
  88870. * @returns a number representing the delta time in ms
  88871. */
  88872. getDeltaTime(): number;
  88873. private _measureFps;
  88874. /** @hidden */
  88875. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88876. private _canRenderToFloatFramebuffer;
  88877. private _canRenderToHalfFloatFramebuffer;
  88878. private _canRenderToFramebuffer;
  88879. /** @hidden */
  88880. _getWebGLTextureType(type: number): number;
  88881. /** @hidden */
  88882. _getInternalFormat(format: number): number;
  88883. /** @hidden */
  88884. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88885. /** @hidden */
  88886. _getRGBAMultiSampleBufferFormat(type: number): number;
  88887. /** @hidden */
  88888. _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;
  88889. /** @hidden */
  88890. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88891. /**
  88892. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88893. * @returns true if the engine can be created
  88894. * @ignorenaming
  88895. */
  88896. static isSupported(): boolean;
  88897. }
  88898. }
  88899. declare module BABYLON {
  88900. /**
  88901. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88902. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88903. */
  88904. export class EffectFallbacks {
  88905. private _defines;
  88906. private _currentRank;
  88907. private _maxRank;
  88908. private _mesh;
  88909. /**
  88910. * Removes the fallback from the bound mesh.
  88911. */
  88912. unBindMesh(): void;
  88913. /**
  88914. * Adds a fallback on the specified property.
  88915. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88916. * @param define The name of the define in the shader
  88917. */
  88918. addFallback(rank: number, define: string): void;
  88919. /**
  88920. * Sets the mesh to use CPU skinning when needing to fallback.
  88921. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88922. * @param mesh The mesh to use the fallbacks.
  88923. */
  88924. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88925. /**
  88926. * Checks to see if more fallbacks are still availible.
  88927. */
  88928. readonly isMoreFallbacks: boolean;
  88929. /**
  88930. * Removes the defines that shoould be removed when falling back.
  88931. * @param currentDefines defines the current define statements for the shader.
  88932. * @param effect defines the current effect we try to compile
  88933. * @returns The resulting defines with defines of the current rank removed.
  88934. */
  88935. reduce(currentDefines: string, effect: Effect): string;
  88936. }
  88937. /**
  88938. * Options to be used when creating an effect.
  88939. */
  88940. export class EffectCreationOptions {
  88941. /**
  88942. * Atrributes that will be used in the shader.
  88943. */
  88944. attributes: string[];
  88945. /**
  88946. * Uniform varible names that will be set in the shader.
  88947. */
  88948. uniformsNames: string[];
  88949. /**
  88950. * Uniform buffer varible names that will be set in the shader.
  88951. */
  88952. uniformBuffersNames: string[];
  88953. /**
  88954. * Sampler texture variable names that will be set in the shader.
  88955. */
  88956. samplers: string[];
  88957. /**
  88958. * Define statements that will be set in the shader.
  88959. */
  88960. defines: any;
  88961. /**
  88962. * Possible fallbacks for this effect to improve performance when needed.
  88963. */
  88964. fallbacks: Nullable<EffectFallbacks>;
  88965. /**
  88966. * Callback that will be called when the shader is compiled.
  88967. */
  88968. onCompiled: Nullable<(effect: Effect) => void>;
  88969. /**
  88970. * Callback that will be called if an error occurs during shader compilation.
  88971. */
  88972. onError: Nullable<(effect: Effect, errors: string) => void>;
  88973. /**
  88974. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88975. */
  88976. indexParameters: any;
  88977. /**
  88978. * Max number of lights that can be used in the shader.
  88979. */
  88980. maxSimultaneousLights: number;
  88981. /**
  88982. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88983. */
  88984. transformFeedbackVaryings: Nullable<string[]>;
  88985. }
  88986. /**
  88987. * Effect containing vertex and fragment shader that can be executed on an object.
  88988. */
  88989. export class Effect implements IDisposable {
  88990. /**
  88991. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88992. */
  88993. static ShadersRepository: string;
  88994. /**
  88995. * Name of the effect.
  88996. */
  88997. name: any;
  88998. /**
  88999. * String container all the define statements that should be set on the shader.
  89000. */
  89001. defines: string;
  89002. /**
  89003. * Callback that will be called when the shader is compiled.
  89004. */
  89005. onCompiled: Nullable<(effect: Effect) => void>;
  89006. /**
  89007. * Callback that will be called if an error occurs during shader compilation.
  89008. */
  89009. onError: Nullable<(effect: Effect, errors: string) => void>;
  89010. /**
  89011. * Callback that will be called when effect is bound.
  89012. */
  89013. onBind: Nullable<(effect: Effect) => void>;
  89014. /**
  89015. * Unique ID of the effect.
  89016. */
  89017. uniqueId: number;
  89018. /**
  89019. * Observable that will be called when the shader is compiled.
  89020. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  89021. */
  89022. onCompileObservable: Observable<Effect>;
  89023. /**
  89024. * Observable that will be called if an error occurs during shader compilation.
  89025. */
  89026. onErrorObservable: Observable<Effect>;
  89027. /** @hidden */
  89028. _onBindObservable: Nullable<Observable<Effect>>;
  89029. /**
  89030. * Observable that will be called when effect is bound.
  89031. */
  89032. readonly onBindObservable: Observable<Effect>;
  89033. /** @hidden */
  89034. _bonesComputationForcedToCPU: boolean;
  89035. private static _uniqueIdSeed;
  89036. private _engine;
  89037. private _uniformBuffersNames;
  89038. private _uniformsNames;
  89039. private _samplerList;
  89040. private _samplers;
  89041. private _isReady;
  89042. private _compilationError;
  89043. private _attributesNames;
  89044. private _attributes;
  89045. private _uniforms;
  89046. /**
  89047. * Key for the effect.
  89048. * @hidden
  89049. */
  89050. _key: string;
  89051. private _indexParameters;
  89052. private _fallbacks;
  89053. private _vertexSourceCode;
  89054. private _fragmentSourceCode;
  89055. private _vertexSourceCodeOverride;
  89056. private _fragmentSourceCodeOverride;
  89057. private _transformFeedbackVaryings;
  89058. /**
  89059. * Compiled shader to webGL program.
  89060. * @hidden
  89061. */
  89062. _pipelineContext: Nullable<IPipelineContext>;
  89063. private _valueCache;
  89064. private static _baseCache;
  89065. /**
  89066. * Instantiates an effect.
  89067. * An effect can be used to create/manage/execute vertex and fragment shaders.
  89068. * @param baseName Name of the effect.
  89069. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  89070. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  89071. * @param samplers List of sampler variables that will be passed to the shader.
  89072. * @param engine Engine to be used to render the effect
  89073. * @param defines Define statements to be added to the shader.
  89074. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  89075. * @param onCompiled Callback that will be called when the shader is compiled.
  89076. * @param onError Callback that will be called if an error occurs during shader compilation.
  89077. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89078. */
  89079. 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);
  89080. /**
  89081. * Unique key for this effect
  89082. */
  89083. readonly key: string;
  89084. /**
  89085. * If the effect has been compiled and prepared.
  89086. * @returns if the effect is compiled and prepared.
  89087. */
  89088. isReady(): boolean;
  89089. /**
  89090. * The engine the effect was initialized with.
  89091. * @returns the engine.
  89092. */
  89093. getEngine(): Engine;
  89094. /**
  89095. * The pipeline context for this effect
  89096. * @returns the associated pipeline context
  89097. */
  89098. getPipelineContext(): Nullable<IPipelineContext>;
  89099. /**
  89100. * The set of names of attribute variables for the shader.
  89101. * @returns An array of attribute names.
  89102. */
  89103. getAttributesNames(): string[];
  89104. /**
  89105. * Returns the attribute at the given index.
  89106. * @param index The index of the attribute.
  89107. * @returns The location of the attribute.
  89108. */
  89109. getAttributeLocation(index: number): number;
  89110. /**
  89111. * Returns the attribute based on the name of the variable.
  89112. * @param name of the attribute to look up.
  89113. * @returns the attribute location.
  89114. */
  89115. getAttributeLocationByName(name: string): number;
  89116. /**
  89117. * The number of attributes.
  89118. * @returns the numnber of attributes.
  89119. */
  89120. getAttributesCount(): number;
  89121. /**
  89122. * Gets the index of a uniform variable.
  89123. * @param uniformName of the uniform to look up.
  89124. * @returns the index.
  89125. */
  89126. getUniformIndex(uniformName: string): number;
  89127. /**
  89128. * Returns the attribute based on the name of the variable.
  89129. * @param uniformName of the uniform to look up.
  89130. * @returns the location of the uniform.
  89131. */
  89132. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  89133. /**
  89134. * Returns an array of sampler variable names
  89135. * @returns The array of sampler variable neames.
  89136. */
  89137. getSamplers(): string[];
  89138. /**
  89139. * The error from the last compilation.
  89140. * @returns the error string.
  89141. */
  89142. getCompilationError(): string;
  89143. /**
  89144. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  89145. * @param func The callback to be used.
  89146. */
  89147. executeWhenCompiled(func: (effect: Effect) => void): void;
  89148. private _checkIsReady;
  89149. /** @hidden */
  89150. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  89151. /** @hidden */
  89152. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  89153. /** @hidden */
  89154. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  89155. private _processShaderConversion;
  89156. private _processIncludes;
  89157. private _processPrecision;
  89158. /**
  89159. * Recompiles the webGL program
  89160. * @param vertexSourceCode The source code for the vertex shader.
  89161. * @param fragmentSourceCode The source code for the fragment shader.
  89162. * @param onCompiled Callback called when completed.
  89163. * @param onError Callback called on error.
  89164. * @hidden
  89165. */
  89166. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  89167. /**
  89168. * Prepares the effect
  89169. * @hidden
  89170. */
  89171. _prepareEffect(): void;
  89172. /**
  89173. * Checks if the effect is supported. (Must be called after compilation)
  89174. */
  89175. readonly isSupported: boolean;
  89176. /**
  89177. * Binds a texture to the engine to be used as output of the shader.
  89178. * @param channel Name of the output variable.
  89179. * @param texture Texture to bind.
  89180. * @hidden
  89181. */
  89182. _bindTexture(channel: string, texture: InternalTexture): void;
  89183. /**
  89184. * Sets a texture on the engine to be used in the shader.
  89185. * @param channel Name of the sampler variable.
  89186. * @param texture Texture to set.
  89187. */
  89188. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  89189. /**
  89190. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  89191. * @param channel Name of the sampler variable.
  89192. * @param texture Texture to set.
  89193. */
  89194. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  89195. /**
  89196. * Sets an array of textures on the engine to be used in the shader.
  89197. * @param channel Name of the variable.
  89198. * @param textures Textures to set.
  89199. */
  89200. setTextureArray(channel: string, textures: BaseTexture[]): void;
  89201. /**
  89202. * 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)
  89203. * @param channel Name of the sampler variable.
  89204. * @param postProcess Post process to get the input texture from.
  89205. */
  89206. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  89207. /**
  89208. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  89209. * 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)
  89210. * @param channel Name of the sampler variable.
  89211. * @param postProcess Post process to get the output texture from.
  89212. */
  89213. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  89214. /** @hidden */
  89215. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  89216. /** @hidden */
  89217. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  89218. /** @hidden */
  89219. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  89220. /** @hidden */
  89221. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  89222. /**
  89223. * Binds a buffer to a uniform.
  89224. * @param buffer Buffer to bind.
  89225. * @param name Name of the uniform variable to bind to.
  89226. */
  89227. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  89228. /**
  89229. * Binds block to a uniform.
  89230. * @param blockName Name of the block to bind.
  89231. * @param index Index to bind.
  89232. */
  89233. bindUniformBlock(blockName: string, index: number): void;
  89234. /**
  89235. * Sets an interger value on a uniform variable.
  89236. * @param uniformName Name of the variable.
  89237. * @param value Value to be set.
  89238. * @returns this effect.
  89239. */
  89240. setInt(uniformName: string, value: number): Effect;
  89241. /**
  89242. * Sets an int array on a uniform variable.
  89243. * @param uniformName Name of the variable.
  89244. * @param array array to be set.
  89245. * @returns this effect.
  89246. */
  89247. setIntArray(uniformName: string, array: Int32Array): Effect;
  89248. /**
  89249. * 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)
  89250. * @param uniformName Name of the variable.
  89251. * @param array array to be set.
  89252. * @returns this effect.
  89253. */
  89254. setIntArray2(uniformName: string, array: Int32Array): Effect;
  89255. /**
  89256. * 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)
  89257. * @param uniformName Name of the variable.
  89258. * @param array array to be set.
  89259. * @returns this effect.
  89260. */
  89261. setIntArray3(uniformName: string, array: Int32Array): Effect;
  89262. /**
  89263. * 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)
  89264. * @param uniformName Name of the variable.
  89265. * @param array array to be set.
  89266. * @returns this effect.
  89267. */
  89268. setIntArray4(uniformName: string, array: Int32Array): Effect;
  89269. /**
  89270. * Sets an float array on a uniform variable.
  89271. * @param uniformName Name of the variable.
  89272. * @param array array to be set.
  89273. * @returns this effect.
  89274. */
  89275. setFloatArray(uniformName: string, array: Float32Array): Effect;
  89276. /**
  89277. * 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)
  89278. * @param uniformName Name of the variable.
  89279. * @param array array to be set.
  89280. * @returns this effect.
  89281. */
  89282. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  89283. /**
  89284. * 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)
  89285. * @param uniformName Name of the variable.
  89286. * @param array array to be set.
  89287. * @returns this effect.
  89288. */
  89289. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  89290. /**
  89291. * 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)
  89292. * @param uniformName Name of the variable.
  89293. * @param array array to be set.
  89294. * @returns this effect.
  89295. */
  89296. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  89297. /**
  89298. * Sets an array on a uniform variable.
  89299. * @param uniformName Name of the variable.
  89300. * @param array array to be set.
  89301. * @returns this effect.
  89302. */
  89303. setArray(uniformName: string, array: number[]): Effect;
  89304. /**
  89305. * 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)
  89306. * @param uniformName Name of the variable.
  89307. * @param array array to be set.
  89308. * @returns this effect.
  89309. */
  89310. setArray2(uniformName: string, array: number[]): Effect;
  89311. /**
  89312. * 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)
  89313. * @param uniformName Name of the variable.
  89314. * @param array array to be set.
  89315. * @returns this effect.
  89316. */
  89317. setArray3(uniformName: string, array: number[]): Effect;
  89318. /**
  89319. * 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)
  89320. * @param uniformName Name of the variable.
  89321. * @param array array to be set.
  89322. * @returns this effect.
  89323. */
  89324. setArray4(uniformName: string, array: number[]): Effect;
  89325. /**
  89326. * Sets matrices on a uniform variable.
  89327. * @param uniformName Name of the variable.
  89328. * @param matrices matrices to be set.
  89329. * @returns this effect.
  89330. */
  89331. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  89332. /**
  89333. * Sets matrix on a uniform variable.
  89334. * @param uniformName Name of the variable.
  89335. * @param matrix matrix to be set.
  89336. * @returns this effect.
  89337. */
  89338. setMatrix(uniformName: string, matrix: Matrix): Effect;
  89339. /**
  89340. * 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)
  89341. * @param uniformName Name of the variable.
  89342. * @param matrix matrix to be set.
  89343. * @returns this effect.
  89344. */
  89345. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  89346. /**
  89347. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  89348. * @param uniformName Name of the variable.
  89349. * @param matrix matrix to be set.
  89350. * @returns this effect.
  89351. */
  89352. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  89353. /**
  89354. * Sets a float on a uniform variable.
  89355. * @param uniformName Name of the variable.
  89356. * @param value value to be set.
  89357. * @returns this effect.
  89358. */
  89359. setFloat(uniformName: string, value: number): Effect;
  89360. /**
  89361. * Sets a boolean on a uniform variable.
  89362. * @param uniformName Name of the variable.
  89363. * @param bool value to be set.
  89364. * @returns this effect.
  89365. */
  89366. setBool(uniformName: string, bool: boolean): Effect;
  89367. /**
  89368. * Sets a Vector2 on a uniform variable.
  89369. * @param uniformName Name of the variable.
  89370. * @param vector2 vector2 to be set.
  89371. * @returns this effect.
  89372. */
  89373. setVector2(uniformName: string, vector2: Vector2): Effect;
  89374. /**
  89375. * Sets a float2 on a uniform variable.
  89376. * @param uniformName Name of the variable.
  89377. * @param x First float in float2.
  89378. * @param y Second float in float2.
  89379. * @returns this effect.
  89380. */
  89381. setFloat2(uniformName: string, x: number, y: number): Effect;
  89382. /**
  89383. * Sets a Vector3 on a uniform variable.
  89384. * @param uniformName Name of the variable.
  89385. * @param vector3 Value to be set.
  89386. * @returns this effect.
  89387. */
  89388. setVector3(uniformName: string, vector3: Vector3): Effect;
  89389. /**
  89390. * Sets a float3 on a uniform variable.
  89391. * @param uniformName Name of the variable.
  89392. * @param x First float in float3.
  89393. * @param y Second float in float3.
  89394. * @param z Third float in float3.
  89395. * @returns this effect.
  89396. */
  89397. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  89398. /**
  89399. * Sets a Vector4 on a uniform variable.
  89400. * @param uniformName Name of the variable.
  89401. * @param vector4 Value to be set.
  89402. * @returns this effect.
  89403. */
  89404. setVector4(uniformName: string, vector4: Vector4): Effect;
  89405. /**
  89406. * Sets a float4 on a uniform variable.
  89407. * @param uniformName Name of the variable.
  89408. * @param x First float in float4.
  89409. * @param y Second float in float4.
  89410. * @param z Third float in float4.
  89411. * @param w Fourth float in float4.
  89412. * @returns this effect.
  89413. */
  89414. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89415. /**
  89416. * Sets a Color3 on a uniform variable.
  89417. * @param uniformName Name of the variable.
  89418. * @param color3 Value to be set.
  89419. * @returns this effect.
  89420. */
  89421. setColor3(uniformName: string, color3: Color3): Effect;
  89422. /**
  89423. * Sets a Color4 on a uniform variable.
  89424. * @param uniformName Name of the variable.
  89425. * @param color3 Value to be set.
  89426. * @param alpha Alpha value to be set.
  89427. * @returns this effect.
  89428. */
  89429. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89430. /**
  89431. * Sets a Color4 on a uniform variable
  89432. * @param uniformName defines the name of the variable
  89433. * @param color4 defines the value to be set
  89434. * @returns this effect.
  89435. */
  89436. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89437. /** Release all associated resources */
  89438. dispose(): void;
  89439. /**
  89440. * This function will add a new shader to the shader store
  89441. * @param name the name of the shader
  89442. * @param pixelShader optional pixel shader content
  89443. * @param vertexShader optional vertex shader content
  89444. */
  89445. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89446. /**
  89447. * Store of each shader (The can be looked up using effect.key)
  89448. */
  89449. static ShadersStore: {
  89450. [key: string]: string;
  89451. };
  89452. /**
  89453. * Store of each included file for a shader (The can be looked up using effect.key)
  89454. */
  89455. static IncludesShadersStore: {
  89456. [key: string]: string;
  89457. };
  89458. /**
  89459. * Resets the cache of effects.
  89460. */
  89461. static ResetCache(): void;
  89462. }
  89463. }
  89464. declare module BABYLON {
  89465. /**
  89466. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89467. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89468. * 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;
  89469. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89470. */
  89471. export class ColorCurves {
  89472. private _dirty;
  89473. private _tempColor;
  89474. private _globalCurve;
  89475. private _highlightsCurve;
  89476. private _midtonesCurve;
  89477. private _shadowsCurve;
  89478. private _positiveCurve;
  89479. private _negativeCurve;
  89480. private _globalHue;
  89481. private _globalDensity;
  89482. private _globalSaturation;
  89483. private _globalExposure;
  89484. /**
  89485. * Gets the global Hue value.
  89486. * 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).
  89487. */
  89488. /**
  89489. * Sets the global Hue value.
  89490. * 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).
  89491. */
  89492. globalHue: number;
  89493. /**
  89494. * Gets the global Density value.
  89495. * 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.
  89496. * Values less than zero provide a filter of opposite hue.
  89497. */
  89498. /**
  89499. * Sets 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. globalDensity: number;
  89504. /**
  89505. * Gets the global Saturation value.
  89506. * 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.
  89507. */
  89508. /**
  89509. * Sets the global Saturation value.
  89510. * 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.
  89511. */
  89512. globalSaturation: number;
  89513. /**
  89514. * Gets the global Exposure 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 exposure and negative values decrease exposure.
  89516. */
  89517. /**
  89518. * Sets the global Exposure value.
  89519. * 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.
  89520. */
  89521. globalExposure: number;
  89522. private _highlightsHue;
  89523. private _highlightsDensity;
  89524. private _highlightsSaturation;
  89525. private _highlightsExposure;
  89526. /**
  89527. * Gets the highlights Hue value.
  89528. * 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).
  89529. */
  89530. /**
  89531. * Sets the highlights Hue value.
  89532. * 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).
  89533. */
  89534. highlightsHue: number;
  89535. /**
  89536. * Gets the highlights Density value.
  89537. * 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.
  89538. * Values less than zero provide a filter of opposite hue.
  89539. */
  89540. /**
  89541. * Sets 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. highlightsDensity: number;
  89546. /**
  89547. * Gets the highlights Saturation value.
  89548. * 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.
  89549. */
  89550. /**
  89551. * Sets the highlights Saturation value.
  89552. * 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.
  89553. */
  89554. highlightsSaturation: number;
  89555. /**
  89556. * Gets the highlights Exposure 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 exposure and negative values decrease exposure.
  89558. */
  89559. /**
  89560. * Sets the highlights Exposure value.
  89561. * 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.
  89562. */
  89563. highlightsExposure: number;
  89564. private _midtonesHue;
  89565. private _midtonesDensity;
  89566. private _midtonesSaturation;
  89567. private _midtonesExposure;
  89568. /**
  89569. * Gets the midtones Hue value.
  89570. * 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).
  89571. */
  89572. /**
  89573. * Sets the midtones Hue value.
  89574. * 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).
  89575. */
  89576. midtonesHue: number;
  89577. /**
  89578. * Gets the midtones Density value.
  89579. * 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.
  89580. * Values less than zero provide a filter of opposite hue.
  89581. */
  89582. /**
  89583. * Sets 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. midtonesDensity: number;
  89588. /**
  89589. * Gets the midtones Saturation value.
  89590. * 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.
  89591. */
  89592. /**
  89593. * Sets the midtones Saturation value.
  89594. * 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.
  89595. */
  89596. midtonesSaturation: number;
  89597. /**
  89598. * Gets the midtones Exposure 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 exposure and negative values decrease exposure.
  89600. */
  89601. /**
  89602. * Sets the midtones Exposure value.
  89603. * 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.
  89604. */
  89605. midtonesExposure: number;
  89606. private _shadowsHue;
  89607. private _shadowsDensity;
  89608. private _shadowsSaturation;
  89609. private _shadowsExposure;
  89610. /**
  89611. * Gets the shadows Hue value.
  89612. * 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).
  89613. */
  89614. /**
  89615. * Sets the shadows Hue value.
  89616. * 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).
  89617. */
  89618. shadowsHue: number;
  89619. /**
  89620. * Gets the shadows Density value.
  89621. * 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.
  89622. * Values less than zero provide a filter of opposite hue.
  89623. */
  89624. /**
  89625. * Sets 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. shadowsDensity: number;
  89630. /**
  89631. * Gets the shadows Saturation value.
  89632. * 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.
  89633. */
  89634. /**
  89635. * Sets the shadows Saturation value.
  89636. * 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.
  89637. */
  89638. shadowsSaturation: number;
  89639. /**
  89640. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  89642. */
  89643. /**
  89644. * Sets the shadows Exposure value.
  89645. * 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.
  89646. */
  89647. shadowsExposure: number;
  89648. /**
  89649. * Returns the class name
  89650. * @returns The class name
  89651. */
  89652. getClassName(): string;
  89653. /**
  89654. * Binds the color curves to the shader.
  89655. * @param colorCurves The color curve to bind
  89656. * @param effect The effect to bind to
  89657. * @param positiveUniform The positive uniform shader parameter
  89658. * @param neutralUniform The neutral uniform shader parameter
  89659. * @param negativeUniform The negative uniform shader parameter
  89660. */
  89661. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89662. /**
  89663. * Prepare the list of uniforms associated with the ColorCurves effects.
  89664. * @param uniformsList The list of uniforms used in the effect
  89665. */
  89666. static PrepareUniforms(uniformsList: string[]): void;
  89667. /**
  89668. * Returns color grading data based on a hue, density, saturation and exposure value.
  89669. * @param filterHue The hue of the color filter.
  89670. * @param filterDensity The density of the color filter.
  89671. * @param saturation The saturation.
  89672. * @param exposure The exposure.
  89673. * @param result The result data container.
  89674. */
  89675. private getColorGradingDataToRef;
  89676. /**
  89677. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89678. * @param value The input slider value in range [-100,100].
  89679. * @returns Adjusted value.
  89680. */
  89681. private static applyColorGradingSliderNonlinear;
  89682. /**
  89683. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89684. * @param hue The hue (H) input.
  89685. * @param saturation The saturation (S) input.
  89686. * @param brightness The brightness (B) input.
  89687. * @result An RGBA color represented as Vector4.
  89688. */
  89689. private static fromHSBToRef;
  89690. /**
  89691. * Returns a value clamped between min and max
  89692. * @param value The value to clamp
  89693. * @param min The minimum of value
  89694. * @param max The maximum of value
  89695. * @returns The clamped value.
  89696. */
  89697. private static clamp;
  89698. /**
  89699. * Clones the current color curve instance.
  89700. * @return The cloned curves
  89701. */
  89702. clone(): ColorCurves;
  89703. /**
  89704. * Serializes the current color curve instance to a json representation.
  89705. * @return a JSON representation
  89706. */
  89707. serialize(): any;
  89708. /**
  89709. * Parses the color curve from a json representation.
  89710. * @param source the JSON source to parse
  89711. * @return The parsed curves
  89712. */
  89713. static Parse(source: any): ColorCurves;
  89714. }
  89715. }
  89716. declare module BABYLON {
  89717. /**
  89718. * Interface to follow in your material defines to integrate easily the
  89719. * Image proccessing functions.
  89720. * @hidden
  89721. */
  89722. export interface IImageProcessingConfigurationDefines {
  89723. IMAGEPROCESSING: boolean;
  89724. VIGNETTE: boolean;
  89725. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89726. VIGNETTEBLENDMODEOPAQUE: boolean;
  89727. TONEMAPPING: boolean;
  89728. TONEMAPPING_ACES: boolean;
  89729. CONTRAST: boolean;
  89730. EXPOSURE: boolean;
  89731. COLORCURVES: boolean;
  89732. COLORGRADING: boolean;
  89733. COLORGRADING3D: boolean;
  89734. SAMPLER3DGREENDEPTH: boolean;
  89735. SAMPLER3DBGRMAP: boolean;
  89736. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89737. }
  89738. /**
  89739. * @hidden
  89740. */
  89741. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89742. IMAGEPROCESSING: boolean;
  89743. VIGNETTE: boolean;
  89744. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89745. VIGNETTEBLENDMODEOPAQUE: boolean;
  89746. TONEMAPPING: boolean;
  89747. TONEMAPPING_ACES: boolean;
  89748. CONTRAST: boolean;
  89749. COLORCURVES: boolean;
  89750. COLORGRADING: boolean;
  89751. COLORGRADING3D: boolean;
  89752. SAMPLER3DGREENDEPTH: boolean;
  89753. SAMPLER3DBGRMAP: boolean;
  89754. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89755. EXPOSURE: boolean;
  89756. constructor();
  89757. }
  89758. /**
  89759. * This groups together the common properties used for image processing either in direct forward pass
  89760. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89761. * or not.
  89762. */
  89763. export class ImageProcessingConfiguration {
  89764. /**
  89765. * Default tone mapping applied in BabylonJS.
  89766. */
  89767. static readonly TONEMAPPING_STANDARD: number;
  89768. /**
  89769. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89770. * to other engines rendering to increase portability.
  89771. */
  89772. static readonly TONEMAPPING_ACES: number;
  89773. /**
  89774. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89775. */
  89776. colorCurves: Nullable<ColorCurves>;
  89777. private _colorCurvesEnabled;
  89778. /**
  89779. * Gets wether the color curves effect is enabled.
  89780. */
  89781. /**
  89782. * Sets wether the color curves effect is enabled.
  89783. */
  89784. colorCurvesEnabled: boolean;
  89785. private _colorGradingTexture;
  89786. /**
  89787. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89788. */
  89789. /**
  89790. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89791. */
  89792. colorGradingTexture: Nullable<BaseTexture>;
  89793. private _colorGradingEnabled;
  89794. /**
  89795. * Gets wether the color grading effect is enabled.
  89796. */
  89797. /**
  89798. * Sets wether the color grading effect is enabled.
  89799. */
  89800. colorGradingEnabled: boolean;
  89801. private _colorGradingWithGreenDepth;
  89802. /**
  89803. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89804. */
  89805. /**
  89806. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89807. */
  89808. colorGradingWithGreenDepth: boolean;
  89809. private _colorGradingBGR;
  89810. /**
  89811. * Gets wether the color grading texture contains BGR values.
  89812. */
  89813. /**
  89814. * Sets wether the color grading texture contains BGR values.
  89815. */
  89816. colorGradingBGR: boolean;
  89817. /** @hidden */
  89818. _exposure: number;
  89819. /**
  89820. * Gets the Exposure used in the effect.
  89821. */
  89822. /**
  89823. * Sets the Exposure used in the effect.
  89824. */
  89825. exposure: number;
  89826. private _toneMappingEnabled;
  89827. /**
  89828. * Gets wether the tone mapping effect is enabled.
  89829. */
  89830. /**
  89831. * Sets wether the tone mapping effect is enabled.
  89832. */
  89833. toneMappingEnabled: boolean;
  89834. private _toneMappingType;
  89835. /**
  89836. * Gets the type of tone mapping effect.
  89837. */
  89838. /**
  89839. * Sets the type of tone mapping effect used in BabylonJS.
  89840. */
  89841. toneMappingType: number;
  89842. protected _contrast: number;
  89843. /**
  89844. * Gets the contrast used in the effect.
  89845. */
  89846. /**
  89847. * Sets the contrast used in the effect.
  89848. */
  89849. contrast: number;
  89850. /**
  89851. * Vignette stretch size.
  89852. */
  89853. vignetteStretch: number;
  89854. /**
  89855. * Vignette centre X Offset.
  89856. */
  89857. vignetteCentreX: number;
  89858. /**
  89859. * Vignette centre Y Offset.
  89860. */
  89861. vignetteCentreY: number;
  89862. /**
  89863. * Vignette weight or intensity of the vignette effect.
  89864. */
  89865. vignetteWeight: number;
  89866. /**
  89867. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89868. * if vignetteEnabled is set to true.
  89869. */
  89870. vignetteColor: Color4;
  89871. /**
  89872. * Camera field of view used by the Vignette effect.
  89873. */
  89874. vignetteCameraFov: number;
  89875. private _vignetteBlendMode;
  89876. /**
  89877. * Gets the vignette blend mode allowing different kind of effect.
  89878. */
  89879. /**
  89880. * Sets the vignette blend mode allowing different kind of effect.
  89881. */
  89882. vignetteBlendMode: number;
  89883. private _vignetteEnabled;
  89884. /**
  89885. * Gets wether the vignette effect is enabled.
  89886. */
  89887. /**
  89888. * Sets wether the vignette effect is enabled.
  89889. */
  89890. vignetteEnabled: boolean;
  89891. private _applyByPostProcess;
  89892. /**
  89893. * Gets wether the image processing is applied through a post process or not.
  89894. */
  89895. /**
  89896. * Sets wether the image processing is applied through a post process or not.
  89897. */
  89898. applyByPostProcess: boolean;
  89899. private _isEnabled;
  89900. /**
  89901. * Gets wether the image processing is enabled or not.
  89902. */
  89903. /**
  89904. * Sets wether the image processing is enabled or not.
  89905. */
  89906. isEnabled: boolean;
  89907. /**
  89908. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89909. */
  89910. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89911. /**
  89912. * Method called each time the image processing information changes requires to recompile the effect.
  89913. */
  89914. protected _updateParameters(): void;
  89915. /**
  89916. * Gets the current class name.
  89917. * @return "ImageProcessingConfiguration"
  89918. */
  89919. getClassName(): string;
  89920. /**
  89921. * Prepare the list of uniforms associated with the Image Processing effects.
  89922. * @param uniforms The list of uniforms used in the effect
  89923. * @param defines the list of defines currently in use
  89924. */
  89925. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89926. /**
  89927. * Prepare the list of samplers associated with the Image Processing effects.
  89928. * @param samplersList The list of uniforms used in the effect
  89929. * @param defines the list of defines currently in use
  89930. */
  89931. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89932. /**
  89933. * Prepare the list of defines associated to the shader.
  89934. * @param defines the list of defines to complete
  89935. * @param forPostProcess Define if we are currently in post process mode or not
  89936. */
  89937. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89938. /**
  89939. * Returns true if all the image processing information are ready.
  89940. * @returns True if ready, otherwise, false
  89941. */
  89942. isReady(): boolean;
  89943. /**
  89944. * Binds the image processing to the shader.
  89945. * @param effect The effect to bind to
  89946. * @param aspectRatio Define the current aspect ratio of the effect
  89947. */
  89948. bind(effect: Effect, aspectRatio?: number): void;
  89949. /**
  89950. * Clones the current image processing instance.
  89951. * @return The cloned image processing
  89952. */
  89953. clone(): ImageProcessingConfiguration;
  89954. /**
  89955. * Serializes the current image processing instance to a json representation.
  89956. * @return a JSON representation
  89957. */
  89958. serialize(): any;
  89959. /**
  89960. * Parses the image processing from a json representation.
  89961. * @param source the JSON source to parse
  89962. * @return The parsed image processing
  89963. */
  89964. static Parse(source: any): ImageProcessingConfiguration;
  89965. private static _VIGNETTEMODE_MULTIPLY;
  89966. private static _VIGNETTEMODE_OPAQUE;
  89967. /**
  89968. * Used to apply the vignette as a mix with the pixel color.
  89969. */
  89970. static readonly VIGNETTEMODE_MULTIPLY: number;
  89971. /**
  89972. * Used to apply the vignette as a replacement of the pixel color.
  89973. */
  89974. static readonly VIGNETTEMODE_OPAQUE: number;
  89975. }
  89976. }
  89977. declare module BABYLON {
  89978. /**
  89979. * This represents all the required information to add a fresnel effect on a material:
  89980. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89981. */
  89982. export class FresnelParameters {
  89983. private _isEnabled;
  89984. /**
  89985. * Define if the fresnel effect is enable or not.
  89986. */
  89987. isEnabled: boolean;
  89988. /**
  89989. * Define the color used on edges (grazing angle)
  89990. */
  89991. leftColor: Color3;
  89992. /**
  89993. * Define the color used on center
  89994. */
  89995. rightColor: Color3;
  89996. /**
  89997. * Define bias applied to computed fresnel term
  89998. */
  89999. bias: number;
  90000. /**
  90001. * Defined the power exponent applied to fresnel term
  90002. */
  90003. power: number;
  90004. /**
  90005. * Clones the current fresnel and its valuues
  90006. * @returns a clone fresnel configuration
  90007. */
  90008. clone(): FresnelParameters;
  90009. /**
  90010. * Serializes the current fresnel parameters to a JSON representation.
  90011. * @return the JSON serialization
  90012. */
  90013. serialize(): any;
  90014. /**
  90015. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  90016. * @param parsedFresnelParameters Define the JSON representation
  90017. * @returns the parsed parameters
  90018. */
  90019. static Parse(parsedFresnelParameters: any): FresnelParameters;
  90020. }
  90021. }
  90022. declare module BABYLON {
  90023. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  90024. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90025. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90026. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90027. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90028. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90029. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90030. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90031. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90032. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90033. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90034. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90035. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90036. /**
  90037. * Decorator used to define property that can be serialized as reference to a camera
  90038. * @param sourceName defines the name of the property to decorate
  90039. */
  90040. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90041. /**
  90042. * Class used to help serialization objects
  90043. */
  90044. export class SerializationHelper {
  90045. /** hidden */
  90046. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  90047. /** hidden */
  90048. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  90049. /** hidden */
  90050. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  90051. /** hidden */
  90052. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  90053. /**
  90054. * Appends the serialized animations from the source animations
  90055. * @param source Source containing the animations
  90056. * @param destination Target to store the animations
  90057. */
  90058. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90059. /**
  90060. * Static function used to serialized a specific entity
  90061. * @param entity defines the entity to serialize
  90062. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  90063. * @returns a JSON compatible object representing the serialization of the entity
  90064. */
  90065. static Serialize<T>(entity: T, serializationObject?: any): any;
  90066. /**
  90067. * Creates a new entity from a serialization data object
  90068. * @param creationFunction defines a function used to instanciated the new entity
  90069. * @param source defines the source serialization data
  90070. * @param scene defines the hosting scene
  90071. * @param rootUrl defines the root url for resources
  90072. * @returns a new entity
  90073. */
  90074. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90075. /**
  90076. * Clones an object
  90077. * @param creationFunction defines the function used to instanciate the new object
  90078. * @param source defines the source object
  90079. * @returns the cloned object
  90080. */
  90081. static Clone<T>(creationFunction: () => T, source: T): T;
  90082. /**
  90083. * Instanciates a new object based on a source one (some data will be shared between both object)
  90084. * @param creationFunction defines the function used to instanciate the new object
  90085. * @param source defines the source object
  90086. * @returns the new object
  90087. */
  90088. static Instanciate<T>(creationFunction: () => T, source: T): T;
  90089. }
  90090. }
  90091. declare module BABYLON {
  90092. /**
  90093. * This is the base class of all the camera used in the application.
  90094. * @see http://doc.babylonjs.com/features/cameras
  90095. */
  90096. export class Camera extends Node {
  90097. /** @hidden */
  90098. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90099. /**
  90100. * This is the default projection mode used by the cameras.
  90101. * It helps recreating a feeling of perspective and better appreciate depth.
  90102. * This is the best way to simulate real life cameras.
  90103. */
  90104. static readonly PERSPECTIVE_CAMERA: number;
  90105. /**
  90106. * This helps creating camera with an orthographic mode.
  90107. * 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.
  90108. */
  90109. static readonly ORTHOGRAPHIC_CAMERA: number;
  90110. /**
  90111. * This is the default FOV mode for perspective cameras.
  90112. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90113. */
  90114. static readonly FOVMODE_VERTICAL_FIXED: number;
  90115. /**
  90116. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90117. */
  90118. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90119. /**
  90120. * This specifies ther is no need for a camera rig.
  90121. * Basically only one eye is rendered corresponding to the camera.
  90122. */
  90123. static readonly RIG_MODE_NONE: number;
  90124. /**
  90125. * Simulates a camera Rig with one blue eye and one red eye.
  90126. * This can be use with 3d blue and red glasses.
  90127. */
  90128. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90129. /**
  90130. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90131. */
  90132. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90133. /**
  90134. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90135. */
  90136. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90137. /**
  90138. * Defines that both eyes of the camera will be rendered over under each other.
  90139. */
  90140. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90141. /**
  90142. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90143. */
  90144. static readonly RIG_MODE_VR: number;
  90145. /**
  90146. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90147. */
  90148. static readonly RIG_MODE_WEBVR: number;
  90149. /**
  90150. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90151. */
  90152. static readonly RIG_MODE_CUSTOM: number;
  90153. /**
  90154. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90155. */
  90156. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90157. /**
  90158. * Define the input manager associated with the camera.
  90159. */
  90160. inputs: CameraInputsManager<Camera>;
  90161. /** @hidden */
  90162. _position: Vector3;
  90163. /**
  90164. * Define the current local position of the camera in the scene
  90165. */
  90166. position: Vector3;
  90167. /**
  90168. * The vector the camera should consider as up.
  90169. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90170. */
  90171. upVector: Vector3;
  90172. /**
  90173. * Define the current limit on the left side for an orthographic camera
  90174. * In scene unit
  90175. */
  90176. orthoLeft: Nullable<number>;
  90177. /**
  90178. * Define the current limit on the right side for an orthographic camera
  90179. * In scene unit
  90180. */
  90181. orthoRight: Nullable<number>;
  90182. /**
  90183. * Define the current limit on the bottom side for an orthographic camera
  90184. * In scene unit
  90185. */
  90186. orthoBottom: Nullable<number>;
  90187. /**
  90188. * Define the current limit on the top side for an orthographic camera
  90189. * In scene unit
  90190. */
  90191. orthoTop: Nullable<number>;
  90192. /**
  90193. * Field Of View is set in Radians. (default is 0.8)
  90194. */
  90195. fov: number;
  90196. /**
  90197. * Define the minimum distance the camera can see from.
  90198. * This is important to note that the depth buffer are not infinite and the closer it starts
  90199. * the more your scene might encounter depth fighting issue.
  90200. */
  90201. minZ: number;
  90202. /**
  90203. * Define the maximum distance the camera can see to.
  90204. * This is important to note that the depth buffer are not infinite and the further it end
  90205. * the more your scene might encounter depth fighting issue.
  90206. */
  90207. maxZ: number;
  90208. /**
  90209. * Define the default inertia of the camera.
  90210. * This helps giving a smooth feeling to the camera movement.
  90211. */
  90212. inertia: number;
  90213. /**
  90214. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  90215. */
  90216. mode: number;
  90217. /**
  90218. * Define wether the camera is intermediate.
  90219. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90220. */
  90221. isIntermediate: boolean;
  90222. /**
  90223. * Define the viewport of the camera.
  90224. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90225. */
  90226. viewport: Viewport;
  90227. /**
  90228. * Restricts the camera to viewing objects with the same layerMask.
  90229. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90230. */
  90231. layerMask: number;
  90232. /**
  90233. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90234. */
  90235. fovMode: number;
  90236. /**
  90237. * Rig mode of the camera.
  90238. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90239. * This is normally controlled byt the camera themselves as internal use.
  90240. */
  90241. cameraRigMode: number;
  90242. /**
  90243. * Defines the distance between both "eyes" in case of a RIG
  90244. */
  90245. interaxialDistance: number;
  90246. /**
  90247. * Defines if stereoscopic rendering is done side by side or over under.
  90248. */
  90249. isStereoscopicSideBySide: boolean;
  90250. /**
  90251. * 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
  90252. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90253. * else in the scene.
  90254. */
  90255. customRenderTargets: RenderTargetTexture[];
  90256. /**
  90257. * When set, the camera will render to this render target instead of the default canvas
  90258. */
  90259. outputRenderTarget: Nullable<RenderTargetTexture>;
  90260. /**
  90261. * Observable triggered when the camera view matrix has changed.
  90262. */
  90263. onViewMatrixChangedObservable: Observable<Camera>;
  90264. /**
  90265. * Observable triggered when the camera Projection matrix has changed.
  90266. */
  90267. onProjectionMatrixChangedObservable: Observable<Camera>;
  90268. /**
  90269. * Observable triggered when the inputs have been processed.
  90270. */
  90271. onAfterCheckInputsObservable: Observable<Camera>;
  90272. /**
  90273. * Observable triggered when reset has been called and applied to the camera.
  90274. */
  90275. onRestoreStateObservable: Observable<Camera>;
  90276. /** @hidden */
  90277. _cameraRigParams: any;
  90278. /** @hidden */
  90279. _rigCameras: Camera[];
  90280. /** @hidden */
  90281. _rigPostProcess: Nullable<PostProcess>;
  90282. protected _webvrViewMatrix: Matrix;
  90283. /** @hidden */
  90284. _skipRendering: boolean;
  90285. /** @hidden */
  90286. _projectionMatrix: Matrix;
  90287. /** @hidden */
  90288. _postProcesses: Nullable<PostProcess>[];
  90289. /** @hidden */
  90290. _activeMeshes: SmartArray<AbstractMesh>;
  90291. protected _globalPosition: Vector3;
  90292. /** hidden */
  90293. _computedViewMatrix: Matrix;
  90294. private _doNotComputeProjectionMatrix;
  90295. private _transformMatrix;
  90296. private _frustumPlanes;
  90297. private _refreshFrustumPlanes;
  90298. private _storedFov;
  90299. private _stateStored;
  90300. /**
  90301. * Instantiates a new camera object.
  90302. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90303. * @see http://doc.babylonjs.com/features/cameras
  90304. * @param name Defines the name of the camera in the scene
  90305. * @param position Defines the position of the camera
  90306. * @param scene Defines the scene the camera belongs too
  90307. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90308. */
  90309. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90310. /**
  90311. * Store current camera state (fov, position, etc..)
  90312. * @returns the camera
  90313. */
  90314. storeState(): Camera;
  90315. /**
  90316. * Restores the camera state values if it has been stored. You must call storeState() first
  90317. */
  90318. protected _restoreStateValues(): boolean;
  90319. /**
  90320. * Restored camera state. You must call storeState() first.
  90321. * @returns true if restored and false otherwise
  90322. */
  90323. restoreState(): boolean;
  90324. /**
  90325. * Gets the class name of the camera.
  90326. * @returns the class name
  90327. */
  90328. getClassName(): string;
  90329. /** @hidden */
  90330. readonly _isCamera: boolean;
  90331. /**
  90332. * Gets a string representation of the camera useful for debug purpose.
  90333. * @param fullDetails Defines that a more verboe level of logging is required
  90334. * @returns the string representation
  90335. */
  90336. toString(fullDetails?: boolean): string;
  90337. /**
  90338. * Gets the current world space position of the camera.
  90339. */
  90340. readonly globalPosition: Vector3;
  90341. /**
  90342. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90343. * @returns the active meshe list
  90344. */
  90345. getActiveMeshes(): SmartArray<AbstractMesh>;
  90346. /**
  90347. * Check wether a mesh is part of the current active mesh list of the camera
  90348. * @param mesh Defines the mesh to check
  90349. * @returns true if active, false otherwise
  90350. */
  90351. isActiveMesh(mesh: Mesh): boolean;
  90352. /**
  90353. * Is this camera ready to be used/rendered
  90354. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90355. * @return true if the camera is ready
  90356. */
  90357. isReady(completeCheck?: boolean): boolean;
  90358. /** @hidden */
  90359. _initCache(): void;
  90360. /** @hidden */
  90361. _updateCache(ignoreParentClass?: boolean): void;
  90362. /** @hidden */
  90363. _isSynchronized(): boolean;
  90364. /** @hidden */
  90365. _isSynchronizedViewMatrix(): boolean;
  90366. /** @hidden */
  90367. _isSynchronizedProjectionMatrix(): boolean;
  90368. /**
  90369. * Attach the input controls to a specific dom element to get the input from.
  90370. * @param element Defines the element the controls should be listened from
  90371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90372. */
  90373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90374. /**
  90375. * Detach the current controls from the specified dom element.
  90376. * @param element Defines the element to stop listening the inputs from
  90377. */
  90378. detachControl(element: HTMLElement): void;
  90379. /**
  90380. * Update the camera state according to the different inputs gathered during the frame.
  90381. */
  90382. update(): void;
  90383. /** @hidden */
  90384. _checkInputs(): void;
  90385. /** @hidden */
  90386. readonly rigCameras: Camera[];
  90387. /**
  90388. * Gets the post process used by the rig cameras
  90389. */
  90390. readonly rigPostProcess: Nullable<PostProcess>;
  90391. /**
  90392. * Internal, gets the first post proces.
  90393. * @returns the first post process to be run on this camera.
  90394. */
  90395. _getFirstPostProcess(): Nullable<PostProcess>;
  90396. private _cascadePostProcessesToRigCams;
  90397. /**
  90398. * Attach a post process to the camera.
  90399. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90400. * @param postProcess The post process to attach to the camera
  90401. * @param insertAt The position of the post process in case several of them are in use in the scene
  90402. * @returns the position the post process has been inserted at
  90403. */
  90404. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90405. /**
  90406. * Detach a post process to the camera.
  90407. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90408. * @param postProcess The post process to detach from the camera
  90409. */
  90410. detachPostProcess(postProcess: PostProcess): void;
  90411. /**
  90412. * Gets the current world matrix of the camera
  90413. */
  90414. getWorldMatrix(): Matrix;
  90415. /** @hidden */
  90416. _getViewMatrix(): Matrix;
  90417. /**
  90418. * Gets the current view matrix of the camera.
  90419. * @param force forces the camera to recompute the matrix without looking at the cached state
  90420. * @returns the view matrix
  90421. */
  90422. getViewMatrix(force?: boolean): Matrix;
  90423. /**
  90424. * Freeze the projection matrix.
  90425. * It will prevent the cache check of the camera projection compute and can speed up perf
  90426. * if no parameter of the camera are meant to change
  90427. * @param projection Defines manually a projection if necessary
  90428. */
  90429. freezeProjectionMatrix(projection?: Matrix): void;
  90430. /**
  90431. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90432. */
  90433. unfreezeProjectionMatrix(): void;
  90434. /**
  90435. * Gets the current projection matrix of the camera.
  90436. * @param force forces the camera to recompute the matrix without looking at the cached state
  90437. * @returns the projection matrix
  90438. */
  90439. getProjectionMatrix(force?: boolean): Matrix;
  90440. /**
  90441. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90442. * @returns a Matrix
  90443. */
  90444. getTransformationMatrix(): Matrix;
  90445. private _updateFrustumPlanes;
  90446. /**
  90447. * Checks if a cullable object (mesh...) is in the camera frustum
  90448. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90449. * @param target The object to check
  90450. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90451. * @returns true if the object is in frustum otherwise false
  90452. */
  90453. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90454. /**
  90455. * Checks if a cullable object (mesh...) is in the camera frustum
  90456. * Unlike isInFrustum this cheks the full bounding box
  90457. * @param target The object to check
  90458. * @returns true if the object is in frustum otherwise false
  90459. */
  90460. isCompletelyInFrustum(target: ICullable): boolean;
  90461. /**
  90462. * Gets a ray in the forward direction from the camera.
  90463. * @param length Defines the length of the ray to create
  90464. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90465. * @param origin Defines the start point of the ray which defaults to the camera position
  90466. * @returns the forward ray
  90467. */
  90468. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90469. /**
  90470. * Releases resources associated with this node.
  90471. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90472. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90473. */
  90474. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90475. /** @hidden */
  90476. _isLeftCamera: boolean;
  90477. /**
  90478. * Gets the left camera of a rig setup in case of Rigged Camera
  90479. */
  90480. readonly isLeftCamera: boolean;
  90481. /** @hidden */
  90482. _isRightCamera: boolean;
  90483. /**
  90484. * Gets the right camera of a rig setup in case of Rigged Camera
  90485. */
  90486. readonly isRightCamera: boolean;
  90487. /**
  90488. * Gets the left camera of a rig setup in case of Rigged Camera
  90489. */
  90490. readonly leftCamera: Nullable<FreeCamera>;
  90491. /**
  90492. * Gets the right camera of a rig setup in case of Rigged Camera
  90493. */
  90494. readonly rightCamera: Nullable<FreeCamera>;
  90495. /**
  90496. * Gets the left camera target of a rig setup in case of Rigged Camera
  90497. * @returns the target position
  90498. */
  90499. getLeftTarget(): Nullable<Vector3>;
  90500. /**
  90501. * Gets the right camera target of a rig setup in case of Rigged Camera
  90502. * @returns the target position
  90503. */
  90504. getRightTarget(): Nullable<Vector3>;
  90505. /**
  90506. * @hidden
  90507. */
  90508. setCameraRigMode(mode: number, rigParams: any): void;
  90509. /** @hidden */
  90510. static _setStereoscopicRigMode(camera: Camera): void;
  90511. /** @hidden */
  90512. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90513. /** @hidden */
  90514. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90515. /** @hidden */
  90516. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90517. /** @hidden */
  90518. _getVRProjectionMatrix(): Matrix;
  90519. protected _updateCameraRotationMatrix(): void;
  90520. protected _updateWebVRCameraRotationMatrix(): void;
  90521. /**
  90522. * This function MUST be overwritten by the different WebVR cameras available.
  90523. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90524. * @hidden
  90525. */
  90526. _getWebVRProjectionMatrix(): Matrix;
  90527. /**
  90528. * This function MUST be overwritten by the different WebVR cameras available.
  90529. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90530. * @hidden
  90531. */
  90532. _getWebVRViewMatrix(): Matrix;
  90533. /** @hidden */
  90534. setCameraRigParameter(name: string, value: any): void;
  90535. /**
  90536. * needs to be overridden by children so sub has required properties to be copied
  90537. * @hidden
  90538. */
  90539. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90540. /**
  90541. * May need to be overridden by children
  90542. * @hidden
  90543. */
  90544. _updateRigCameras(): void;
  90545. /** @hidden */
  90546. _setupInputs(): void;
  90547. /**
  90548. * Serialiaze the camera setup to a json represention
  90549. * @returns the JSON representation
  90550. */
  90551. serialize(): any;
  90552. /**
  90553. * Clones the current camera.
  90554. * @param name The cloned camera name
  90555. * @returns the cloned camera
  90556. */
  90557. clone(name: string): Camera;
  90558. /**
  90559. * Gets the direction of the camera relative to a given local axis.
  90560. * @param localAxis Defines the reference axis to provide a relative direction.
  90561. * @return the direction
  90562. */
  90563. getDirection(localAxis: Vector3): Vector3;
  90564. /**
  90565. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90566. * @param localAxis Defines the reference axis to provide a relative direction.
  90567. * @param result Defines the vector to store the result in
  90568. */
  90569. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90570. /**
  90571. * Gets a camera constructor for a given camera type
  90572. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90573. * @param name The name of the camera the result will be able to instantiate
  90574. * @param scene The scene the result will construct the camera in
  90575. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90576. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90577. * @returns a factory method to construc the camera
  90578. */
  90579. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90580. /**
  90581. * Compute the world matrix of the camera.
  90582. * @returns the camera workd matrix
  90583. */
  90584. computeWorldMatrix(): Matrix;
  90585. /**
  90586. * Parse a JSON and creates the camera from the parsed information
  90587. * @param parsedCamera The JSON to parse
  90588. * @param scene The scene to instantiate the camera in
  90589. * @returns the newly constructed camera
  90590. */
  90591. static Parse(parsedCamera: any, scene: Scene): Camera;
  90592. }
  90593. }
  90594. declare module BABYLON {
  90595. /**
  90596. * Interface for any object that can request an animation frame
  90597. */
  90598. export interface ICustomAnimationFrameRequester {
  90599. /**
  90600. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90601. */
  90602. renderFunction?: Function;
  90603. /**
  90604. * Called to request the next frame to render to
  90605. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90606. */
  90607. requestAnimationFrame: Function;
  90608. /**
  90609. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90610. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90611. */
  90612. requestID?: number;
  90613. }
  90614. /**
  90615. * Interface containing an array of animations
  90616. */
  90617. export interface IAnimatable {
  90618. /**
  90619. * Array of animations
  90620. */
  90621. animations: Nullable<Array<Animation>>;
  90622. }
  90623. /** Interface used by value gradients (color, factor, ...) */
  90624. export interface IValueGradient {
  90625. /**
  90626. * Gets or sets the gradient value (between 0 and 1)
  90627. */
  90628. gradient: number;
  90629. }
  90630. /** Class used to store color4 gradient */
  90631. export class ColorGradient implements IValueGradient {
  90632. /**
  90633. * Gets or sets the gradient value (between 0 and 1)
  90634. */
  90635. gradient: number;
  90636. /**
  90637. * Gets or sets first associated color
  90638. */
  90639. color1: Color4;
  90640. /**
  90641. * Gets or sets second associated color
  90642. */
  90643. color2?: Color4;
  90644. /**
  90645. * Will get a color picked randomly between color1 and color2.
  90646. * If color2 is undefined then color1 will be used
  90647. * @param result defines the target Color4 to store the result in
  90648. */
  90649. getColorToRef(result: Color4): void;
  90650. }
  90651. /** Class used to store color 3 gradient */
  90652. export class Color3Gradient implements IValueGradient {
  90653. /**
  90654. * Gets or sets the gradient value (between 0 and 1)
  90655. */
  90656. gradient: number;
  90657. /**
  90658. * Gets or sets the associated color
  90659. */
  90660. color: Color3;
  90661. }
  90662. /** Class used to store factor gradient */
  90663. export class FactorGradient implements IValueGradient {
  90664. /**
  90665. * Gets or sets the gradient value (between 0 and 1)
  90666. */
  90667. gradient: number;
  90668. /**
  90669. * Gets or sets first associated factor
  90670. */
  90671. factor1: number;
  90672. /**
  90673. * Gets or sets second associated factor
  90674. */
  90675. factor2?: number;
  90676. /**
  90677. * Will get a number picked randomly between factor1 and factor2.
  90678. * If factor2 is undefined then factor1 will be used
  90679. * @returns the picked number
  90680. */
  90681. getFactor(): number;
  90682. }
  90683. /**
  90684. * @ignore
  90685. * Application error to support additional information when loading a file
  90686. */
  90687. export class LoadFileError extends Error {
  90688. /** defines the optional web request */
  90689. request?: WebRequest | undefined;
  90690. private static _setPrototypeOf;
  90691. /**
  90692. * Creates a new LoadFileError
  90693. * @param message defines the message of the error
  90694. * @param request defines the optional web request
  90695. */
  90696. constructor(message: string,
  90697. /** defines the optional web request */
  90698. request?: WebRequest | undefined);
  90699. }
  90700. /**
  90701. * Class used to define a retry strategy when error happens while loading assets
  90702. */
  90703. export class RetryStrategy {
  90704. /**
  90705. * Function used to defines an exponential back off strategy
  90706. * @param maxRetries defines the maximum number of retries (3 by default)
  90707. * @param baseInterval defines the interval between retries
  90708. * @returns the strategy function to use
  90709. */
  90710. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90711. }
  90712. /**
  90713. * File request interface
  90714. */
  90715. export interface IFileRequest {
  90716. /**
  90717. * Raised when the request is complete (success or error).
  90718. */
  90719. onCompleteObservable: Observable<IFileRequest>;
  90720. /**
  90721. * Aborts the request for a file.
  90722. */
  90723. abort: () => void;
  90724. }
  90725. /**
  90726. * Class containing a set of static utilities functions
  90727. */
  90728. export class Tools {
  90729. /**
  90730. * Gets or sets the base URL to use to load assets
  90731. */
  90732. static BaseUrl: string;
  90733. /**
  90734. * Enable/Disable Custom HTTP Request Headers globally.
  90735. * default = false
  90736. * @see CustomRequestHeaders
  90737. */
  90738. static UseCustomRequestHeaders: boolean;
  90739. /**
  90740. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90741. * i.e. when loading files, where the server/service expects an Authorization header
  90742. */
  90743. static CustomRequestHeaders: {
  90744. [key: string]: string;
  90745. };
  90746. /**
  90747. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90748. */
  90749. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90750. /**
  90751. * Default behaviour for cors in the application.
  90752. * It can be a string if the expected behavior is identical in the entire app.
  90753. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90754. */
  90755. static CorsBehavior: string | ((url: string | string[]) => string);
  90756. /**
  90757. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90758. * @ignorenaming
  90759. */
  90760. static UseFallbackTexture: boolean;
  90761. /**
  90762. * Use this object to register external classes like custom textures or material
  90763. * to allow the laoders to instantiate them
  90764. */
  90765. static RegisteredExternalClasses: {
  90766. [key: string]: Object;
  90767. };
  90768. /**
  90769. * Texture content used if a texture cannot loaded
  90770. * @ignorenaming
  90771. */
  90772. static fallbackTexture: string;
  90773. /**
  90774. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90775. * @param u defines the coordinate on X axis
  90776. * @param v defines the coordinate on Y axis
  90777. * @param width defines the width of the source data
  90778. * @param height defines the height of the source data
  90779. * @param pixels defines the source byte array
  90780. * @param color defines the output color
  90781. */
  90782. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90783. /**
  90784. * Interpolates between a and b via alpha
  90785. * @param a The lower value (returned when alpha = 0)
  90786. * @param b The upper value (returned when alpha = 1)
  90787. * @param alpha The interpolation-factor
  90788. * @return The mixed value
  90789. */
  90790. static Mix(a: number, b: number, alpha: number): number;
  90791. /**
  90792. * Tries to instantiate a new object from a given class name
  90793. * @param className defines the class name to instantiate
  90794. * @returns the new object or null if the system was not able to do the instantiation
  90795. */
  90796. static Instantiate(className: string): any;
  90797. /**
  90798. * Provides a slice function that will work even on IE
  90799. * @param data defines the array to slice
  90800. * @param start defines the start of the data (optional)
  90801. * @param end defines the end of the data (optional)
  90802. * @returns the new sliced array
  90803. */
  90804. static Slice<T>(data: T, start?: number, end?: number): T;
  90805. /**
  90806. * Polyfill for setImmediate
  90807. * @param action defines the action to execute after the current execution block
  90808. */
  90809. static SetImmediate(action: () => void): void;
  90810. /**
  90811. * Function indicating if a number is an exponent of 2
  90812. * @param value defines the value to test
  90813. * @returns true if the value is an exponent of 2
  90814. */
  90815. static IsExponentOfTwo(value: number): boolean;
  90816. private static _tmpFloatArray;
  90817. /**
  90818. * Returns the nearest 32-bit single precision float representation of a Number
  90819. * @param value A Number. If the parameter is of a different type, it will get converted
  90820. * to a number or to NaN if it cannot be converted
  90821. * @returns number
  90822. */
  90823. static FloatRound(value: number): number;
  90824. /**
  90825. * Find the next highest power of two.
  90826. * @param x Number to start search from.
  90827. * @return Next highest power of two.
  90828. */
  90829. static CeilingPOT(x: number): number;
  90830. /**
  90831. * Find the next lowest power of two.
  90832. * @param x Number to start search from.
  90833. * @return Next lowest power of two.
  90834. */
  90835. static FloorPOT(x: number): number;
  90836. /**
  90837. * Find the nearest power of two.
  90838. * @param x Number to start search from.
  90839. * @return Next nearest power of two.
  90840. */
  90841. static NearestPOT(x: number): number;
  90842. /**
  90843. * Get the closest exponent of two
  90844. * @param value defines the value to approximate
  90845. * @param max defines the maximum value to return
  90846. * @param mode defines how to define the closest value
  90847. * @returns closest exponent of two of the given value
  90848. */
  90849. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90850. /**
  90851. * Extracts the filename from a path
  90852. * @param path defines the path to use
  90853. * @returns the filename
  90854. */
  90855. static GetFilename(path: string): string;
  90856. /**
  90857. * Extracts the "folder" part of a path (everything before the filename).
  90858. * @param uri The URI to extract the info from
  90859. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90860. * @returns The "folder" part of the path
  90861. */
  90862. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90863. /**
  90864. * Extracts text content from a DOM element hierarchy
  90865. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90866. */
  90867. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90868. /**
  90869. * Convert an angle in radians to degrees
  90870. * @param angle defines the angle to convert
  90871. * @returns the angle in degrees
  90872. */
  90873. static ToDegrees(angle: number): number;
  90874. /**
  90875. * Convert an angle in degrees to radians
  90876. * @param angle defines the angle to convert
  90877. * @returns the angle in radians
  90878. */
  90879. static ToRadians(angle: number): number;
  90880. /**
  90881. * Encode a buffer to a base64 string
  90882. * @param buffer defines the buffer to encode
  90883. * @returns the encoded string
  90884. */
  90885. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90886. /**
  90887. * Extracts minimum and maximum values from a list of indexed positions
  90888. * @param positions defines the positions to use
  90889. * @param indices defines the indices to the positions
  90890. * @param indexStart defines the start index
  90891. * @param indexCount defines the end index
  90892. * @param bias defines bias value to add to the result
  90893. * @return minimum and maximum values
  90894. */
  90895. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90896. minimum: Vector3;
  90897. maximum: Vector3;
  90898. };
  90899. /**
  90900. * Extracts minimum and maximum values from a list of positions
  90901. * @param positions defines the positions to use
  90902. * @param start defines the start index in the positions array
  90903. * @param count defines the number of positions to handle
  90904. * @param bias defines bias value to add to the result
  90905. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90906. * @return minimum and maximum values
  90907. */
  90908. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90909. minimum: Vector3;
  90910. maximum: Vector3;
  90911. };
  90912. /**
  90913. * Returns an array if obj is not an array
  90914. * @param obj defines the object to evaluate as an array
  90915. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90916. * @returns either obj directly if obj is an array or a new array containing obj
  90917. */
  90918. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90919. /**
  90920. * Gets the pointer prefix to use
  90921. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90922. */
  90923. static GetPointerPrefix(): string;
  90924. /**
  90925. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90926. * @param func - the function to be called
  90927. * @param requester - the object that will request the next frame. Falls back to window.
  90928. * @returns frame number
  90929. */
  90930. static QueueNewFrame(func: () => void, requester?: any): number;
  90931. /**
  90932. * Ask the browser to promote the current element to fullscreen rendering mode
  90933. * @param element defines the DOM element to promote
  90934. */
  90935. static RequestFullscreen(element: HTMLElement): void;
  90936. /**
  90937. * Asks the browser to exit fullscreen mode
  90938. */
  90939. static ExitFullscreen(): void;
  90940. /**
  90941. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90942. * @param url define the url we are trying
  90943. * @param element define the dom element where to configure the cors policy
  90944. */
  90945. static SetCorsBehavior(url: string | string[], element: {
  90946. crossOrigin: string | null;
  90947. }): void;
  90948. /**
  90949. * Removes unwanted characters from an url
  90950. * @param url defines the url to clean
  90951. * @returns the cleaned url
  90952. */
  90953. static CleanUrl(url: string): string;
  90954. /**
  90955. * Gets or sets a function used to pre-process url before using them to load assets
  90956. */
  90957. static PreprocessUrl: (url: string) => string;
  90958. /**
  90959. * Loads an image as an HTMLImageElement.
  90960. * @param input url string, ArrayBuffer, or Blob to load
  90961. * @param onLoad callback called when the image successfully loads
  90962. * @param onError callback called when the image fails to load
  90963. * @param offlineProvider offline provider for caching
  90964. * @returns the HTMLImageElement of the loaded image
  90965. */
  90966. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90967. /**
  90968. * Loads a file
  90969. * @param url url string, ArrayBuffer, or Blob to load
  90970. * @param onSuccess callback called when the file successfully loads
  90971. * @param onProgress callback called while file is loading (if the server supports this mode)
  90972. * @param offlineProvider defines the offline provider for caching
  90973. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90974. * @param onError callback called when the file fails to load
  90975. * @returns a file request object
  90976. */
  90977. 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;
  90978. /**
  90979. * Load a script (identified by an url). When the url returns, the
  90980. * content of this file is added into a new script element, attached to the DOM (body element)
  90981. * @param scriptUrl defines the url of the script to laod
  90982. * @param onSuccess defines the callback called when the script is loaded
  90983. * @param onError defines the callback to call if an error occurs
  90984. * @param scriptId defines the id of the script element
  90985. */
  90986. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90987. /**
  90988. * Load an asynchronous script (identified by an url). When the url returns, the
  90989. * content of this file is added into a new script element, attached to the DOM (body element)
  90990. * @param scriptUrl defines the url of the script to laod
  90991. * @param scriptId defines the id of the script element
  90992. * @returns a promise request object
  90993. */
  90994. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90995. /**
  90996. * Loads a file from a blob
  90997. * @param fileToLoad defines the blob to use
  90998. * @param callback defines the callback to call when data is loaded
  90999. * @param progressCallback defines the callback to call during loading process
  91000. * @returns a file request object
  91001. */
  91002. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  91003. /**
  91004. * Loads a file
  91005. * @param fileToLoad defines the file to load
  91006. * @param callback defines the callback to call when data is loaded
  91007. * @param progressCallBack defines the callback to call during loading process
  91008. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  91009. * @returns a file request object
  91010. */
  91011. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  91012. /**
  91013. * Creates a data url from a given string content
  91014. * @param content defines the content to convert
  91015. * @returns the new data url link
  91016. */
  91017. static FileAsURL(content: string): string;
  91018. /**
  91019. * Format the given number to a specific decimal format
  91020. * @param value defines the number to format
  91021. * @param decimals defines the number of decimals to use
  91022. * @returns the formatted string
  91023. */
  91024. static Format(value: number, decimals?: number): string;
  91025. /**
  91026. * Checks if a given vector is inside a specific range
  91027. * @param v defines the vector to test
  91028. * @param min defines the minimum range
  91029. * @param max defines the maximum range
  91030. */
  91031. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  91032. /**
  91033. * Tries to copy an object by duplicating every property
  91034. * @param source defines the source object
  91035. * @param destination defines the target object
  91036. * @param doNotCopyList defines a list of properties to avoid
  91037. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  91038. */
  91039. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  91040. /**
  91041. * Gets a boolean indicating if the given object has no own property
  91042. * @param obj defines the object to test
  91043. * @returns true if object has no own property
  91044. */
  91045. static IsEmpty(obj: any): boolean;
  91046. /**
  91047. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  91048. * @param str Source string
  91049. * @param suffix Suffix to search for in the source string
  91050. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  91051. */
  91052. static EndsWith(str: string, suffix: string): boolean;
  91053. /**
  91054. * Function used to register events at window level
  91055. * @param events defines the events to register
  91056. */
  91057. static RegisterTopRootEvents(events: {
  91058. name: string;
  91059. handler: Nullable<(e: FocusEvent) => any>;
  91060. }[]): void;
  91061. /**
  91062. * Function used to unregister events from window level
  91063. * @param events defines the events to unregister
  91064. */
  91065. static UnregisterTopRootEvents(events: {
  91066. name: string;
  91067. handler: Nullable<(e: FocusEvent) => any>;
  91068. }[]): void;
  91069. /**
  91070. * @ignore
  91071. */
  91072. static _ScreenshotCanvas: HTMLCanvasElement;
  91073. /**
  91074. * Dumps the current bound framebuffer
  91075. * @param width defines the rendering width
  91076. * @param height defines the rendering height
  91077. * @param engine defines the hosting engine
  91078. * @param successCallback defines the callback triggered once the data are available
  91079. * @param mimeType defines the mime type of the result
  91080. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  91081. */
  91082. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91083. /**
  91084. * Converts the canvas data to blob.
  91085. * This acts as a polyfill for browsers not supporting the to blob function.
  91086. * @param canvas Defines the canvas to extract the data from
  91087. * @param successCallback Defines the callback triggered once the data are available
  91088. * @param mimeType Defines the mime type of the result
  91089. */
  91090. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  91091. /**
  91092. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  91093. * @param successCallback defines the callback triggered once the data are available
  91094. * @param mimeType defines the mime type of the result
  91095. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  91096. */
  91097. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91098. /**
  91099. * Downloads a blob in the browser
  91100. * @param blob defines the blob to download
  91101. * @param fileName defines the name of the downloaded file
  91102. */
  91103. static Download(blob: Blob, fileName: string): void;
  91104. /**
  91105. * Captures a screenshot of the current rendering
  91106. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91107. * @param engine defines the rendering engine
  91108. * @param camera defines the source camera
  91109. * @param size This parameter can be set to a single number or to an object with the
  91110. * following (optional) properties: precision, width, height. If a single number is passed,
  91111. * it will be used for both width and height. If an object is passed, the screenshot size
  91112. * will be derived from the parameters. The precision property is a multiplier allowing
  91113. * rendering at a higher or lower resolution
  91114. * @param successCallback defines the callback receives a single parameter which contains the
  91115. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91116. * src parameter of an <img> to display it
  91117. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  91118. * Check your browser for supported MIME types
  91119. */
  91120. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  91121. /**
  91122. * Generates an image screenshot from the specified camera.
  91123. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91124. * @param engine The engine to use for rendering
  91125. * @param camera The camera to use for rendering
  91126. * @param size This parameter can be set to a single number or to an object with the
  91127. * following (optional) properties: precision, width, height. If a single number is passed,
  91128. * it will be used for both width and height. If an object is passed, the screenshot size
  91129. * will be derived from the parameters. The precision property is a multiplier allowing
  91130. * rendering at a higher or lower resolution
  91131. * @param successCallback The callback receives a single parameter which contains the
  91132. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91133. * src parameter of an <img> to display it
  91134. * @param mimeType The MIME type of the screenshot image (default: image/png).
  91135. * Check your browser for supported MIME types
  91136. * @param samples Texture samples (default: 1)
  91137. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  91138. * @param fileName A name for for the downloaded file.
  91139. */
  91140. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  91141. /**
  91142. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91143. * Be aware Math.random() could cause collisions, but:
  91144. * "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"
  91145. * @returns a pseudo random id
  91146. */
  91147. static RandomId(): string;
  91148. /**
  91149. * Test if the given uri is a base64 string
  91150. * @param uri The uri to test
  91151. * @return True if the uri is a base64 string or false otherwise
  91152. */
  91153. static IsBase64(uri: string): boolean;
  91154. /**
  91155. * Decode the given base64 uri.
  91156. * @param uri The uri to decode
  91157. * @return The decoded base64 data.
  91158. */
  91159. static DecodeBase64(uri: string): ArrayBuffer;
  91160. /**
  91161. * Gets the absolute url.
  91162. * @param url the input url
  91163. * @return the absolute url
  91164. */
  91165. static GetAbsoluteUrl(url: string): string;
  91166. /**
  91167. * No log
  91168. */
  91169. static readonly NoneLogLevel: number;
  91170. /**
  91171. * Only message logs
  91172. */
  91173. static readonly MessageLogLevel: number;
  91174. /**
  91175. * Only warning logs
  91176. */
  91177. static readonly WarningLogLevel: number;
  91178. /**
  91179. * Only error logs
  91180. */
  91181. static readonly ErrorLogLevel: number;
  91182. /**
  91183. * All logs
  91184. */
  91185. static readonly AllLogLevel: number;
  91186. /**
  91187. * Gets a value indicating the number of loading errors
  91188. * @ignorenaming
  91189. */
  91190. static readonly errorsCount: number;
  91191. /**
  91192. * Callback called when a new log is added
  91193. */
  91194. static OnNewCacheEntry: (entry: string) => void;
  91195. /**
  91196. * Log a message to the console
  91197. * @param message defines the message to log
  91198. */
  91199. static Log(message: string): void;
  91200. /**
  91201. * Write a warning message to the console
  91202. * @param message defines the message to log
  91203. */
  91204. static Warn(message: string): void;
  91205. /**
  91206. * Write an error message to the console
  91207. * @param message defines the message to log
  91208. */
  91209. static Error(message: string): void;
  91210. /**
  91211. * Gets current log cache (list of logs)
  91212. */
  91213. static readonly LogCache: string;
  91214. /**
  91215. * Clears the log cache
  91216. */
  91217. static ClearLogCache(): void;
  91218. /**
  91219. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  91220. */
  91221. static LogLevels: number;
  91222. /**
  91223. * Checks if the loaded document was accessed via `file:`-Protocol.
  91224. * @returns boolean
  91225. */
  91226. static IsFileURL(): boolean;
  91227. /**
  91228. * Checks if the window object exists
  91229. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  91230. */
  91231. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  91232. /**
  91233. * No performance log
  91234. */
  91235. static readonly PerformanceNoneLogLevel: number;
  91236. /**
  91237. * Use user marks to log performance
  91238. */
  91239. static readonly PerformanceUserMarkLogLevel: number;
  91240. /**
  91241. * Log performance to the console
  91242. */
  91243. static readonly PerformanceConsoleLogLevel: number;
  91244. private static _performance;
  91245. /**
  91246. * Sets the current performance log level
  91247. */
  91248. static PerformanceLogLevel: number;
  91249. private static _StartPerformanceCounterDisabled;
  91250. private static _EndPerformanceCounterDisabled;
  91251. private static _StartUserMark;
  91252. private static _EndUserMark;
  91253. private static _StartPerformanceConsole;
  91254. private static _EndPerformanceConsole;
  91255. /**
  91256. * Starts a performance counter
  91257. */
  91258. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91259. /**
  91260. * Ends a specific performance coutner
  91261. */
  91262. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91263. /**
  91264. * Gets either window.performance.now() if supported or Date.now() else
  91265. */
  91266. static readonly Now: number;
  91267. /**
  91268. * This method will return the name of the class used to create the instance of the given object.
  91269. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  91270. * @param object the object to get the class name from
  91271. * @param isType defines if the object is actually a type
  91272. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  91273. */
  91274. static GetClassName(object: any, isType?: boolean): string;
  91275. /**
  91276. * Gets the first element of an array satisfying a given predicate
  91277. * @param array defines the array to browse
  91278. * @param predicate defines the predicate to use
  91279. * @returns null if not found or the element
  91280. */
  91281. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  91282. /**
  91283. * This method will return the name of the full name of the class, including its owning module (if any).
  91284. * 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).
  91285. * @param object the object to get the class name from
  91286. * @param isType defines if the object is actually a type
  91287. * @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.
  91288. * @ignorenaming
  91289. */
  91290. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  91291. /**
  91292. * Returns a promise that resolves after the given amount of time.
  91293. * @param delay Number of milliseconds to delay
  91294. * @returns Promise that resolves after the given amount of time
  91295. */
  91296. static DelayAsync(delay: number): Promise<void>;
  91297. /**
  91298. * Gets the current gradient from an array of IValueGradient
  91299. * @param ratio defines the current ratio to get
  91300. * @param gradients defines the array of IValueGradient
  91301. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91302. */
  91303. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91304. }
  91305. /**
  91306. * This class is used to track a performance counter which is number based.
  91307. * The user has access to many properties which give statistics of different nature.
  91308. *
  91309. * The implementer can track two kinds of Performance Counter: time and count.
  91310. * 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.
  91311. * 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.
  91312. */
  91313. export class PerfCounter {
  91314. /**
  91315. * Gets or sets a global boolean to turn on and off all the counters
  91316. */
  91317. static Enabled: boolean;
  91318. /**
  91319. * Returns the smallest value ever
  91320. */
  91321. readonly min: number;
  91322. /**
  91323. * Returns the biggest value ever
  91324. */
  91325. readonly max: number;
  91326. /**
  91327. * Returns the average value since the performance counter is running
  91328. */
  91329. readonly average: number;
  91330. /**
  91331. * Returns the average value of the last second the counter was monitored
  91332. */
  91333. readonly lastSecAverage: number;
  91334. /**
  91335. * Returns the current value
  91336. */
  91337. readonly current: number;
  91338. /**
  91339. * Gets the accumulated total
  91340. */
  91341. readonly total: number;
  91342. /**
  91343. * Gets the total value count
  91344. */
  91345. readonly count: number;
  91346. /**
  91347. * Creates a new counter
  91348. */
  91349. constructor();
  91350. /**
  91351. * Call this method to start monitoring a new frame.
  91352. * 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.
  91353. */
  91354. fetchNewFrame(): void;
  91355. /**
  91356. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  91357. * @param newCount the count value to add to the monitored count
  91358. * @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.
  91359. */
  91360. addCount(newCount: number, fetchResult: boolean): void;
  91361. /**
  91362. * Start monitoring this performance counter
  91363. */
  91364. beginMonitoring(): void;
  91365. /**
  91366. * Compute the time lapsed since the previous beginMonitoring() call.
  91367. * @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
  91368. */
  91369. endMonitoring(newFrame?: boolean): void;
  91370. private _fetchResult;
  91371. private _startMonitoringTime;
  91372. private _min;
  91373. private _max;
  91374. private _average;
  91375. private _current;
  91376. private _totalValueCount;
  91377. private _totalAccumulated;
  91378. private _lastSecAverage;
  91379. private _lastSecAccumulated;
  91380. private _lastSecTime;
  91381. private _lastSecValueCount;
  91382. }
  91383. /**
  91384. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  91385. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  91386. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  91387. * @param name The name of the class, case should be preserved
  91388. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  91389. */
  91390. export function className(name: string, module?: string): (target: Object) => void;
  91391. /**
  91392. * An implementation of a loop for asynchronous functions.
  91393. */
  91394. export class AsyncLoop {
  91395. /**
  91396. * Defines the number of iterations for the loop
  91397. */
  91398. iterations: number;
  91399. /**
  91400. * Defines the current index of the loop.
  91401. */
  91402. index: number;
  91403. private _done;
  91404. private _fn;
  91405. private _successCallback;
  91406. /**
  91407. * Constructor.
  91408. * @param iterations the number of iterations.
  91409. * @param func the function to run each iteration
  91410. * @param successCallback the callback that will be called upon succesful execution
  91411. * @param offset starting offset.
  91412. */
  91413. constructor(
  91414. /**
  91415. * Defines the number of iterations for the loop
  91416. */
  91417. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91418. /**
  91419. * Execute the next iteration. Must be called after the last iteration was finished.
  91420. */
  91421. executeNext(): void;
  91422. /**
  91423. * Break the loop and run the success callback.
  91424. */
  91425. breakLoop(): void;
  91426. /**
  91427. * Create and run an async loop.
  91428. * @param iterations the number of iterations.
  91429. * @param fn the function to run each iteration
  91430. * @param successCallback the callback that will be called upon succesful execution
  91431. * @param offset starting offset.
  91432. * @returns the created async loop object
  91433. */
  91434. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91435. /**
  91436. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91437. * @param iterations total number of iterations
  91438. * @param syncedIterations number of synchronous iterations in each async iteration.
  91439. * @param fn the function to call each iteration.
  91440. * @param callback a success call back that will be called when iterating stops.
  91441. * @param breakFunction a break condition (optional)
  91442. * @param timeout timeout settings for the setTimeout function. default - 0.
  91443. * @returns the created async loop object
  91444. */
  91445. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91446. }
  91447. }
  91448. declare module BABYLON {
  91449. /** @hidden */
  91450. export interface ICollisionCoordinator {
  91451. createCollider(): Collider;
  91452. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91453. init(scene: Scene): void;
  91454. }
  91455. /** @hidden */
  91456. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91457. private _scene;
  91458. private _scaledPosition;
  91459. private _scaledVelocity;
  91460. private _finalPosition;
  91461. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91462. createCollider(): Collider;
  91463. init(scene: Scene): void;
  91464. private _collideWithWorld;
  91465. }
  91466. }
  91467. declare module BABYLON {
  91468. /**
  91469. * Class used to manage all inputs for the scene.
  91470. */
  91471. export class InputManager {
  91472. /** The distance in pixel that you have to move to prevent some events */
  91473. static DragMovementThreshold: number;
  91474. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91475. static LongPressDelay: number;
  91476. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91477. static DoubleClickDelay: number;
  91478. /** If you need to check double click without raising a single click at first click, enable this flag */
  91479. static ExclusiveDoubleClickMode: boolean;
  91480. private _wheelEventName;
  91481. private _onPointerMove;
  91482. private _onPointerDown;
  91483. private _onPointerUp;
  91484. private _initClickEvent;
  91485. private _initActionManager;
  91486. private _delayedSimpleClick;
  91487. private _delayedSimpleClickTimeout;
  91488. private _previousDelayedSimpleClickTimeout;
  91489. private _meshPickProceed;
  91490. private _previousButtonPressed;
  91491. private _currentPickResult;
  91492. private _previousPickResult;
  91493. private _totalPointersPressed;
  91494. private _doubleClickOccured;
  91495. private _pointerOverMesh;
  91496. private _pickedDownMesh;
  91497. private _pickedUpMesh;
  91498. private _pointerX;
  91499. private _pointerY;
  91500. private _unTranslatedPointerX;
  91501. private _unTranslatedPointerY;
  91502. private _startingPointerPosition;
  91503. private _previousStartingPointerPosition;
  91504. private _startingPointerTime;
  91505. private _previousStartingPointerTime;
  91506. private _pointerCaptures;
  91507. private _onKeyDown;
  91508. private _onKeyUp;
  91509. private _onCanvasFocusObserver;
  91510. private _onCanvasBlurObserver;
  91511. private _scene;
  91512. /**
  91513. * Creates a new InputManager
  91514. * @param scene defines the hosting scene
  91515. */
  91516. constructor(scene: Scene);
  91517. /**
  91518. * Gets the mesh that is currently under the pointer
  91519. */
  91520. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91521. /**
  91522. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  91523. */
  91524. readonly unTranslatedPointer: Vector2;
  91525. /**
  91526. * Gets or sets the current on-screen X position of the pointer
  91527. */
  91528. pointerX: number;
  91529. /**
  91530. * Gets or sets the current on-screen Y position of the pointer
  91531. */
  91532. pointerY: number;
  91533. private _updatePointerPosition;
  91534. private _processPointerMove;
  91535. private _setRayOnPointerInfo;
  91536. private _checkPrePointerObservable;
  91537. /**
  91538. * Use this method to simulate a pointer move on a mesh
  91539. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91540. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91541. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91542. */
  91543. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91544. /**
  91545. * Use this method to simulate a pointer down on a mesh
  91546. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91547. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91548. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91549. */
  91550. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91551. private _processPointerDown;
  91552. /** @hidden */
  91553. _isPointerSwiping(): boolean;
  91554. /**
  91555. * Use this method to simulate a pointer up on a mesh
  91556. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91557. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91558. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91559. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91560. */
  91561. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  91562. private _processPointerUp;
  91563. /**
  91564. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91565. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91566. * @returns true if the pointer was captured
  91567. */
  91568. isPointerCaptured(pointerId?: number): boolean;
  91569. /**
  91570. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91571. * @param attachUp defines if you want to attach events to pointerup
  91572. * @param attachDown defines if you want to attach events to pointerdown
  91573. * @param attachMove defines if you want to attach events to pointermove
  91574. */
  91575. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91576. /**
  91577. * Detaches all event handlers
  91578. */
  91579. detachControl(): void;
  91580. /**
  91581. * Force the value of meshUnderPointer
  91582. * @param mesh defines the mesh to use
  91583. */
  91584. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91585. /**
  91586. * Gets the mesh under the pointer
  91587. * @returns a Mesh or null if no mesh is under the pointer
  91588. */
  91589. getPointerOverMesh(): Nullable<AbstractMesh>;
  91590. }
  91591. }
  91592. declare module BABYLON {
  91593. /**
  91594. * This class defines the direct association between an animation and a target
  91595. */
  91596. export class TargetedAnimation {
  91597. /**
  91598. * Animation to perform
  91599. */
  91600. animation: Animation;
  91601. /**
  91602. * Target to animate
  91603. */
  91604. target: any;
  91605. }
  91606. /**
  91607. * Use this class to create coordinated animations on multiple targets
  91608. */
  91609. export class AnimationGroup implements IDisposable {
  91610. /** The name of the animation group */
  91611. name: string;
  91612. private _scene;
  91613. private _targetedAnimations;
  91614. private _animatables;
  91615. private _from;
  91616. private _to;
  91617. private _isStarted;
  91618. private _isPaused;
  91619. private _speedRatio;
  91620. /**
  91621. * Gets or sets the unique id of the node
  91622. */
  91623. uniqueId: number;
  91624. /**
  91625. * This observable will notify when one animation have ended
  91626. */
  91627. onAnimationEndObservable: Observable<TargetedAnimation>;
  91628. /**
  91629. * Observer raised when one animation loops
  91630. */
  91631. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91632. /**
  91633. * This observable will notify when all animations have ended.
  91634. */
  91635. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91636. /**
  91637. * This observable will notify when all animations have paused.
  91638. */
  91639. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91640. /**
  91641. * This observable will notify when all animations are playing.
  91642. */
  91643. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91644. /**
  91645. * Gets the first frame
  91646. */
  91647. readonly from: number;
  91648. /**
  91649. * Gets the last frame
  91650. */
  91651. readonly to: number;
  91652. /**
  91653. * Define if the animations are started
  91654. */
  91655. readonly isStarted: boolean;
  91656. /**
  91657. * Gets a value indicating that the current group is playing
  91658. */
  91659. readonly isPlaying: boolean;
  91660. /**
  91661. * Gets or sets the speed ratio to use for all animations
  91662. */
  91663. /**
  91664. * Gets or sets the speed ratio to use for all animations
  91665. */
  91666. speedRatio: number;
  91667. /**
  91668. * Gets the targeted animations for this animation group
  91669. */
  91670. readonly targetedAnimations: Array<TargetedAnimation>;
  91671. /**
  91672. * returning the list of animatables controlled by this animation group.
  91673. */
  91674. readonly animatables: Array<Animatable>;
  91675. /**
  91676. * Instantiates a new Animation Group.
  91677. * This helps managing several animations at once.
  91678. * @see http://doc.babylonjs.com/how_to/group
  91679. * @param name Defines the name of the group
  91680. * @param scene Defines the scene the group belongs to
  91681. */
  91682. constructor(
  91683. /** The name of the animation group */
  91684. name: string, scene?: Nullable<Scene>);
  91685. /**
  91686. * Add an animation (with its target) in the group
  91687. * @param animation defines the animation we want to add
  91688. * @param target defines the target of the animation
  91689. * @returns the TargetedAnimation object
  91690. */
  91691. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91692. /**
  91693. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91694. * It can add constant keys at begin or end
  91695. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91696. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91697. * @returns the animation group
  91698. */
  91699. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91700. /**
  91701. * Start all animations on given targets
  91702. * @param loop defines if animations must loop
  91703. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91704. * @param from defines the from key (optional)
  91705. * @param to defines the to key (optional)
  91706. * @returns the current animation group
  91707. */
  91708. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91709. /**
  91710. * Pause all animations
  91711. * @returns the animation group
  91712. */
  91713. pause(): AnimationGroup;
  91714. /**
  91715. * Play all animations to initial state
  91716. * This function will start() the animations if they were not started or will restart() them if they were paused
  91717. * @param loop defines if animations must loop
  91718. * @returns the animation group
  91719. */
  91720. play(loop?: boolean): AnimationGroup;
  91721. /**
  91722. * Reset all animations to initial state
  91723. * @returns the animation group
  91724. */
  91725. reset(): AnimationGroup;
  91726. /**
  91727. * Restart animations from key 0
  91728. * @returns the animation group
  91729. */
  91730. restart(): AnimationGroup;
  91731. /**
  91732. * Stop all animations
  91733. * @returns the animation group
  91734. */
  91735. stop(): AnimationGroup;
  91736. /**
  91737. * Set animation weight for all animatables
  91738. * @param weight defines the weight to use
  91739. * @return the animationGroup
  91740. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91741. */
  91742. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91743. /**
  91744. * Synchronize and normalize all animatables with a source animatable
  91745. * @param root defines the root animatable to synchronize with
  91746. * @return the animationGroup
  91747. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91748. */
  91749. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91750. /**
  91751. * Goes to a specific frame in this animation group
  91752. * @param frame the frame number to go to
  91753. * @return the animationGroup
  91754. */
  91755. goToFrame(frame: number): AnimationGroup;
  91756. /**
  91757. * Dispose all associated resources
  91758. */
  91759. dispose(): void;
  91760. private _checkAnimationGroupEnded;
  91761. /**
  91762. * Clone the current animation group and returns a copy
  91763. * @param newName defines the name of the new group
  91764. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91765. * @returns the new aniamtion group
  91766. */
  91767. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91768. /**
  91769. * Returns a new AnimationGroup object parsed from the source provided.
  91770. * @param parsedAnimationGroup defines the source
  91771. * @param scene defines the scene that will receive the animationGroup
  91772. * @returns a new AnimationGroup
  91773. */
  91774. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91775. /**
  91776. * Returns the string "AnimationGroup"
  91777. * @returns "AnimationGroup"
  91778. */
  91779. getClassName(): string;
  91780. /**
  91781. * Creates a detailled string about the object
  91782. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91783. * @returns a string representing the object
  91784. */
  91785. toString(fullDetails?: boolean): string;
  91786. }
  91787. }
  91788. declare module BABYLON {
  91789. /**
  91790. * Define an interface for all classes that will hold resources
  91791. */
  91792. export interface IDisposable {
  91793. /**
  91794. * Releases all held resources
  91795. */
  91796. dispose(): void;
  91797. }
  91798. /** Interface defining initialization parameters for Scene class */
  91799. export interface SceneOptions {
  91800. /**
  91801. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91802. * It will improve performance when the number of geometries becomes important.
  91803. */
  91804. useGeometryUniqueIdsMap?: boolean;
  91805. /**
  91806. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91807. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91808. */
  91809. useMaterialMeshMap?: boolean;
  91810. /**
  91811. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91812. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91813. */
  91814. useClonedMeshhMap?: boolean;
  91815. }
  91816. /**
  91817. * Represents a scene to be rendered by the engine.
  91818. * @see http://doc.babylonjs.com/features/scene
  91819. */
  91820. export class Scene extends AbstractScene implements IAnimatable {
  91821. private static _uniqueIdCounter;
  91822. /** The fog is deactivated */
  91823. static readonly FOGMODE_NONE: number;
  91824. /** The fog density is following an exponential function */
  91825. static readonly FOGMODE_EXP: number;
  91826. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91827. static readonly FOGMODE_EXP2: number;
  91828. /** The fog density is following a linear function. */
  91829. static readonly FOGMODE_LINEAR: number;
  91830. /**
  91831. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91832. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91833. */
  91834. static MinDeltaTime: number;
  91835. /**
  91836. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91837. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91838. */
  91839. static MaxDeltaTime: number;
  91840. /**
  91841. * Factory used to create the default material.
  91842. * @param name The name of the material to create
  91843. * @param scene The scene to create the material for
  91844. * @returns The default material
  91845. */
  91846. static DefaultMaterialFactory(scene: Scene): Material;
  91847. /**
  91848. * Factory used to create the a collision coordinator.
  91849. * @returns The collision coordinator
  91850. */
  91851. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91852. /** @hidden */
  91853. _inputManager: InputManager;
  91854. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91855. cameraToUseForPointers: Nullable<Camera>;
  91856. /** @hidden */
  91857. readonly _isScene: boolean;
  91858. /**
  91859. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91860. */
  91861. autoClear: boolean;
  91862. /**
  91863. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91864. */
  91865. autoClearDepthAndStencil: boolean;
  91866. /**
  91867. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91868. */
  91869. clearColor: Color4;
  91870. /**
  91871. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91872. */
  91873. ambientColor: Color3;
  91874. /**
  91875. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91876. * It should only be one of the following (if not the default embedded one):
  91877. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91878. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91879. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91880. * The material properties need to be setup according to the type of texture in use.
  91881. */
  91882. environmentBRDFTexture: BaseTexture;
  91883. /** @hidden */
  91884. protected _environmentTexture: Nullable<BaseTexture>;
  91885. /**
  91886. * Texture used in all pbr material as the reflection texture.
  91887. * As in the majority of the scene they are the same (exception for multi room and so on),
  91888. * this is easier to reference from here than from all the materials.
  91889. */
  91890. /**
  91891. * Texture used in all pbr material as the reflection texture.
  91892. * As in the majority of the scene they are the same (exception for multi room and so on),
  91893. * this is easier to set here than in all the materials.
  91894. */
  91895. environmentTexture: Nullable<BaseTexture>;
  91896. /** @hidden */
  91897. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91898. /**
  91899. * Default image processing configuration used either in the rendering
  91900. * Forward main pass or through the imageProcessingPostProcess if present.
  91901. * As in the majority of the scene they are the same (exception for multi camera),
  91902. * this is easier to reference from here than from all the materials and post process.
  91903. *
  91904. * No setter as we it is a shared configuration, you can set the values instead.
  91905. */
  91906. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91907. private _forceWireframe;
  91908. /**
  91909. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91910. */
  91911. forceWireframe: boolean;
  91912. private _forcePointsCloud;
  91913. /**
  91914. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91915. */
  91916. forcePointsCloud: boolean;
  91917. /**
  91918. * Gets or sets the active clipplane 1
  91919. */
  91920. clipPlane: Nullable<Plane>;
  91921. /**
  91922. * Gets or sets the active clipplane 2
  91923. */
  91924. clipPlane2: Nullable<Plane>;
  91925. /**
  91926. * Gets or sets the active clipplane 3
  91927. */
  91928. clipPlane3: Nullable<Plane>;
  91929. /**
  91930. * Gets or sets the active clipplane 4
  91931. */
  91932. clipPlane4: Nullable<Plane>;
  91933. /**
  91934. * Gets or sets a boolean indicating if animations are enabled
  91935. */
  91936. animationsEnabled: boolean;
  91937. private _animationPropertiesOverride;
  91938. /**
  91939. * Gets or sets the animation properties override
  91940. */
  91941. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91942. /**
  91943. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91944. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91945. */
  91946. useConstantAnimationDeltaTime: boolean;
  91947. /**
  91948. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91949. * Please note that it requires to run a ray cast through the scene on every frame
  91950. */
  91951. constantlyUpdateMeshUnderPointer: boolean;
  91952. /**
  91953. * Defines the HTML cursor to use when hovering over interactive elements
  91954. */
  91955. hoverCursor: string;
  91956. /**
  91957. * Defines the HTML default cursor to use (empty by default)
  91958. */
  91959. defaultCursor: string;
  91960. /**
  91961. * This is used to call preventDefault() on pointer down
  91962. * in order to block unwanted artifacts like system double clicks
  91963. */
  91964. preventDefaultOnPointerDown: boolean;
  91965. /**
  91966. * This is used to call preventDefault() on pointer up
  91967. * in order to block unwanted artifacts like system double clicks
  91968. */
  91969. preventDefaultOnPointerUp: boolean;
  91970. /**
  91971. * Gets or sets user defined metadata
  91972. */
  91973. metadata: any;
  91974. /**
  91975. * For internal use only. Please do not use.
  91976. */
  91977. reservedDataStore: any;
  91978. /**
  91979. * Gets the name of the plugin used to load this scene (null by default)
  91980. */
  91981. loadingPluginName: string;
  91982. /**
  91983. * Use this array to add regular expressions used to disable offline support for specific urls
  91984. */
  91985. disableOfflineSupportExceptionRules: RegExp[];
  91986. /**
  91987. * An event triggered when the scene is disposed.
  91988. */
  91989. onDisposeObservable: Observable<Scene>;
  91990. private _onDisposeObserver;
  91991. /** Sets a function to be executed when this scene is disposed. */
  91992. onDispose: () => void;
  91993. /**
  91994. * An event triggered before rendering the scene (right after animations and physics)
  91995. */
  91996. onBeforeRenderObservable: Observable<Scene>;
  91997. private _onBeforeRenderObserver;
  91998. /** Sets a function to be executed before rendering this scene */
  91999. beforeRender: Nullable<() => void>;
  92000. /**
  92001. * An event triggered after rendering the scene
  92002. */
  92003. onAfterRenderObservable: Observable<Scene>;
  92004. private _onAfterRenderObserver;
  92005. /** Sets a function to be executed after rendering this scene */
  92006. afterRender: Nullable<() => void>;
  92007. /**
  92008. * An event triggered before animating the scene
  92009. */
  92010. onBeforeAnimationsObservable: Observable<Scene>;
  92011. /**
  92012. * An event triggered after animations processing
  92013. */
  92014. onAfterAnimationsObservable: Observable<Scene>;
  92015. /**
  92016. * An event triggered before draw calls are ready to be sent
  92017. */
  92018. onBeforeDrawPhaseObservable: Observable<Scene>;
  92019. /**
  92020. * An event triggered after draw calls have been sent
  92021. */
  92022. onAfterDrawPhaseObservable: Observable<Scene>;
  92023. /**
  92024. * An event triggered when the scene is ready
  92025. */
  92026. onReadyObservable: Observable<Scene>;
  92027. /**
  92028. * An event triggered before rendering a camera
  92029. */
  92030. onBeforeCameraRenderObservable: Observable<Camera>;
  92031. private _onBeforeCameraRenderObserver;
  92032. /** Sets a function to be executed before rendering a camera*/
  92033. beforeCameraRender: () => void;
  92034. /**
  92035. * An event triggered after rendering a camera
  92036. */
  92037. onAfterCameraRenderObservable: Observable<Camera>;
  92038. private _onAfterCameraRenderObserver;
  92039. /** Sets a function to be executed after rendering a camera*/
  92040. afterCameraRender: () => void;
  92041. /**
  92042. * An event triggered when active meshes evaluation is about to start
  92043. */
  92044. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  92045. /**
  92046. * An event triggered when active meshes evaluation is done
  92047. */
  92048. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  92049. /**
  92050. * An event triggered when particles rendering is about to start
  92051. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92052. */
  92053. onBeforeParticlesRenderingObservable: Observable<Scene>;
  92054. /**
  92055. * An event triggered when particles rendering is done
  92056. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92057. */
  92058. onAfterParticlesRenderingObservable: Observable<Scene>;
  92059. /**
  92060. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  92061. */
  92062. onDataLoadedObservable: Observable<Scene>;
  92063. /**
  92064. * An event triggered when a camera is created
  92065. */
  92066. onNewCameraAddedObservable: Observable<Camera>;
  92067. /**
  92068. * An event triggered when a camera is removed
  92069. */
  92070. onCameraRemovedObservable: Observable<Camera>;
  92071. /**
  92072. * An event triggered when a light is created
  92073. */
  92074. onNewLightAddedObservable: Observable<Light>;
  92075. /**
  92076. * An event triggered when a light is removed
  92077. */
  92078. onLightRemovedObservable: Observable<Light>;
  92079. /**
  92080. * An event triggered when a geometry is created
  92081. */
  92082. onNewGeometryAddedObservable: Observable<Geometry>;
  92083. /**
  92084. * An event triggered when a geometry is removed
  92085. */
  92086. onGeometryRemovedObservable: Observable<Geometry>;
  92087. /**
  92088. * An event triggered when a transform node is created
  92089. */
  92090. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  92091. /**
  92092. * An event triggered when a transform node is removed
  92093. */
  92094. onTransformNodeRemovedObservable: Observable<TransformNode>;
  92095. /**
  92096. * An event triggered when a mesh is created
  92097. */
  92098. onNewMeshAddedObservable: Observable<AbstractMesh>;
  92099. /**
  92100. * An event triggered when a mesh is removed
  92101. */
  92102. onMeshRemovedObservable: Observable<AbstractMesh>;
  92103. /**
  92104. * An event triggered when a skeleton is created
  92105. */
  92106. onNewSkeletonAddedObservable: Observable<Skeleton>;
  92107. /**
  92108. * An event triggered when a skeleton is removed
  92109. */
  92110. onSkeletonRemovedObservable: Observable<Skeleton>;
  92111. /**
  92112. * An event triggered when a material is created
  92113. */
  92114. onNewMaterialAddedObservable: Observable<Material>;
  92115. /**
  92116. * An event triggered when a material is removed
  92117. */
  92118. onMaterialRemovedObservable: Observable<Material>;
  92119. /**
  92120. * An event triggered when a texture is created
  92121. */
  92122. onNewTextureAddedObservable: Observable<BaseTexture>;
  92123. /**
  92124. * An event triggered when a texture is removed
  92125. */
  92126. onTextureRemovedObservable: Observable<BaseTexture>;
  92127. /**
  92128. * An event triggered when render targets are about to be rendered
  92129. * Can happen multiple times per frame.
  92130. */
  92131. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  92132. /**
  92133. * An event triggered when render targets were rendered.
  92134. * Can happen multiple times per frame.
  92135. */
  92136. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  92137. /**
  92138. * An event triggered before calculating deterministic simulation step
  92139. */
  92140. onBeforeStepObservable: Observable<Scene>;
  92141. /**
  92142. * An event triggered after calculating deterministic simulation step
  92143. */
  92144. onAfterStepObservable: Observable<Scene>;
  92145. /**
  92146. * An event triggered when the activeCamera property is updated
  92147. */
  92148. onActiveCameraChanged: Observable<Scene>;
  92149. /**
  92150. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  92151. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92152. * 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)
  92153. */
  92154. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92155. /**
  92156. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  92157. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92158. * 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)
  92159. */
  92160. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92161. /**
  92162. * This Observable will when a mesh has been imported into the scene.
  92163. */
  92164. onMeshImportedObservable: Observable<AbstractMesh>;
  92165. /**
  92166. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  92167. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  92168. */
  92169. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  92170. /** @hidden */
  92171. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  92172. /**
  92173. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  92174. */
  92175. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  92176. /**
  92177. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  92178. */
  92179. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  92180. /**
  92181. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  92182. */
  92183. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  92184. /** Callback called when a pointer move is detected */
  92185. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92186. /** Callback called when a pointer down is detected */
  92187. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92188. /** Callback called when a pointer up is detected */
  92189. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  92190. /** Callback called when a pointer pick is detected */
  92191. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  92192. /**
  92193. * 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).
  92194. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  92195. */
  92196. onPrePointerObservable: Observable<PointerInfoPre>;
  92197. /**
  92198. * Observable event triggered each time an input event is received from the rendering canvas
  92199. */
  92200. onPointerObservable: Observable<PointerInfo>;
  92201. /**
  92202. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  92203. */
  92204. readonly unTranslatedPointer: Vector2;
  92205. /**
  92206. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  92207. */
  92208. static DragMovementThreshold: number;
  92209. /**
  92210. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  92211. */
  92212. static LongPressDelay: number;
  92213. /**
  92214. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  92215. */
  92216. static DoubleClickDelay: number;
  92217. /** If you need to check double click without raising a single click at first click, enable this flag */
  92218. static ExclusiveDoubleClickMode: boolean;
  92219. /** @hidden */
  92220. _mirroredCameraPosition: Nullable<Vector3>;
  92221. /**
  92222. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  92223. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  92224. */
  92225. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  92226. /**
  92227. * Observable event triggered each time an keyboard event is received from the hosting window
  92228. */
  92229. onKeyboardObservable: Observable<KeyboardInfo>;
  92230. private _useRightHandedSystem;
  92231. /**
  92232. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  92233. */
  92234. useRightHandedSystem: boolean;
  92235. private _timeAccumulator;
  92236. private _currentStepId;
  92237. private _currentInternalStep;
  92238. /**
  92239. * Sets the step Id used by deterministic lock step
  92240. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92241. * @param newStepId defines the step Id
  92242. */
  92243. setStepId(newStepId: number): void;
  92244. /**
  92245. * Gets the step Id used by deterministic lock step
  92246. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92247. * @returns the step Id
  92248. */
  92249. getStepId(): number;
  92250. /**
  92251. * Gets the internal step used by deterministic lock step
  92252. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92253. * @returns the internal step
  92254. */
  92255. getInternalStep(): number;
  92256. private _fogEnabled;
  92257. /**
  92258. * Gets or sets a boolean indicating if fog is enabled on this scene
  92259. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92260. * (Default is true)
  92261. */
  92262. fogEnabled: boolean;
  92263. private _fogMode;
  92264. /**
  92265. * Gets or sets the fog mode to use
  92266. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92267. * | mode | value |
  92268. * | --- | --- |
  92269. * | FOGMODE_NONE | 0 |
  92270. * | FOGMODE_EXP | 1 |
  92271. * | FOGMODE_EXP2 | 2 |
  92272. * | FOGMODE_LINEAR | 3 |
  92273. */
  92274. fogMode: number;
  92275. /**
  92276. * Gets or sets the fog color to use
  92277. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92278. * (Default is Color3(0.2, 0.2, 0.3))
  92279. */
  92280. fogColor: Color3;
  92281. /**
  92282. * Gets or sets the fog density to use
  92283. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92284. * (Default is 0.1)
  92285. */
  92286. fogDensity: number;
  92287. /**
  92288. * Gets or sets the fog start distance to use
  92289. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92290. * (Default is 0)
  92291. */
  92292. fogStart: number;
  92293. /**
  92294. * Gets or sets the fog end distance to use
  92295. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92296. * (Default is 1000)
  92297. */
  92298. fogEnd: number;
  92299. private _shadowsEnabled;
  92300. /**
  92301. * Gets or sets a boolean indicating if shadows are enabled on this scene
  92302. */
  92303. shadowsEnabled: boolean;
  92304. private _lightsEnabled;
  92305. /**
  92306. * Gets or sets a boolean indicating if lights are enabled on this scene
  92307. */
  92308. lightsEnabled: boolean;
  92309. /** All of the active cameras added to this scene. */
  92310. activeCameras: Camera[];
  92311. /** @hidden */
  92312. _activeCamera: Nullable<Camera>;
  92313. /** Gets or sets the current active camera */
  92314. activeCamera: Nullable<Camera>;
  92315. private _defaultMaterial;
  92316. /** The default material used on meshes when no material is affected */
  92317. /** The default material used on meshes when no material is affected */
  92318. defaultMaterial: Material;
  92319. private _texturesEnabled;
  92320. /**
  92321. * Gets or sets a boolean indicating if textures are enabled on this scene
  92322. */
  92323. texturesEnabled: boolean;
  92324. /**
  92325. * Gets or sets a boolean indicating if particles are enabled on this scene
  92326. */
  92327. particlesEnabled: boolean;
  92328. /**
  92329. * Gets or sets a boolean indicating if sprites are enabled on this scene
  92330. */
  92331. spritesEnabled: boolean;
  92332. private _skeletonsEnabled;
  92333. /**
  92334. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  92335. */
  92336. skeletonsEnabled: boolean;
  92337. /**
  92338. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  92339. */
  92340. lensFlaresEnabled: boolean;
  92341. /**
  92342. * Gets or sets a boolean indicating if collisions are enabled on this scene
  92343. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92344. */
  92345. collisionsEnabled: boolean;
  92346. private _collisionCoordinator;
  92347. /** @hidden */
  92348. readonly collisionCoordinator: ICollisionCoordinator;
  92349. /**
  92350. * Defines the gravity applied to this scene (used only for collisions)
  92351. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92352. */
  92353. gravity: Vector3;
  92354. /**
  92355. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  92356. */
  92357. postProcessesEnabled: boolean;
  92358. /**
  92359. * The list of postprocesses added to the scene
  92360. */
  92361. postProcesses: PostProcess[];
  92362. /**
  92363. * Gets the current postprocess manager
  92364. */
  92365. postProcessManager: PostProcessManager;
  92366. /**
  92367. * Gets or sets a boolean indicating if render targets are enabled on this scene
  92368. */
  92369. renderTargetsEnabled: boolean;
  92370. /**
  92371. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  92372. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  92373. */
  92374. dumpNextRenderTargets: boolean;
  92375. /**
  92376. * The list of user defined render targets added to the scene
  92377. */
  92378. customRenderTargets: RenderTargetTexture[];
  92379. /**
  92380. * Defines if texture loading must be delayed
  92381. * If true, textures will only be loaded when they need to be rendered
  92382. */
  92383. useDelayedTextureLoading: boolean;
  92384. /**
  92385. * Gets the list of meshes imported to the scene through SceneLoader
  92386. */
  92387. importedMeshesFiles: String[];
  92388. /**
  92389. * Gets or sets a boolean indicating if probes are enabled on this scene
  92390. */
  92391. probesEnabled: boolean;
  92392. /**
  92393. * Gets or sets the current offline provider to use to store scene data
  92394. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  92395. */
  92396. offlineProvider: IOfflineProvider;
  92397. /**
  92398. * Gets or sets the action manager associated with the scene
  92399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92400. */
  92401. actionManager: AbstractActionManager;
  92402. private _meshesForIntersections;
  92403. /**
  92404. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  92405. */
  92406. proceduralTexturesEnabled: boolean;
  92407. private _engine;
  92408. private _totalVertices;
  92409. /** @hidden */
  92410. _activeIndices: PerfCounter;
  92411. /** @hidden */
  92412. _activeParticles: PerfCounter;
  92413. /** @hidden */
  92414. _activeBones: PerfCounter;
  92415. private _animationRatio;
  92416. /** @hidden */
  92417. _animationTimeLast: number;
  92418. /** @hidden */
  92419. _animationTime: number;
  92420. /**
  92421. * Gets or sets a general scale for animation speed
  92422. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  92423. */
  92424. animationTimeScale: number;
  92425. /** @hidden */
  92426. _cachedMaterial: Nullable<Material>;
  92427. /** @hidden */
  92428. _cachedEffect: Nullable<Effect>;
  92429. /** @hidden */
  92430. _cachedVisibility: Nullable<number>;
  92431. private _renderId;
  92432. private _frameId;
  92433. private _executeWhenReadyTimeoutId;
  92434. private _intermediateRendering;
  92435. private _viewUpdateFlag;
  92436. private _projectionUpdateFlag;
  92437. /** @hidden */
  92438. _toBeDisposed: Nullable<IDisposable>[];
  92439. private _activeRequests;
  92440. /** @hidden */
  92441. _pendingData: any[];
  92442. private _isDisposed;
  92443. /**
  92444. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  92445. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  92446. */
  92447. dispatchAllSubMeshesOfActiveMeshes: boolean;
  92448. private _activeMeshes;
  92449. private _processedMaterials;
  92450. private _renderTargets;
  92451. /** @hidden */
  92452. _activeParticleSystems: SmartArray<IParticleSystem>;
  92453. private _activeSkeletons;
  92454. private _softwareSkinnedMeshes;
  92455. private _renderingManager;
  92456. /** @hidden */
  92457. _activeAnimatables: Animatable[];
  92458. private _transformMatrix;
  92459. private _sceneUbo;
  92460. /** @hidden */
  92461. _viewMatrix: Matrix;
  92462. private _projectionMatrix;
  92463. /** @hidden */
  92464. _forcedViewPosition: Nullable<Vector3>;
  92465. /** @hidden */
  92466. _frustumPlanes: Plane[];
  92467. /**
  92468. * Gets the list of frustum planes (built from the active camera)
  92469. */
  92470. readonly frustumPlanes: Plane[];
  92471. /**
  92472. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  92473. * This is useful if there are more lights that the maximum simulteanous authorized
  92474. */
  92475. requireLightSorting: boolean;
  92476. /** @hidden */
  92477. readonly useMaterialMeshMap: boolean;
  92478. /** @hidden */
  92479. readonly useClonedMeshhMap: boolean;
  92480. private _externalData;
  92481. private _uid;
  92482. /**
  92483. * @hidden
  92484. * Backing store of defined scene components.
  92485. */
  92486. _components: ISceneComponent[];
  92487. /**
  92488. * @hidden
  92489. * Backing store of defined scene components.
  92490. */
  92491. _serializableComponents: ISceneSerializableComponent[];
  92492. /**
  92493. * List of components to register on the next registration step.
  92494. */
  92495. private _transientComponents;
  92496. /**
  92497. * Registers the transient components if needed.
  92498. */
  92499. private _registerTransientComponents;
  92500. /**
  92501. * @hidden
  92502. * Add a component to the scene.
  92503. * Note that the ccomponent could be registered on th next frame if this is called after
  92504. * the register component stage.
  92505. * @param component Defines the component to add to the scene
  92506. */
  92507. _addComponent(component: ISceneComponent): void;
  92508. /**
  92509. * @hidden
  92510. * Gets a component from the scene.
  92511. * @param name defines the name of the component to retrieve
  92512. * @returns the component or null if not present
  92513. */
  92514. _getComponent(name: string): Nullable<ISceneComponent>;
  92515. /**
  92516. * @hidden
  92517. * Defines the actions happening before camera updates.
  92518. */
  92519. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92520. /**
  92521. * @hidden
  92522. * Defines the actions happening before clear the canvas.
  92523. */
  92524. _beforeClearStage: Stage<SimpleStageAction>;
  92525. /**
  92526. * @hidden
  92527. * Defines the actions when collecting render targets for the frame.
  92528. */
  92529. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92530. /**
  92531. * @hidden
  92532. * Defines the actions happening for one camera in the frame.
  92533. */
  92534. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92535. /**
  92536. * @hidden
  92537. * Defines the actions happening during the per mesh ready checks.
  92538. */
  92539. _isReadyForMeshStage: Stage<MeshStageAction>;
  92540. /**
  92541. * @hidden
  92542. * Defines the actions happening before evaluate active mesh checks.
  92543. */
  92544. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92545. /**
  92546. * @hidden
  92547. * Defines the actions happening during the evaluate sub mesh checks.
  92548. */
  92549. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92550. /**
  92551. * @hidden
  92552. * Defines the actions happening during the active mesh stage.
  92553. */
  92554. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92555. /**
  92556. * @hidden
  92557. * Defines the actions happening during the per camera render target step.
  92558. */
  92559. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92560. /**
  92561. * @hidden
  92562. * Defines the actions happening just before the active camera is drawing.
  92563. */
  92564. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92565. /**
  92566. * @hidden
  92567. * Defines the actions happening just before a render target is drawing.
  92568. */
  92569. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92570. /**
  92571. * @hidden
  92572. * Defines the actions happening just before a rendering group is drawing.
  92573. */
  92574. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92575. /**
  92576. * @hidden
  92577. * Defines the actions happening just before a mesh is drawing.
  92578. */
  92579. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92580. /**
  92581. * @hidden
  92582. * Defines the actions happening just after a mesh has been drawn.
  92583. */
  92584. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92585. /**
  92586. * @hidden
  92587. * Defines the actions happening just after a rendering group has been drawn.
  92588. */
  92589. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92590. /**
  92591. * @hidden
  92592. * Defines the actions happening just after the active camera has been drawn.
  92593. */
  92594. _afterCameraDrawStage: Stage<CameraStageAction>;
  92595. /**
  92596. * @hidden
  92597. * Defines the actions happening just after a render target has been drawn.
  92598. */
  92599. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92600. /**
  92601. * @hidden
  92602. * Defines the actions happening just after rendering all cameras and computing intersections.
  92603. */
  92604. _afterRenderStage: Stage<SimpleStageAction>;
  92605. /**
  92606. * @hidden
  92607. * Defines the actions happening when a pointer move event happens.
  92608. */
  92609. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92610. /**
  92611. * @hidden
  92612. * Defines the actions happening when a pointer down event happens.
  92613. */
  92614. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92615. /**
  92616. * @hidden
  92617. * Defines the actions happening when a pointer up event happens.
  92618. */
  92619. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92620. /**
  92621. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92622. */
  92623. private geometriesByUniqueId;
  92624. /**
  92625. * Creates a new Scene
  92626. * @param engine defines the engine to use to render this scene
  92627. * @param options defines the scene options
  92628. */
  92629. constructor(engine: Engine, options?: SceneOptions);
  92630. /**
  92631. * Gets a string idenfifying the name of the class
  92632. * @returns "Scene" string
  92633. */
  92634. getClassName(): string;
  92635. private _defaultMeshCandidates;
  92636. /**
  92637. * @hidden
  92638. */
  92639. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92640. private _defaultSubMeshCandidates;
  92641. /**
  92642. * @hidden
  92643. */
  92644. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92645. /**
  92646. * Sets the default candidate providers for the scene.
  92647. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92648. * and getCollidingSubMeshCandidates to their default function
  92649. */
  92650. setDefaultCandidateProviders(): void;
  92651. /**
  92652. * Gets the mesh that is currently under the pointer
  92653. */
  92654. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92655. /**
  92656. * Gets or sets the current on-screen X position of the pointer
  92657. */
  92658. pointerX: number;
  92659. /**
  92660. * Gets or sets the current on-screen Y position of the pointer
  92661. */
  92662. pointerY: number;
  92663. /**
  92664. * Gets the cached material (ie. the latest rendered one)
  92665. * @returns the cached material
  92666. */
  92667. getCachedMaterial(): Nullable<Material>;
  92668. /**
  92669. * Gets the cached effect (ie. the latest rendered one)
  92670. * @returns the cached effect
  92671. */
  92672. getCachedEffect(): Nullable<Effect>;
  92673. /**
  92674. * Gets the cached visibility state (ie. the latest rendered one)
  92675. * @returns the cached visibility state
  92676. */
  92677. getCachedVisibility(): Nullable<number>;
  92678. /**
  92679. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92680. * @param material defines the current material
  92681. * @param effect defines the current effect
  92682. * @param visibility defines the current visibility state
  92683. * @returns true if one parameter is not cached
  92684. */
  92685. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92686. /**
  92687. * Gets the engine associated with the scene
  92688. * @returns an Engine
  92689. */
  92690. getEngine(): Engine;
  92691. /**
  92692. * Gets the total number of vertices rendered per frame
  92693. * @returns the total number of vertices rendered per frame
  92694. */
  92695. getTotalVertices(): number;
  92696. /**
  92697. * Gets the performance counter for total vertices
  92698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92699. */
  92700. readonly totalVerticesPerfCounter: PerfCounter;
  92701. /**
  92702. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92703. * @returns the total number of active indices rendered per frame
  92704. */
  92705. getActiveIndices(): number;
  92706. /**
  92707. * Gets the performance counter for active indices
  92708. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92709. */
  92710. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92711. /**
  92712. * Gets the total number of active particles rendered per frame
  92713. * @returns the total number of active particles rendered per frame
  92714. */
  92715. getActiveParticles(): number;
  92716. /**
  92717. * Gets the performance counter for active particles
  92718. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92719. */
  92720. readonly activeParticlesPerfCounter: PerfCounter;
  92721. /**
  92722. * Gets the total number of active bones rendered per frame
  92723. * @returns the total number of active bones rendered per frame
  92724. */
  92725. getActiveBones(): number;
  92726. /**
  92727. * Gets the performance counter for active bones
  92728. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92729. */
  92730. readonly activeBonesPerfCounter: PerfCounter;
  92731. /**
  92732. * Gets the array of active meshes
  92733. * @returns an array of AbstractMesh
  92734. */
  92735. getActiveMeshes(): SmartArray<AbstractMesh>;
  92736. /**
  92737. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92738. * @returns a number
  92739. */
  92740. getAnimationRatio(): number;
  92741. /**
  92742. * Gets an unique Id for the current render phase
  92743. * @returns a number
  92744. */
  92745. getRenderId(): number;
  92746. /**
  92747. * Gets an unique Id for the current frame
  92748. * @returns a number
  92749. */
  92750. getFrameId(): number;
  92751. /** Call this function if you want to manually increment the render Id*/
  92752. incrementRenderId(): void;
  92753. private _createUbo;
  92754. /**
  92755. * Use this method to simulate a pointer move on a mesh
  92756. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92757. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92758. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92759. * @returns the current scene
  92760. */
  92761. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92762. /**
  92763. * Use this method to simulate a pointer down on a mesh
  92764. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92765. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92766. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92767. * @returns the current scene
  92768. */
  92769. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92770. /**
  92771. * Use this method to simulate a pointer up on a mesh
  92772. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92773. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92774. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92775. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92776. * @returns the current scene
  92777. */
  92778. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92779. /**
  92780. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92781. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92782. * @returns true if the pointer was captured
  92783. */
  92784. isPointerCaptured(pointerId?: number): boolean;
  92785. /**
  92786. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92787. * @param attachUp defines if you want to attach events to pointerup
  92788. * @param attachDown defines if you want to attach events to pointerdown
  92789. * @param attachMove defines if you want to attach events to pointermove
  92790. */
  92791. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92792. /** Detaches all event handlers*/
  92793. detachControl(): void;
  92794. /**
  92795. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92796. * Delay loaded resources are not taking in account
  92797. * @return true if all required resources are ready
  92798. */
  92799. isReady(): boolean;
  92800. /** Resets all cached information relative to material (including effect and visibility) */
  92801. resetCachedMaterial(): void;
  92802. /**
  92803. * Registers a function to be called before every frame render
  92804. * @param func defines the function to register
  92805. */
  92806. registerBeforeRender(func: () => void): void;
  92807. /**
  92808. * Unregisters a function called before every frame render
  92809. * @param func defines the function to unregister
  92810. */
  92811. unregisterBeforeRender(func: () => void): void;
  92812. /**
  92813. * Registers a function to be called after every frame render
  92814. * @param func defines the function to register
  92815. */
  92816. registerAfterRender(func: () => void): void;
  92817. /**
  92818. * Unregisters a function called after every frame render
  92819. * @param func defines the function to unregister
  92820. */
  92821. unregisterAfterRender(func: () => void): void;
  92822. private _executeOnceBeforeRender;
  92823. /**
  92824. * The provided function will run before render once and will be disposed afterwards.
  92825. * A timeout delay can be provided so that the function will be executed in N ms.
  92826. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92827. * @param func The function to be executed.
  92828. * @param timeout optional delay in ms
  92829. */
  92830. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92831. /** @hidden */
  92832. _addPendingData(data: any): void;
  92833. /** @hidden */
  92834. _removePendingData(data: any): void;
  92835. /**
  92836. * Returns the number of items waiting to be loaded
  92837. * @returns the number of items waiting to be loaded
  92838. */
  92839. getWaitingItemsCount(): number;
  92840. /**
  92841. * Returns a boolean indicating if the scene is still loading data
  92842. */
  92843. readonly isLoading: boolean;
  92844. /**
  92845. * Registers a function to be executed when the scene is ready
  92846. * @param {Function} func - the function to be executed
  92847. */
  92848. executeWhenReady(func: () => void): void;
  92849. /**
  92850. * Returns a promise that resolves when the scene is ready
  92851. * @returns A promise that resolves when the scene is ready
  92852. */
  92853. whenReadyAsync(): Promise<void>;
  92854. /** @hidden */
  92855. _checkIsReady(): void;
  92856. /**
  92857. * Gets all animatable attached to the scene
  92858. */
  92859. readonly animatables: Animatable[];
  92860. /**
  92861. * Resets the last animation time frame.
  92862. * Useful to override when animations start running when loading a scene for the first time.
  92863. */
  92864. resetLastAnimationTimeFrame(): void;
  92865. /**
  92866. * Gets the current view matrix
  92867. * @returns a Matrix
  92868. */
  92869. getViewMatrix(): Matrix;
  92870. /**
  92871. * Gets the current projection matrix
  92872. * @returns a Matrix
  92873. */
  92874. getProjectionMatrix(): Matrix;
  92875. /**
  92876. * Gets the current transform matrix
  92877. * @returns a Matrix made of View * Projection
  92878. */
  92879. getTransformMatrix(): Matrix;
  92880. /**
  92881. * Sets the current transform matrix
  92882. * @param viewL defines the View matrix to use
  92883. * @param projectionL defines the Projection matrix to use
  92884. * @param viewR defines the right View matrix to use (if provided)
  92885. * @param projectionR defines the right Projection matrix to use (if provided)
  92886. */
  92887. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92888. /**
  92889. * Gets the uniform buffer used to store scene data
  92890. * @returns a UniformBuffer
  92891. */
  92892. getSceneUniformBuffer(): UniformBuffer;
  92893. /**
  92894. * Gets an unique (relatively to the current scene) Id
  92895. * @returns an unique number for the scene
  92896. */
  92897. getUniqueId(): number;
  92898. /**
  92899. * Add a mesh to the list of scene's meshes
  92900. * @param newMesh defines the mesh to add
  92901. * @param recursive if all child meshes should also be added to the scene
  92902. */
  92903. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92904. /**
  92905. * Remove a mesh for the list of scene's meshes
  92906. * @param toRemove defines the mesh to remove
  92907. * @param recursive if all child meshes should also be removed from the scene
  92908. * @returns the index where the mesh was in the mesh list
  92909. */
  92910. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92911. /**
  92912. * Add a transform node to the list of scene's transform nodes
  92913. * @param newTransformNode defines the transform node to add
  92914. */
  92915. addTransformNode(newTransformNode: TransformNode): void;
  92916. /**
  92917. * Remove a transform node for the list of scene's transform nodes
  92918. * @param toRemove defines the transform node to remove
  92919. * @returns the index where the transform node was in the transform node list
  92920. */
  92921. removeTransformNode(toRemove: TransformNode): number;
  92922. /**
  92923. * Remove a skeleton for the list of scene's skeletons
  92924. * @param toRemove defines the skeleton to remove
  92925. * @returns the index where the skeleton was in the skeleton list
  92926. */
  92927. removeSkeleton(toRemove: Skeleton): number;
  92928. /**
  92929. * Remove a morph target for the list of scene's morph targets
  92930. * @param toRemove defines the morph target to remove
  92931. * @returns the index where the morph target was in the morph target list
  92932. */
  92933. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92934. /**
  92935. * Remove a light for the list of scene's lights
  92936. * @param toRemove defines the light to remove
  92937. * @returns the index where the light was in the light list
  92938. */
  92939. removeLight(toRemove: Light): number;
  92940. /**
  92941. * Remove a camera for the list of scene's cameras
  92942. * @param toRemove defines the camera to remove
  92943. * @returns the index where the camera was in the camera list
  92944. */
  92945. removeCamera(toRemove: Camera): number;
  92946. /**
  92947. * Remove a particle system for the list of scene's particle systems
  92948. * @param toRemove defines the particle system to remove
  92949. * @returns the index where the particle system was in the particle system list
  92950. */
  92951. removeParticleSystem(toRemove: IParticleSystem): number;
  92952. /**
  92953. * Remove a animation for the list of scene's animations
  92954. * @param toRemove defines the animation to remove
  92955. * @returns the index where the animation was in the animation list
  92956. */
  92957. removeAnimation(toRemove: Animation): number;
  92958. /**
  92959. * Will stop the animation of the given target
  92960. * @param target - the target
  92961. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  92962. * @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)
  92963. */
  92964. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  92965. /**
  92966. * Removes the given animation group from this scene.
  92967. * @param toRemove The animation group to remove
  92968. * @returns The index of the removed animation group
  92969. */
  92970. removeAnimationGroup(toRemove: AnimationGroup): number;
  92971. /**
  92972. * Removes the given multi-material from this scene.
  92973. * @param toRemove The multi-material to remove
  92974. * @returns The index of the removed multi-material
  92975. */
  92976. removeMultiMaterial(toRemove: MultiMaterial): number;
  92977. /**
  92978. * Removes the given material from this scene.
  92979. * @param toRemove The material to remove
  92980. * @returns The index of the removed material
  92981. */
  92982. removeMaterial(toRemove: Material): number;
  92983. /**
  92984. * Removes the given action manager from this scene.
  92985. * @param toRemove The action manager to remove
  92986. * @returns The index of the removed action manager
  92987. */
  92988. removeActionManager(toRemove: AbstractActionManager): number;
  92989. /**
  92990. * Removes the given texture from this scene.
  92991. * @param toRemove The texture to remove
  92992. * @returns The index of the removed texture
  92993. */
  92994. removeTexture(toRemove: BaseTexture): number;
  92995. /**
  92996. * Adds the given light to this scene
  92997. * @param newLight The light to add
  92998. */
  92999. addLight(newLight: Light): void;
  93000. /**
  93001. * Sorts the list list based on light priorities
  93002. */
  93003. sortLightsByPriority(): void;
  93004. /**
  93005. * Adds the given camera to this scene
  93006. * @param newCamera The camera to add
  93007. */
  93008. addCamera(newCamera: Camera): void;
  93009. /**
  93010. * Adds the given skeleton to this scene
  93011. * @param newSkeleton The skeleton to add
  93012. */
  93013. addSkeleton(newSkeleton: Skeleton): void;
  93014. /**
  93015. * Adds the given particle system to this scene
  93016. * @param newParticleSystem The particle system to add
  93017. */
  93018. addParticleSystem(newParticleSystem: IParticleSystem): void;
  93019. /**
  93020. * Adds the given animation to this scene
  93021. * @param newAnimation The animation to add
  93022. */
  93023. addAnimation(newAnimation: Animation): void;
  93024. /**
  93025. * Adds the given animation group to this scene.
  93026. * @param newAnimationGroup The animation group to add
  93027. */
  93028. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  93029. /**
  93030. * Adds the given multi-material to this scene
  93031. * @param newMultiMaterial The multi-material to add
  93032. */
  93033. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  93034. /**
  93035. * Adds the given material to this scene
  93036. * @param newMaterial The material to add
  93037. */
  93038. addMaterial(newMaterial: Material): void;
  93039. /**
  93040. * Adds the given morph target to this scene
  93041. * @param newMorphTargetManager The morph target to add
  93042. */
  93043. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  93044. /**
  93045. * Adds the given geometry to this scene
  93046. * @param newGeometry The geometry to add
  93047. */
  93048. addGeometry(newGeometry: Geometry): void;
  93049. /**
  93050. * Adds the given action manager to this scene
  93051. * @param newActionManager The action manager to add
  93052. */
  93053. addActionManager(newActionManager: AbstractActionManager): void;
  93054. /**
  93055. * Adds the given texture to this scene.
  93056. * @param newTexture The texture to add
  93057. */
  93058. addTexture(newTexture: BaseTexture): void;
  93059. /**
  93060. * Switch active camera
  93061. * @param newCamera defines the new active camera
  93062. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  93063. */
  93064. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  93065. /**
  93066. * sets the active camera of the scene using its ID
  93067. * @param id defines the camera's ID
  93068. * @return the new active camera or null if none found.
  93069. */
  93070. setActiveCameraByID(id: string): Nullable<Camera>;
  93071. /**
  93072. * sets the active camera of the scene using its name
  93073. * @param name defines the camera's name
  93074. * @returns the new active camera or null if none found.
  93075. */
  93076. setActiveCameraByName(name: string): Nullable<Camera>;
  93077. /**
  93078. * get an animation group using its name
  93079. * @param name defines the material's name
  93080. * @return the animation group or null if none found.
  93081. */
  93082. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  93083. /**
  93084. * Get a material using its unique id
  93085. * @param uniqueId defines the material's unique id
  93086. * @return the material or null if none found.
  93087. */
  93088. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  93089. /**
  93090. * get a material using its id
  93091. * @param id defines the material's ID
  93092. * @return the material or null if none found.
  93093. */
  93094. getMaterialByID(id: string): Nullable<Material>;
  93095. /**
  93096. * Gets a material using its name
  93097. * @param name defines the material's name
  93098. * @return the material or null if none found.
  93099. */
  93100. getMaterialByName(name: string): Nullable<Material>;
  93101. /**
  93102. * Gets a camera using its id
  93103. * @param id defines the id to look for
  93104. * @returns the camera or null if not found
  93105. */
  93106. getCameraByID(id: string): Nullable<Camera>;
  93107. /**
  93108. * Gets a camera using its unique id
  93109. * @param uniqueId defines the unique id to look for
  93110. * @returns the camera or null if not found
  93111. */
  93112. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  93113. /**
  93114. * Gets a camera using its name
  93115. * @param name defines the camera's name
  93116. * @return the camera or null if none found.
  93117. */
  93118. getCameraByName(name: string): Nullable<Camera>;
  93119. /**
  93120. * Gets a bone using its id
  93121. * @param id defines the bone's id
  93122. * @return the bone or null if not found
  93123. */
  93124. getBoneByID(id: string): Nullable<Bone>;
  93125. /**
  93126. * Gets a bone using its id
  93127. * @param name defines the bone's name
  93128. * @return the bone or null if not found
  93129. */
  93130. getBoneByName(name: string): Nullable<Bone>;
  93131. /**
  93132. * Gets a light node using its name
  93133. * @param name defines the the light's name
  93134. * @return the light or null if none found.
  93135. */
  93136. getLightByName(name: string): Nullable<Light>;
  93137. /**
  93138. * Gets a light node using its id
  93139. * @param id defines the light's id
  93140. * @return the light or null if none found.
  93141. */
  93142. getLightByID(id: string): Nullable<Light>;
  93143. /**
  93144. * Gets a light node using its scene-generated unique ID
  93145. * @param uniqueId defines the light's unique id
  93146. * @return the light or null if none found.
  93147. */
  93148. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  93149. /**
  93150. * Gets a particle system by id
  93151. * @param id defines the particle system id
  93152. * @return the corresponding system or null if none found
  93153. */
  93154. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  93155. /**
  93156. * Gets a geometry using its ID
  93157. * @param id defines the geometry's id
  93158. * @return the geometry or null if none found.
  93159. */
  93160. getGeometryByID(id: string): Nullable<Geometry>;
  93161. private _getGeometryByUniqueID;
  93162. /**
  93163. * Add a new geometry to this scene
  93164. * @param geometry defines the geometry to be added to the scene.
  93165. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  93166. * @return a boolean defining if the geometry was added or not
  93167. */
  93168. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  93169. /**
  93170. * Removes an existing geometry
  93171. * @param geometry defines the geometry to be removed from the scene
  93172. * @return a boolean defining if the geometry was removed or not
  93173. */
  93174. removeGeometry(geometry: Geometry): boolean;
  93175. /**
  93176. * Gets the list of geometries attached to the scene
  93177. * @returns an array of Geometry
  93178. */
  93179. getGeometries(): Geometry[];
  93180. /**
  93181. * Gets the first added mesh found of a given ID
  93182. * @param id defines the id to search for
  93183. * @return the mesh found or null if not found at all
  93184. */
  93185. getMeshByID(id: string): Nullable<AbstractMesh>;
  93186. /**
  93187. * Gets a list of meshes using their id
  93188. * @param id defines the id to search for
  93189. * @returns a list of meshes
  93190. */
  93191. getMeshesByID(id: string): Array<AbstractMesh>;
  93192. /**
  93193. * Gets the first added transform node found of a given ID
  93194. * @param id defines the id to search for
  93195. * @return the found transform node or null if not found at all.
  93196. */
  93197. getTransformNodeByID(id: string): Nullable<TransformNode>;
  93198. /**
  93199. * Gets a transform node with its auto-generated unique id
  93200. * @param uniqueId efines the unique id to search for
  93201. * @return the found transform node or null if not found at all.
  93202. */
  93203. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  93204. /**
  93205. * Gets a list of transform nodes using their id
  93206. * @param id defines the id to search for
  93207. * @returns a list of transform nodes
  93208. */
  93209. getTransformNodesByID(id: string): Array<TransformNode>;
  93210. /**
  93211. * Gets a mesh with its auto-generated unique id
  93212. * @param uniqueId defines the unique id to search for
  93213. * @return the found mesh or null if not found at all.
  93214. */
  93215. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  93216. /**
  93217. * Gets a the last added mesh using a given id
  93218. * @param id defines the id to search for
  93219. * @return the found mesh or null if not found at all.
  93220. */
  93221. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  93222. /**
  93223. * Gets a the last added node (Mesh, Camera, Light) using a given id
  93224. * @param id defines the id to search for
  93225. * @return the found node or null if not found at all
  93226. */
  93227. getLastEntryByID(id: string): Nullable<Node>;
  93228. /**
  93229. * Gets a node (Mesh, Camera, Light) using a given id
  93230. * @param id defines the id to search for
  93231. * @return the found node or null if not found at all
  93232. */
  93233. getNodeByID(id: string): Nullable<Node>;
  93234. /**
  93235. * Gets a node (Mesh, Camera, Light) using a given name
  93236. * @param name defines the name to search for
  93237. * @return the found node or null if not found at all.
  93238. */
  93239. getNodeByName(name: string): Nullable<Node>;
  93240. /**
  93241. * Gets a mesh using a given name
  93242. * @param name defines the name to search for
  93243. * @return the found mesh or null if not found at all.
  93244. */
  93245. getMeshByName(name: string): Nullable<AbstractMesh>;
  93246. /**
  93247. * Gets a transform node using a given name
  93248. * @param name defines the name to search for
  93249. * @return the found transform node or null if not found at all.
  93250. */
  93251. getTransformNodeByName(name: string): Nullable<TransformNode>;
  93252. /**
  93253. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  93254. * @param id defines the id to search for
  93255. * @return the found skeleton or null if not found at all.
  93256. */
  93257. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  93258. /**
  93259. * Gets a skeleton using a given auto generated unique id
  93260. * @param uniqueId defines the unique id to search for
  93261. * @return the found skeleton or null if not found at all.
  93262. */
  93263. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  93264. /**
  93265. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  93266. * @param id defines the id to search for
  93267. * @return the found skeleton or null if not found at all.
  93268. */
  93269. getSkeletonById(id: string): Nullable<Skeleton>;
  93270. /**
  93271. * Gets a skeleton using a given name
  93272. * @param name defines the name to search for
  93273. * @return the found skeleton or null if not found at all.
  93274. */
  93275. getSkeletonByName(name: string): Nullable<Skeleton>;
  93276. /**
  93277. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  93278. * @param id defines the id to search for
  93279. * @return the found morph target manager or null if not found at all.
  93280. */
  93281. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  93282. /**
  93283. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  93284. * @param id defines the id to search for
  93285. * @return the found morph target or null if not found at all.
  93286. */
  93287. getMorphTargetById(id: string): Nullable<MorphTarget>;
  93288. /**
  93289. * Gets a boolean indicating if the given mesh is active
  93290. * @param mesh defines the mesh to look for
  93291. * @returns true if the mesh is in the active list
  93292. */
  93293. isActiveMesh(mesh: AbstractMesh): boolean;
  93294. /**
  93295. * Return a unique id as a string which can serve as an identifier for the scene
  93296. */
  93297. readonly uid: string;
  93298. /**
  93299. * Add an externaly attached data from its key.
  93300. * This method call will fail and return false, if such key already exists.
  93301. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  93302. * @param key the unique key that identifies the data
  93303. * @param data the data object to associate to the key for this Engine instance
  93304. * @return true if no such key were already present and the data was added successfully, false otherwise
  93305. */
  93306. addExternalData<T>(key: string, data: T): boolean;
  93307. /**
  93308. * Get an externaly attached data from its key
  93309. * @param key the unique key that identifies the data
  93310. * @return the associated data, if present (can be null), or undefined if not present
  93311. */
  93312. getExternalData<T>(key: string): Nullable<T>;
  93313. /**
  93314. * Get an externaly attached data from its key, create it using a factory if it's not already present
  93315. * @param key the unique key that identifies the data
  93316. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  93317. * @return the associated data, can be null if the factory returned null.
  93318. */
  93319. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  93320. /**
  93321. * Remove an externaly attached data from the Engine instance
  93322. * @param key the unique key that identifies the data
  93323. * @return true if the data was successfully removed, false if it doesn't exist
  93324. */
  93325. removeExternalData(key: string): boolean;
  93326. private _evaluateSubMesh;
  93327. /**
  93328. * Clear the processed materials smart array preventing retention point in material dispose.
  93329. */
  93330. freeProcessedMaterials(): void;
  93331. private _preventFreeActiveMeshesAndRenderingGroups;
  93332. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  93333. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  93334. * when disposing several meshes in a row or a hierarchy of meshes.
  93335. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  93336. */
  93337. blockfreeActiveMeshesAndRenderingGroups: boolean;
  93338. /**
  93339. * Clear the active meshes smart array preventing retention point in mesh dispose.
  93340. */
  93341. freeActiveMeshes(): void;
  93342. /**
  93343. * Clear the info related to rendering groups preventing retention points during dispose.
  93344. */
  93345. freeRenderingGroups(): void;
  93346. /** @hidden */
  93347. _isInIntermediateRendering(): boolean;
  93348. /**
  93349. * Lambda returning the list of potentially active meshes.
  93350. */
  93351. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  93352. /**
  93353. * Lambda returning the list of potentially active sub meshes.
  93354. */
  93355. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  93356. /**
  93357. * Lambda returning the list of potentially intersecting sub meshes.
  93358. */
  93359. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  93360. /**
  93361. * Lambda returning the list of potentially colliding sub meshes.
  93362. */
  93363. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  93364. private _activeMeshesFrozen;
  93365. /**
  93366. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  93367. * @returns the current scene
  93368. */
  93369. freezeActiveMeshes(): Scene;
  93370. /**
  93371. * Use this function to restart evaluating active meshes on every frame
  93372. * @returns the current scene
  93373. */
  93374. unfreezeActiveMeshes(): Scene;
  93375. private _evaluateActiveMeshes;
  93376. private _activeMesh;
  93377. /**
  93378. * Update the transform matrix to update from the current active camera
  93379. * @param force defines a boolean used to force the update even if cache is up to date
  93380. */
  93381. updateTransformMatrix(force?: boolean): void;
  93382. private _bindFrameBuffer;
  93383. /** @hidden */
  93384. _allowPostProcessClearColor: boolean;
  93385. /** @hidden */
  93386. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  93387. private _processSubCameras;
  93388. private _checkIntersections;
  93389. /** @hidden */
  93390. _advancePhysicsEngineStep(step: number): void;
  93391. /**
  93392. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  93393. */
  93394. getDeterministicFrameTime: () => number;
  93395. /** @hidden */
  93396. _animate(): void;
  93397. /** Execute all animations (for a frame) */
  93398. animate(): void;
  93399. /**
  93400. * Render the scene
  93401. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  93402. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  93403. */
  93404. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  93405. /**
  93406. * Freeze all materials
  93407. * A frozen material will not be updatable but should be faster to render
  93408. */
  93409. freezeMaterials(): void;
  93410. /**
  93411. * Unfreeze all materials
  93412. * A frozen material will not be updatable but should be faster to render
  93413. */
  93414. unfreezeMaterials(): void;
  93415. /**
  93416. * Releases all held ressources
  93417. */
  93418. dispose(): void;
  93419. /**
  93420. * Gets if the scene is already disposed
  93421. */
  93422. readonly isDisposed: boolean;
  93423. /**
  93424. * Call this function to reduce memory footprint of the scene.
  93425. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  93426. */
  93427. clearCachedVertexData(): void;
  93428. /**
  93429. * This function will remove the local cached buffer data from texture.
  93430. * It will save memory but will prevent the texture from being rebuilt
  93431. */
  93432. cleanCachedTextureBuffer(): void;
  93433. /**
  93434. * Get the world extend vectors with an optional filter
  93435. *
  93436. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  93437. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  93438. */
  93439. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  93440. min: Vector3;
  93441. max: Vector3;
  93442. };
  93443. /**
  93444. * Creates a ray that can be used to pick in the scene
  93445. * @param x defines the x coordinate of the origin (on-screen)
  93446. * @param y defines the y coordinate of the origin (on-screen)
  93447. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93448. * @param camera defines the camera to use for the picking
  93449. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93450. * @returns a Ray
  93451. */
  93452. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  93453. /**
  93454. * Creates a ray that can be used to pick in the scene
  93455. * @param x defines the x coordinate of the origin (on-screen)
  93456. * @param y defines the y coordinate of the origin (on-screen)
  93457. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93458. * @param result defines the ray where to store the picking ray
  93459. * @param camera defines the camera to use for the picking
  93460. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93461. * @returns the current scene
  93462. */
  93463. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  93464. /**
  93465. * Creates a ray that can be used to pick in the scene
  93466. * @param x defines the x coordinate of the origin (on-screen)
  93467. * @param y defines the y coordinate of the origin (on-screen)
  93468. * @param camera defines the camera to use for the picking
  93469. * @returns a Ray
  93470. */
  93471. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  93472. /**
  93473. * Creates a ray that can be used to pick in the scene
  93474. * @param x defines the x coordinate of the origin (on-screen)
  93475. * @param y defines the y coordinate of the origin (on-screen)
  93476. * @param result defines the ray where to store the picking ray
  93477. * @param camera defines the camera to use for the picking
  93478. * @returns the current scene
  93479. */
  93480. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  93481. /** Launch a ray to try to pick a mesh in the scene
  93482. * @param x position on screen
  93483. * @param y position on screen
  93484. * @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
  93485. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  93486. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93487. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93488. * @returns a PickingInfo
  93489. */
  93490. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  93491. /** Use the given ray to pick a mesh in the scene
  93492. * @param ray The ray to use to pick meshes
  93493. * @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
  93494. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  93495. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93496. * @returns a PickingInfo
  93497. */
  93498. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  93499. /**
  93500. * Launch a ray to try to pick a mesh in the scene
  93501. * @param x X position on screen
  93502. * @param y Y position on screen
  93503. * @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
  93504. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93505. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93506. * @returns an array of PickingInfo
  93507. */
  93508. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93509. /**
  93510. * Launch a ray to try to pick a mesh in the scene
  93511. * @param ray Ray to use
  93512. * @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
  93513. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93514. * @returns an array of PickingInfo
  93515. */
  93516. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93517. /**
  93518. * Force the value of meshUnderPointer
  93519. * @param mesh defines the mesh to use
  93520. */
  93521. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93522. /**
  93523. * Gets the mesh under the pointer
  93524. * @returns a Mesh or null if no mesh is under the pointer
  93525. */
  93526. getPointerOverMesh(): Nullable<AbstractMesh>;
  93527. /** @hidden */
  93528. _rebuildGeometries(): void;
  93529. /** @hidden */
  93530. _rebuildTextures(): void;
  93531. private _getByTags;
  93532. /**
  93533. * Get a list of meshes by tags
  93534. * @param tagsQuery defines the tags query to use
  93535. * @param forEach defines a predicate used to filter results
  93536. * @returns an array of Mesh
  93537. */
  93538. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93539. /**
  93540. * Get a list of cameras by tags
  93541. * @param tagsQuery defines the tags query to use
  93542. * @param forEach defines a predicate used to filter results
  93543. * @returns an array of Camera
  93544. */
  93545. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93546. /**
  93547. * Get a list of lights by tags
  93548. * @param tagsQuery defines the tags query to use
  93549. * @param forEach defines a predicate used to filter results
  93550. * @returns an array of Light
  93551. */
  93552. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93553. /**
  93554. * Get a list of materials by tags
  93555. * @param tagsQuery defines the tags query to use
  93556. * @param forEach defines a predicate used to filter results
  93557. * @returns an array of Material
  93558. */
  93559. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93560. /**
  93561. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93562. * This allowed control for front to back rendering or reversly depending of the special needs.
  93563. *
  93564. * @param renderingGroupId The rendering group id corresponding to its index
  93565. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93566. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93567. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93568. */
  93569. 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;
  93570. /**
  93571. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93572. *
  93573. * @param renderingGroupId The rendering group id corresponding to its index
  93574. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93575. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93576. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93577. */
  93578. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93579. /**
  93580. * Gets the current auto clear configuration for one rendering group of the rendering
  93581. * manager.
  93582. * @param index the rendering group index to get the information for
  93583. * @returns The auto clear setup for the requested rendering group
  93584. */
  93585. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93586. private _blockMaterialDirtyMechanism;
  93587. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93588. blockMaterialDirtyMechanism: boolean;
  93589. /**
  93590. * Will flag all materials as dirty to trigger new shader compilation
  93591. * @param flag defines the flag used to specify which material part must be marked as dirty
  93592. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93593. */
  93594. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93595. /** @hidden */
  93596. _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;
  93597. /** @hidden */
  93598. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93599. }
  93600. }
  93601. declare module BABYLON {
  93602. /**
  93603. * Set of assets to keep when moving a scene into an asset container.
  93604. */
  93605. export class KeepAssets extends AbstractScene {
  93606. }
  93607. /**
  93608. * Container with a set of assets that can be added or removed from a scene.
  93609. */
  93610. export class AssetContainer extends AbstractScene {
  93611. /**
  93612. * The scene the AssetContainer belongs to.
  93613. */
  93614. scene: Scene;
  93615. /**
  93616. * Instantiates an AssetContainer.
  93617. * @param scene The scene the AssetContainer belongs to.
  93618. */
  93619. constructor(scene: Scene);
  93620. /**
  93621. * Adds all the assets from the container to the scene.
  93622. */
  93623. addAllToScene(): void;
  93624. /**
  93625. * Removes all the assets in the container from the scene
  93626. */
  93627. removeAllFromScene(): void;
  93628. /**
  93629. * Disposes all the assets in the container
  93630. */
  93631. dispose(): void;
  93632. private _moveAssets;
  93633. /**
  93634. * Removes all the assets contained in the scene and adds them to the container.
  93635. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93636. */
  93637. moveAllFromScene(keepAssets?: KeepAssets): void;
  93638. /**
  93639. * 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.
  93640. * @returns the root mesh
  93641. */
  93642. createRootMesh(): Mesh;
  93643. }
  93644. }
  93645. declare module BABYLON {
  93646. /**
  93647. * Defines how the parser contract is defined.
  93648. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93649. */
  93650. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93651. /**
  93652. * Defines how the individual parser contract is defined.
  93653. * These parser can parse an individual asset
  93654. */
  93655. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93656. /**
  93657. * Base class of the scene acting as a container for the different elements composing a scene.
  93658. * This class is dynamically extended by the different components of the scene increasing
  93659. * flexibility and reducing coupling
  93660. */
  93661. export abstract class AbstractScene {
  93662. /**
  93663. * Stores the list of available parsers in the application.
  93664. */
  93665. private static _BabylonFileParsers;
  93666. /**
  93667. * Stores the list of available individual parsers in the application.
  93668. */
  93669. private static _IndividualBabylonFileParsers;
  93670. /**
  93671. * Adds a parser in the list of available ones
  93672. * @param name Defines the name of the parser
  93673. * @param parser Defines the parser to add
  93674. */
  93675. static AddParser(name: string, parser: BabylonFileParser): void;
  93676. /**
  93677. * Gets a general parser from the list of avaialble ones
  93678. * @param name Defines the name of the parser
  93679. * @returns the requested parser or null
  93680. */
  93681. static GetParser(name: string): Nullable<BabylonFileParser>;
  93682. /**
  93683. * Adds n individual parser in the list of available ones
  93684. * @param name Defines the name of the parser
  93685. * @param parser Defines the parser to add
  93686. */
  93687. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93688. /**
  93689. * Gets an individual parser from the list of avaialble ones
  93690. * @param name Defines the name of the parser
  93691. * @returns the requested parser or null
  93692. */
  93693. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93694. /**
  93695. * Parser json data and populate both a scene and its associated container object
  93696. * @param jsonData Defines the data to parse
  93697. * @param scene Defines the scene to parse the data for
  93698. * @param container Defines the container attached to the parsing sequence
  93699. * @param rootUrl Defines the root url of the data
  93700. */
  93701. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93702. /**
  93703. * Gets the list of root nodes (ie. nodes with no parent)
  93704. */
  93705. rootNodes: Node[];
  93706. /** All of the cameras added to this scene
  93707. * @see http://doc.babylonjs.com/babylon101/cameras
  93708. */
  93709. cameras: Camera[];
  93710. /**
  93711. * All of the lights added to this scene
  93712. * @see http://doc.babylonjs.com/babylon101/lights
  93713. */
  93714. lights: Light[];
  93715. /**
  93716. * All of the (abstract) meshes added to this scene
  93717. */
  93718. meshes: AbstractMesh[];
  93719. /**
  93720. * The list of skeletons added to the scene
  93721. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93722. */
  93723. skeletons: Skeleton[];
  93724. /**
  93725. * All of the particle systems added to this scene
  93726. * @see http://doc.babylonjs.com/babylon101/particles
  93727. */
  93728. particleSystems: IParticleSystem[];
  93729. /**
  93730. * Gets a list of Animations associated with the scene
  93731. */
  93732. animations: Animation[];
  93733. /**
  93734. * All of the animation groups added to this scene
  93735. * @see http://doc.babylonjs.com/how_to/group
  93736. */
  93737. animationGroups: AnimationGroup[];
  93738. /**
  93739. * All of the multi-materials added to this scene
  93740. * @see http://doc.babylonjs.com/how_to/multi_materials
  93741. */
  93742. multiMaterials: MultiMaterial[];
  93743. /**
  93744. * All of the materials added to this scene
  93745. * In the context of a Scene, it is not supposed to be modified manually.
  93746. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93747. * Note also that the order of the Material wihin the array is not significant and might change.
  93748. * @see http://doc.babylonjs.com/babylon101/materials
  93749. */
  93750. materials: Material[];
  93751. /**
  93752. * The list of morph target managers added to the scene
  93753. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93754. */
  93755. morphTargetManagers: MorphTargetManager[];
  93756. /**
  93757. * The list of geometries used in the scene.
  93758. */
  93759. geometries: Geometry[];
  93760. /**
  93761. * All of the tranform nodes added to this scene
  93762. * In the context of a Scene, it is not supposed to be modified manually.
  93763. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93764. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93765. * @see http://doc.babylonjs.com/how_to/transformnode
  93766. */
  93767. transformNodes: TransformNode[];
  93768. /**
  93769. * ActionManagers available on the scene.
  93770. */
  93771. actionManagers: AbstractActionManager[];
  93772. /**
  93773. * Textures to keep.
  93774. */
  93775. textures: BaseTexture[];
  93776. /**
  93777. * Environment texture for the scene
  93778. */
  93779. environmentTexture: Nullable<BaseTexture>;
  93780. }
  93781. }
  93782. declare module BABYLON {
  93783. /**
  93784. * Defines a sound that can be played in the application.
  93785. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93787. */
  93788. export class Sound {
  93789. /**
  93790. * The name of the sound in the scene.
  93791. */
  93792. name: string;
  93793. /**
  93794. * Does the sound autoplay once loaded.
  93795. */
  93796. autoplay: boolean;
  93797. /**
  93798. * Does the sound loop after it finishes playing once.
  93799. */
  93800. loop: boolean;
  93801. /**
  93802. * Does the sound use a custom attenuation curve to simulate the falloff
  93803. * happening when the source gets further away from the camera.
  93804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93805. */
  93806. useCustomAttenuation: boolean;
  93807. /**
  93808. * The sound track id this sound belongs to.
  93809. */
  93810. soundTrackId: number;
  93811. /**
  93812. * Is this sound currently played.
  93813. */
  93814. isPlaying: boolean;
  93815. /**
  93816. * Is this sound currently paused.
  93817. */
  93818. isPaused: boolean;
  93819. /**
  93820. * Does this sound enables spatial sound.
  93821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93822. */
  93823. spatialSound: boolean;
  93824. /**
  93825. * Define the reference distance the sound should be heard perfectly.
  93826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93827. */
  93828. refDistance: number;
  93829. /**
  93830. * Define the roll off factor of spatial sounds.
  93831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93832. */
  93833. rolloffFactor: number;
  93834. /**
  93835. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93837. */
  93838. maxDistance: number;
  93839. /**
  93840. * Define the distance attenuation model the sound will follow.
  93841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93842. */
  93843. distanceModel: string;
  93844. /**
  93845. * @hidden
  93846. * Back Compat
  93847. **/
  93848. onended: () => any;
  93849. /**
  93850. * Observable event when the current playing sound finishes.
  93851. */
  93852. onEndedObservable: Observable<Sound>;
  93853. private _panningModel;
  93854. private _playbackRate;
  93855. private _streaming;
  93856. private _startTime;
  93857. private _startOffset;
  93858. private _position;
  93859. /** @hidden */
  93860. _positionInEmitterSpace: boolean;
  93861. private _localDirection;
  93862. private _volume;
  93863. private _isReadyToPlay;
  93864. private _isDirectional;
  93865. private _readyToPlayCallback;
  93866. private _audioBuffer;
  93867. private _soundSource;
  93868. private _streamingSource;
  93869. private _soundPanner;
  93870. private _soundGain;
  93871. private _inputAudioNode;
  93872. private _outputAudioNode;
  93873. private _coneInnerAngle;
  93874. private _coneOuterAngle;
  93875. private _coneOuterGain;
  93876. private _scene;
  93877. private _connectedTransformNode;
  93878. private _customAttenuationFunction;
  93879. private _registerFunc;
  93880. private _isOutputConnected;
  93881. private _htmlAudioElement;
  93882. private _urlType;
  93883. /** @hidden */
  93884. static _SceneComponentInitialization: (scene: Scene) => void;
  93885. /**
  93886. * Create a sound and attach it to a scene
  93887. * @param name Name of your sound
  93888. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93889. * @param scene defines the scene the sound belongs to
  93890. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93891. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93892. */
  93893. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93894. /**
  93895. * Release the sound and its associated resources
  93896. */
  93897. dispose(): void;
  93898. /**
  93899. * Gets if the sounds is ready to be played or not.
  93900. * @returns true if ready, otherwise false
  93901. */
  93902. isReady(): boolean;
  93903. private _soundLoaded;
  93904. /**
  93905. * Sets the data of the sound from an audiobuffer
  93906. * @param audioBuffer The audioBuffer containing the data
  93907. */
  93908. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93909. /**
  93910. * Updates the current sounds options such as maxdistance, loop...
  93911. * @param options A JSON object containing values named as the object properties
  93912. */
  93913. updateOptions(options: any): void;
  93914. private _createSpatialParameters;
  93915. private _updateSpatialParameters;
  93916. /**
  93917. * Switch the panning model to HRTF:
  93918. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93920. */
  93921. switchPanningModelToHRTF(): void;
  93922. /**
  93923. * Switch the panning model to Equal Power:
  93924. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93926. */
  93927. switchPanningModelToEqualPower(): void;
  93928. private _switchPanningModel;
  93929. /**
  93930. * Connect this sound to a sound track audio node like gain...
  93931. * @param soundTrackAudioNode the sound track audio node to connect to
  93932. */
  93933. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93934. /**
  93935. * Transform this sound into a directional source
  93936. * @param coneInnerAngle Size of the inner cone in degree
  93937. * @param coneOuterAngle Size of the outer cone in degree
  93938. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93939. */
  93940. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93941. /**
  93942. * Gets or sets the inner angle for the directional cone.
  93943. */
  93944. /**
  93945. * Gets or sets the inner angle for the directional cone.
  93946. */
  93947. directionalConeInnerAngle: number;
  93948. /**
  93949. * Gets or sets the outer angle for the directional cone.
  93950. */
  93951. /**
  93952. * Gets or sets the outer angle for the directional cone.
  93953. */
  93954. directionalConeOuterAngle: number;
  93955. /**
  93956. * Sets the position of the emitter if spatial sound is enabled
  93957. * @param newPosition Defines the new posisiton
  93958. */
  93959. setPosition(newPosition: Vector3): void;
  93960. /**
  93961. * Sets the local direction of the emitter if spatial sound is enabled
  93962. * @param newLocalDirection Defines the new local direction
  93963. */
  93964. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93965. private _updateDirection;
  93966. /** @hidden */
  93967. updateDistanceFromListener(): void;
  93968. /**
  93969. * Sets a new custom attenuation function for the sound.
  93970. * @param callback Defines the function used for the attenuation
  93971. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93972. */
  93973. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93974. /**
  93975. * Play the sound
  93976. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93977. * @param offset (optional) Start the sound setting it at a specific time
  93978. */
  93979. play(time?: number, offset?: number): void;
  93980. private _onended;
  93981. /**
  93982. * Stop the sound
  93983. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93984. */
  93985. stop(time?: number): void;
  93986. /**
  93987. * Put the sound in pause
  93988. */
  93989. pause(): void;
  93990. /**
  93991. * Sets a dedicated volume for this sounds
  93992. * @param newVolume Define the new volume of the sound
  93993. * @param time Define in how long the sound should be at this value
  93994. */
  93995. setVolume(newVolume: number, time?: number): void;
  93996. /**
  93997. * Set the sound play back rate
  93998. * @param newPlaybackRate Define the playback rate the sound should be played at
  93999. */
  94000. setPlaybackRate(newPlaybackRate: number): void;
  94001. /**
  94002. * Gets the volume of the sound.
  94003. * @returns the volume of the sound
  94004. */
  94005. getVolume(): number;
  94006. /**
  94007. * Attach the sound to a dedicated mesh
  94008. * @param transformNode The transform node to connect the sound with
  94009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94010. */
  94011. attachToMesh(transformNode: TransformNode): void;
  94012. /**
  94013. * Detach the sound from the previously attached mesh
  94014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94015. */
  94016. detachFromMesh(): void;
  94017. private _onRegisterAfterWorldMatrixUpdate;
  94018. /**
  94019. * Clone the current sound in the scene.
  94020. * @returns the new sound clone
  94021. */
  94022. clone(): Nullable<Sound>;
  94023. /**
  94024. * Gets the current underlying audio buffer containing the data
  94025. * @returns the audio buffer
  94026. */
  94027. getAudioBuffer(): Nullable<AudioBuffer>;
  94028. /**
  94029. * Serializes the Sound in a JSON representation
  94030. * @returns the JSON representation of the sound
  94031. */
  94032. serialize(): any;
  94033. /**
  94034. * Parse a JSON representation of a sound to innstantiate in a given scene
  94035. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  94036. * @param scene Define the scene the new parsed sound should be created in
  94037. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  94038. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  94039. * @returns the newly parsed sound
  94040. */
  94041. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  94042. }
  94043. }
  94044. declare module BABYLON {
  94045. /**
  94046. * This defines an action helpful to play a defined sound on a triggered action.
  94047. */
  94048. export class PlaySoundAction extends Action {
  94049. private _sound;
  94050. /**
  94051. * Instantiate the action
  94052. * @param triggerOptions defines the trigger options
  94053. * @param sound defines the sound to play
  94054. * @param condition defines the trigger related conditions
  94055. */
  94056. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94057. /** @hidden */
  94058. _prepare(): void;
  94059. /**
  94060. * Execute the action and play the sound.
  94061. */
  94062. execute(): void;
  94063. /**
  94064. * Serializes the actions and its related information.
  94065. * @param parent defines the object to serialize in
  94066. * @returns the serialized object
  94067. */
  94068. serialize(parent: any): any;
  94069. }
  94070. /**
  94071. * This defines an action helpful to stop a defined sound on a triggered action.
  94072. */
  94073. export class StopSoundAction extends Action {
  94074. private _sound;
  94075. /**
  94076. * Instantiate the action
  94077. * @param triggerOptions defines the trigger options
  94078. * @param sound defines the sound to stop
  94079. * @param condition defines the trigger related conditions
  94080. */
  94081. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94082. /** @hidden */
  94083. _prepare(): void;
  94084. /**
  94085. * Execute the action and stop the sound.
  94086. */
  94087. execute(): void;
  94088. /**
  94089. * Serializes the actions and its related information.
  94090. * @param parent defines the object to serialize in
  94091. * @returns the serialized object
  94092. */
  94093. serialize(parent: any): any;
  94094. }
  94095. }
  94096. declare module BABYLON {
  94097. /**
  94098. * This defines an action responsible to change the value of a property
  94099. * by interpolating between its current value and the newly set one once triggered.
  94100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94101. */
  94102. export class InterpolateValueAction extends Action {
  94103. /**
  94104. * Defines the path of the property where the value should be interpolated
  94105. */
  94106. propertyPath: string;
  94107. /**
  94108. * Defines the target value at the end of the interpolation.
  94109. */
  94110. value: any;
  94111. /**
  94112. * Defines the time it will take for the property to interpolate to the value.
  94113. */
  94114. duration: number;
  94115. /**
  94116. * Defines if the other scene animations should be stopped when the action has been triggered
  94117. */
  94118. stopOtherAnimations?: boolean;
  94119. /**
  94120. * Defines a callback raised once the interpolation animation has been done.
  94121. */
  94122. onInterpolationDone?: () => void;
  94123. /**
  94124. * Observable triggered once the interpolation animation has been done.
  94125. */
  94126. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  94127. private _target;
  94128. private _effectiveTarget;
  94129. private _property;
  94130. /**
  94131. * Instantiate the action
  94132. * @param triggerOptions defines the trigger options
  94133. * @param target defines the object containing the value to interpolate
  94134. * @param propertyPath defines the path to the property in the target object
  94135. * @param value defines the target value at the end of the interpolation
  94136. * @param duration deines the time it will take for the property to interpolate to the value.
  94137. * @param condition defines the trigger related conditions
  94138. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  94139. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  94140. */
  94141. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  94142. /** @hidden */
  94143. _prepare(): void;
  94144. /**
  94145. * Execute the action starts the value interpolation.
  94146. */
  94147. execute(): void;
  94148. /**
  94149. * Serializes the actions and its related information.
  94150. * @param parent defines the object to serialize in
  94151. * @returns the serialized object
  94152. */
  94153. serialize(parent: any): any;
  94154. }
  94155. }
  94156. declare module BABYLON {
  94157. /**
  94158. * Options allowed during the creation of a sound track.
  94159. */
  94160. export interface ISoundTrackOptions {
  94161. /**
  94162. * The volume the sound track should take during creation
  94163. */
  94164. volume?: number;
  94165. /**
  94166. * Define if the sound track is the main sound track of the scene
  94167. */
  94168. mainTrack?: boolean;
  94169. }
  94170. /**
  94171. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  94172. * It will be also used in a future release to apply effects on a specific track.
  94173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94174. */
  94175. export class SoundTrack {
  94176. /**
  94177. * The unique identifier of the sound track in the scene.
  94178. */
  94179. id: number;
  94180. /**
  94181. * The list of sounds included in the sound track.
  94182. */
  94183. soundCollection: Array<Sound>;
  94184. private _outputAudioNode;
  94185. private _scene;
  94186. private _isMainTrack;
  94187. private _connectedAnalyser;
  94188. private _options;
  94189. private _isInitialized;
  94190. /**
  94191. * Creates a new sound track.
  94192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94193. * @param scene Define the scene the sound track belongs to
  94194. * @param options
  94195. */
  94196. constructor(scene: Scene, options?: ISoundTrackOptions);
  94197. private _initializeSoundTrackAudioGraph;
  94198. /**
  94199. * Release the sound track and its associated resources
  94200. */
  94201. dispose(): void;
  94202. /**
  94203. * Adds a sound to this sound track
  94204. * @param sound define the cound to add
  94205. * @ignoreNaming
  94206. */
  94207. AddSound(sound: Sound): void;
  94208. /**
  94209. * Removes a sound to this sound track
  94210. * @param sound define the cound to remove
  94211. * @ignoreNaming
  94212. */
  94213. RemoveSound(sound: Sound): void;
  94214. /**
  94215. * Set a global volume for the full sound track.
  94216. * @param newVolume Define the new volume of the sound track
  94217. */
  94218. setVolume(newVolume: number): void;
  94219. /**
  94220. * Switch the panning model to HRTF:
  94221. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94223. */
  94224. switchPanningModelToHRTF(): void;
  94225. /**
  94226. * Switch the panning model to Equal Power:
  94227. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94229. */
  94230. switchPanningModelToEqualPower(): void;
  94231. /**
  94232. * Connect the sound track to an audio analyser allowing some amazing
  94233. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94235. * @param analyser The analyser to connect to the engine
  94236. */
  94237. connectToAnalyser(analyser: Analyser): void;
  94238. }
  94239. }
  94240. declare module BABYLON {
  94241. interface AbstractScene {
  94242. /**
  94243. * The list of sounds used in the scene.
  94244. */
  94245. sounds: Nullable<Array<Sound>>;
  94246. }
  94247. interface Scene {
  94248. /**
  94249. * @hidden
  94250. * Backing field
  94251. */
  94252. _mainSoundTrack: SoundTrack;
  94253. /**
  94254. * The main sound track played by the scene.
  94255. * It cotains your primary collection of sounds.
  94256. */
  94257. mainSoundTrack: SoundTrack;
  94258. /**
  94259. * The list of sound tracks added to the scene
  94260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94261. */
  94262. soundTracks: Nullable<Array<SoundTrack>>;
  94263. /**
  94264. * Gets a sound using a given name
  94265. * @param name defines the name to search for
  94266. * @return the found sound or null if not found at all.
  94267. */
  94268. getSoundByName(name: string): Nullable<Sound>;
  94269. /**
  94270. * Gets or sets if audio support is enabled
  94271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94272. */
  94273. audioEnabled: boolean;
  94274. /**
  94275. * Gets or sets if audio will be output to headphones
  94276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94277. */
  94278. headphone: boolean;
  94279. }
  94280. /**
  94281. * Defines the sound scene component responsible to manage any sounds
  94282. * in a given scene.
  94283. */
  94284. export class AudioSceneComponent implements ISceneSerializableComponent {
  94285. /**
  94286. * The component name helpfull to identify the component in the list of scene components.
  94287. */
  94288. readonly name: string;
  94289. /**
  94290. * The scene the component belongs to.
  94291. */
  94292. scene: Scene;
  94293. private _audioEnabled;
  94294. /**
  94295. * Gets whether audio is enabled or not.
  94296. * Please use related enable/disable method to switch state.
  94297. */
  94298. readonly audioEnabled: boolean;
  94299. private _headphone;
  94300. /**
  94301. * Gets whether audio is outputing to headphone or not.
  94302. * Please use the according Switch methods to change output.
  94303. */
  94304. readonly headphone: boolean;
  94305. /**
  94306. * Creates a new instance of the component for the given scene
  94307. * @param scene Defines the scene to register the component in
  94308. */
  94309. constructor(scene: Scene);
  94310. /**
  94311. * Registers the component in a given scene
  94312. */
  94313. register(): void;
  94314. /**
  94315. * Rebuilds the elements related to this component in case of
  94316. * context lost for instance.
  94317. */
  94318. rebuild(): void;
  94319. /**
  94320. * Serializes the component data to the specified json object
  94321. * @param serializationObject The object to serialize to
  94322. */
  94323. serialize(serializationObject: any): void;
  94324. /**
  94325. * Adds all the element from the container to the scene
  94326. * @param container the container holding the elements
  94327. */
  94328. addFromContainer(container: AbstractScene): void;
  94329. /**
  94330. * Removes all the elements in the container from the scene
  94331. * @param container contains the elements to remove
  94332. * @param dispose if the removed element should be disposed (default: false)
  94333. */
  94334. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  94335. /**
  94336. * Disposes the component and the associated ressources.
  94337. */
  94338. dispose(): void;
  94339. /**
  94340. * Disables audio in the associated scene.
  94341. */
  94342. disableAudio(): void;
  94343. /**
  94344. * Enables audio in the associated scene.
  94345. */
  94346. enableAudio(): void;
  94347. /**
  94348. * Switch audio to headphone output.
  94349. */
  94350. switchAudioModeForHeadphones(): void;
  94351. /**
  94352. * Switch audio to normal speakers.
  94353. */
  94354. switchAudioModeForNormalSpeakers(): void;
  94355. private _afterRender;
  94356. }
  94357. }
  94358. declare module BABYLON {
  94359. /**
  94360. * Wraps one or more Sound objects and selects one with random weight for playback.
  94361. */
  94362. export class WeightedSound {
  94363. /** When true a Sound will be selected and played when the current playing Sound completes. */
  94364. loop: boolean;
  94365. private _coneInnerAngle;
  94366. private _coneOuterAngle;
  94367. private _volume;
  94368. /** A Sound is currently playing. */
  94369. isPlaying: boolean;
  94370. /** A Sound is currently paused. */
  94371. isPaused: boolean;
  94372. private _sounds;
  94373. private _weights;
  94374. private _currentIndex?;
  94375. /**
  94376. * Creates a new WeightedSound from the list of sounds given.
  94377. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  94378. * @param sounds Array of Sounds that will be selected from.
  94379. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  94380. */
  94381. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  94382. /**
  94383. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  94384. */
  94385. /**
  94386. * The size of cone in degress for a directional sound in which there will be no attenuation.
  94387. */
  94388. directionalConeInnerAngle: number;
  94389. /**
  94390. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94391. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94392. */
  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. directionalConeOuterAngle: number;
  94398. /**
  94399. * Playback volume.
  94400. */
  94401. /**
  94402. * Playback volume.
  94403. */
  94404. volume: number;
  94405. private _onended;
  94406. /**
  94407. * Suspend playback
  94408. */
  94409. pause(): void;
  94410. /**
  94411. * Stop playback
  94412. */
  94413. stop(): void;
  94414. /**
  94415. * Start playback.
  94416. * @param startOffset Position the clip head at a specific time in seconds.
  94417. */
  94418. play(startOffset?: number): void;
  94419. }
  94420. }
  94421. declare module BABYLON {
  94422. /**
  94423. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  94424. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94425. */
  94426. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  94427. /**
  94428. * Gets the name of the behavior.
  94429. */
  94430. readonly name: string;
  94431. /**
  94432. * The easing function used by animations
  94433. */
  94434. static EasingFunction: BackEase;
  94435. /**
  94436. * The easing mode used by animations
  94437. */
  94438. static EasingMode: number;
  94439. /**
  94440. * The duration of the animation, in milliseconds
  94441. */
  94442. transitionDuration: number;
  94443. /**
  94444. * Length of the distance animated by the transition when lower radius is reached
  94445. */
  94446. lowerRadiusTransitionRange: number;
  94447. /**
  94448. * Length of the distance animated by the transition when upper radius is reached
  94449. */
  94450. upperRadiusTransitionRange: number;
  94451. private _autoTransitionRange;
  94452. /**
  94453. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94454. */
  94455. /**
  94456. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94457. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  94458. */
  94459. autoTransitionRange: boolean;
  94460. private _attachedCamera;
  94461. private _onAfterCheckInputsObserver;
  94462. private _onMeshTargetChangedObserver;
  94463. /**
  94464. * Initializes the behavior.
  94465. */
  94466. init(): void;
  94467. /**
  94468. * Attaches the behavior to its arc rotate camera.
  94469. * @param camera Defines the camera to attach the behavior to
  94470. */
  94471. attach(camera: ArcRotateCamera): void;
  94472. /**
  94473. * Detaches the behavior from its current arc rotate camera.
  94474. */
  94475. detach(): void;
  94476. private _radiusIsAnimating;
  94477. private _radiusBounceTransition;
  94478. private _animatables;
  94479. private _cachedWheelPrecision;
  94480. /**
  94481. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  94482. * @param radiusLimit The limit to check against.
  94483. * @return Bool to indicate if at limit.
  94484. */
  94485. private _isRadiusAtLimit;
  94486. /**
  94487. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  94488. * @param radiusDelta The delta by which to animate to. Can be negative.
  94489. */
  94490. private _applyBoundRadiusAnimation;
  94491. /**
  94492. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  94493. */
  94494. protected _clearAnimationLocks(): void;
  94495. /**
  94496. * Stops and removes all animations that have been applied to the camera
  94497. */
  94498. stopAllAnimations(): void;
  94499. }
  94500. }
  94501. declare module BABYLON {
  94502. /**
  94503. * 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.
  94504. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94505. */
  94506. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  94507. /**
  94508. * Gets the name of the behavior.
  94509. */
  94510. readonly name: string;
  94511. private _mode;
  94512. private _radiusScale;
  94513. private _positionScale;
  94514. private _defaultElevation;
  94515. private _elevationReturnTime;
  94516. private _elevationReturnWaitTime;
  94517. private _zoomStopsAnimation;
  94518. private _framingTime;
  94519. /**
  94520. * The easing function used by animations
  94521. */
  94522. static EasingFunction: ExponentialEase;
  94523. /**
  94524. * The easing mode used by animations
  94525. */
  94526. static EasingMode: number;
  94527. /**
  94528. * Sets the current mode used by the behavior
  94529. */
  94530. /**
  94531. * Gets current mode used by the behavior.
  94532. */
  94533. mode: number;
  94534. /**
  94535. * Sets the scale applied to the radius (1 by default)
  94536. */
  94537. /**
  94538. * Gets the scale applied to the radius
  94539. */
  94540. radiusScale: number;
  94541. /**
  94542. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94543. */
  94544. /**
  94545. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94546. */
  94547. positionScale: number;
  94548. /**
  94549. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94550. * behaviour is triggered, in radians.
  94551. */
  94552. /**
  94553. * Gets 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. defaultElevation: number;
  94557. /**
  94558. * Sets the time (in milliseconds) taken to return to the default beta position.
  94559. * Negative value indicates camera should not return to default.
  94560. */
  94561. /**
  94562. * Gets the time (in milliseconds) taken to return to the default beta position.
  94563. * Negative value indicates camera should not return to default.
  94564. */
  94565. elevationReturnTime: number;
  94566. /**
  94567. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94568. */
  94569. /**
  94570. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94571. */
  94572. elevationReturnWaitTime: number;
  94573. /**
  94574. * Sets the flag that indicates if user zooming should stop animation.
  94575. */
  94576. /**
  94577. * Gets the flag that indicates if user zooming should stop animation.
  94578. */
  94579. zoomStopsAnimation: boolean;
  94580. /**
  94581. * Sets the transition time when framing the mesh, in milliseconds
  94582. */
  94583. /**
  94584. * Gets the transition time when framing the mesh, in milliseconds
  94585. */
  94586. framingTime: number;
  94587. /**
  94588. * Define if the behavior should automatically change the configured
  94589. * camera limits and sensibilities.
  94590. */
  94591. autoCorrectCameraLimitsAndSensibility: boolean;
  94592. private _onPrePointerObservableObserver;
  94593. private _onAfterCheckInputsObserver;
  94594. private _onMeshTargetChangedObserver;
  94595. private _attachedCamera;
  94596. private _isPointerDown;
  94597. private _lastInteractionTime;
  94598. /**
  94599. * Initializes the behavior.
  94600. */
  94601. init(): void;
  94602. /**
  94603. * Attaches the behavior to its arc rotate camera.
  94604. * @param camera Defines the camera to attach the behavior to
  94605. */
  94606. attach(camera: ArcRotateCamera): void;
  94607. /**
  94608. * Detaches the behavior from its current arc rotate camera.
  94609. */
  94610. detach(): void;
  94611. private _animatables;
  94612. private _betaIsAnimating;
  94613. private _betaTransition;
  94614. private _radiusTransition;
  94615. private _vectorTransition;
  94616. /**
  94617. * Targets the given mesh and updates zoom level accordingly.
  94618. * @param mesh The mesh to target.
  94619. * @param radius Optional. If a cached radius position already exists, overrides default.
  94620. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94621. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94622. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94623. */
  94624. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94625. /**
  94626. * Targets the given mesh with its children and updates zoom level accordingly.
  94627. * @param mesh The mesh to target.
  94628. * @param radius Optional. If a cached radius position already exists, overrides default.
  94629. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94630. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94631. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94632. */
  94633. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94634. /**
  94635. * Targets the given meshes with their children and updates zoom level accordingly.
  94636. * @param meshes The mesh to target.
  94637. * @param radius Optional. If a cached radius position already exists, overrides default.
  94638. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94639. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94640. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94641. */
  94642. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94643. /**
  94644. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94645. * @param minimumWorld Determines the smaller position of the bounding box extend
  94646. * @param maximumWorld Determines the bigger position of the bounding box extend
  94647. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94648. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94649. */
  94650. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94651. /**
  94652. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94653. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94654. * frustum width.
  94655. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94656. * to fully enclose the mesh in the viewing frustum.
  94657. */
  94658. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94659. /**
  94660. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94661. * is automatically returned to its default position (expected to be above ground plane).
  94662. */
  94663. private _maintainCameraAboveGround;
  94664. /**
  94665. * Returns the frustum slope based on the canvas ratio and camera FOV
  94666. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94667. */
  94668. private _getFrustumSlope;
  94669. /**
  94670. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94671. */
  94672. private _clearAnimationLocks;
  94673. /**
  94674. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94675. */
  94676. private _applyUserInteraction;
  94677. /**
  94678. * Stops and removes all animations that have been applied to the camera
  94679. */
  94680. stopAllAnimations(): void;
  94681. /**
  94682. * Gets a value indicating if the user is moving the camera
  94683. */
  94684. readonly isUserIsMoving: boolean;
  94685. /**
  94686. * The camera can move all the way towards the mesh.
  94687. */
  94688. static IgnoreBoundsSizeMode: number;
  94689. /**
  94690. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94691. */
  94692. static FitFrustumSidesMode: number;
  94693. }
  94694. }
  94695. declare module BABYLON {
  94696. /**
  94697. * Base class for Camera Pointer Inputs.
  94698. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94699. * for example usage.
  94700. */
  94701. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94702. /**
  94703. * Defines the camera the input is attached to.
  94704. */
  94705. abstract camera: Camera;
  94706. /**
  94707. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94708. */
  94709. protected _altKey: boolean;
  94710. protected _ctrlKey: boolean;
  94711. protected _metaKey: boolean;
  94712. protected _shiftKey: boolean;
  94713. /**
  94714. * Which mouse buttons were pressed at time of last mouse event.
  94715. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94716. */
  94717. protected _buttonsPressed: number;
  94718. /**
  94719. * Defines the buttons associated with the input to handle camera move.
  94720. */
  94721. buttons: number[];
  94722. /**
  94723. * Attach the input controls to a specific dom element to get the input from.
  94724. * @param element Defines the element the controls should be listened from
  94725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94726. */
  94727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94728. /**
  94729. * Detach the current controls from the specified dom element.
  94730. * @param element Defines the element to stop listening the inputs from
  94731. */
  94732. detachControl(element: Nullable<HTMLElement>): void;
  94733. /**
  94734. * Gets the class name of the current input.
  94735. * @returns the class name
  94736. */
  94737. getClassName(): string;
  94738. /**
  94739. * Get the friendly name associated with the input class.
  94740. * @returns the input friendly name
  94741. */
  94742. getSimpleName(): string;
  94743. /**
  94744. * Called on pointer POINTERDOUBLETAP event.
  94745. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94746. */
  94747. protected onDoubleTap(type: string): void;
  94748. /**
  94749. * Called on pointer POINTERMOVE event if only a single touch is active.
  94750. * Override this method to provide functionality.
  94751. */
  94752. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94753. /**
  94754. * Called on pointer POINTERMOVE event if multiple touches are active.
  94755. * Override this method to provide functionality.
  94756. */
  94757. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94758. /**
  94759. * Called on JS contextmenu event.
  94760. * Override this method to provide functionality.
  94761. */
  94762. protected onContextMenu(evt: PointerEvent): void;
  94763. /**
  94764. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94765. * press.
  94766. * Override this method to provide functionality.
  94767. */
  94768. protected onButtonDown(evt: PointerEvent): void;
  94769. /**
  94770. * Called each time a new POINTERUP event occurs. Ie, for each button
  94771. * release.
  94772. * Override this method to provide functionality.
  94773. */
  94774. protected onButtonUp(evt: PointerEvent): void;
  94775. /**
  94776. * Called when window becomes inactive.
  94777. * Override this method to provide functionality.
  94778. */
  94779. protected onLostFocus(): void;
  94780. private _pointerInput;
  94781. private _observer;
  94782. private _onLostFocus;
  94783. private pointA;
  94784. private pointB;
  94785. }
  94786. }
  94787. declare module BABYLON {
  94788. /**
  94789. * Manage the pointers inputs to control an arc rotate camera.
  94790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94791. */
  94792. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94793. /**
  94794. * Defines the camera the input is attached to.
  94795. */
  94796. camera: ArcRotateCamera;
  94797. /**
  94798. * Gets the class name of the current input.
  94799. * @returns the class name
  94800. */
  94801. getClassName(): string;
  94802. /**
  94803. * Defines the buttons associated with the input to handle camera move.
  94804. */
  94805. buttons: number[];
  94806. /**
  94807. * Defines the pointer angular sensibility along the X axis or how fast is
  94808. * the camera rotating.
  94809. */
  94810. angularSensibilityX: number;
  94811. /**
  94812. * Defines the pointer angular sensibility along the Y axis or how fast is
  94813. * the camera rotating.
  94814. */
  94815. angularSensibilityY: number;
  94816. /**
  94817. * Defines the pointer pinch precision or how fast is the camera zooming.
  94818. */
  94819. pinchPrecision: number;
  94820. /**
  94821. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94822. * from 0.
  94823. * It defines the percentage of current camera.radius to use as delta when
  94824. * pinch zoom is used.
  94825. */
  94826. pinchDeltaPercentage: number;
  94827. /**
  94828. * Defines the pointer panning sensibility or how fast is the camera moving.
  94829. */
  94830. panningSensibility: number;
  94831. /**
  94832. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94833. */
  94834. multiTouchPanning: boolean;
  94835. /**
  94836. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94837. * zoom (pinch) through multitouch.
  94838. */
  94839. multiTouchPanAndZoom: boolean;
  94840. /**
  94841. * Revers pinch action direction.
  94842. */
  94843. pinchInwards: boolean;
  94844. private _isPanClick;
  94845. private _twoFingerActivityCount;
  94846. private _isPinching;
  94847. /**
  94848. * Called on pointer POINTERMOVE event if only a single touch is active.
  94849. */
  94850. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94851. /**
  94852. * Called on pointer POINTERDOUBLETAP event.
  94853. */
  94854. protected onDoubleTap(type: string): void;
  94855. /**
  94856. * Called on pointer POINTERMOVE event if multiple touches are active.
  94857. */
  94858. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94859. /**
  94860. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94861. * press.
  94862. */
  94863. protected onButtonDown(evt: PointerEvent): void;
  94864. /**
  94865. * Called each time a new POINTERUP event occurs. Ie, for each button
  94866. * release.
  94867. */
  94868. protected onButtonUp(evt: PointerEvent): void;
  94869. /**
  94870. * Called when window becomes inactive.
  94871. */
  94872. protected onLostFocus(): void;
  94873. }
  94874. }
  94875. declare module BABYLON {
  94876. /**
  94877. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94879. */
  94880. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94881. /**
  94882. * Defines the camera the input is attached to.
  94883. */
  94884. camera: ArcRotateCamera;
  94885. /**
  94886. * Defines the list of key codes associated with the up action (increase alpha)
  94887. */
  94888. keysUp: number[];
  94889. /**
  94890. * Defines the list of key codes associated with the down action (decrease alpha)
  94891. */
  94892. keysDown: number[];
  94893. /**
  94894. * Defines the list of key codes associated with the left action (increase beta)
  94895. */
  94896. keysLeft: number[];
  94897. /**
  94898. * Defines the list of key codes associated with the right action (decrease beta)
  94899. */
  94900. keysRight: number[];
  94901. /**
  94902. * Defines the list of key codes associated with the reset action.
  94903. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94904. */
  94905. keysReset: number[];
  94906. /**
  94907. * Defines the panning sensibility of the inputs.
  94908. * (How fast is the camera paning)
  94909. */
  94910. panningSensibility: number;
  94911. /**
  94912. * Defines the zooming sensibility of the inputs.
  94913. * (How fast is the camera zooming)
  94914. */
  94915. zoomingSensibility: number;
  94916. /**
  94917. * Defines wether maintaining the alt key down switch the movement mode from
  94918. * orientation to zoom.
  94919. */
  94920. useAltToZoom: boolean;
  94921. /**
  94922. * Rotation speed of the camera
  94923. */
  94924. angularSpeed: number;
  94925. private _keys;
  94926. private _ctrlPressed;
  94927. private _altPressed;
  94928. private _onCanvasBlurObserver;
  94929. private _onKeyboardObserver;
  94930. private _engine;
  94931. private _scene;
  94932. /**
  94933. * Attach the input controls to a specific dom element to get the input from.
  94934. * @param element Defines the element the controls should be listened from
  94935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94936. */
  94937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94938. /**
  94939. * Detach the current controls from the specified dom element.
  94940. * @param element Defines the element to stop listening the inputs from
  94941. */
  94942. detachControl(element: Nullable<HTMLElement>): void;
  94943. /**
  94944. * Update the current camera state depending on the inputs that have been used this frame.
  94945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94946. */
  94947. checkInputs(): void;
  94948. /**
  94949. * Gets the class name of the current intput.
  94950. * @returns the class name
  94951. */
  94952. getClassName(): string;
  94953. /**
  94954. * Get the friendly name associated with the input class.
  94955. * @returns the input friendly name
  94956. */
  94957. getSimpleName(): string;
  94958. }
  94959. }
  94960. declare module BABYLON {
  94961. /**
  94962. * Manage the mouse wheel inputs to control an arc rotate camera.
  94963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94964. */
  94965. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94966. /**
  94967. * Defines the camera the input is attached to.
  94968. */
  94969. camera: ArcRotateCamera;
  94970. /**
  94971. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94972. */
  94973. wheelPrecision: number;
  94974. /**
  94975. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94976. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94977. */
  94978. wheelDeltaPercentage: number;
  94979. private _wheel;
  94980. private _observer;
  94981. private computeDeltaFromMouseWheelLegacyEvent;
  94982. /**
  94983. * Attach the input controls to a specific dom element to get the input from.
  94984. * @param element Defines the element the controls should be listened from
  94985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94986. */
  94987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94988. /**
  94989. * Detach the current controls from the specified dom element.
  94990. * @param element Defines the element to stop listening the inputs from
  94991. */
  94992. detachControl(element: Nullable<HTMLElement>): void;
  94993. /**
  94994. * Gets the class name of the current intput.
  94995. * @returns the class name
  94996. */
  94997. getClassName(): string;
  94998. /**
  94999. * Get the friendly name associated with the input class.
  95000. * @returns the input friendly name
  95001. */
  95002. getSimpleName(): string;
  95003. }
  95004. }
  95005. declare module BABYLON {
  95006. /**
  95007. * Default Inputs manager for the ArcRotateCamera.
  95008. * It groups all the default supported inputs for ease of use.
  95009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95010. */
  95011. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  95012. /**
  95013. * Instantiates a new ArcRotateCameraInputsManager.
  95014. * @param camera Defines the camera the inputs belong to
  95015. */
  95016. constructor(camera: ArcRotateCamera);
  95017. /**
  95018. * Add mouse wheel input support to the input manager.
  95019. * @returns the current input manager
  95020. */
  95021. addMouseWheel(): ArcRotateCameraInputsManager;
  95022. /**
  95023. * Add pointers input support to the input manager.
  95024. * @returns the current input manager
  95025. */
  95026. addPointers(): ArcRotateCameraInputsManager;
  95027. /**
  95028. * Add keyboard input support to the input manager.
  95029. * @returns the current input manager
  95030. */
  95031. addKeyboard(): ArcRotateCameraInputsManager;
  95032. }
  95033. }
  95034. declare module BABYLON {
  95035. /**
  95036. * This represents an orbital type of camera.
  95037. *
  95038. * 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.
  95039. * 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.
  95040. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  95041. */
  95042. export class ArcRotateCamera extends TargetCamera {
  95043. /**
  95044. * Defines the rotation angle of the camera along the longitudinal axis.
  95045. */
  95046. alpha: number;
  95047. /**
  95048. * Defines the rotation angle of the camera along the latitudinal axis.
  95049. */
  95050. beta: number;
  95051. /**
  95052. * Defines the radius of the camera from it s target point.
  95053. */
  95054. radius: number;
  95055. protected _target: Vector3;
  95056. protected _targetHost: Nullable<AbstractMesh>;
  95057. /**
  95058. * Defines the target point of the camera.
  95059. * The camera looks towards it form the radius distance.
  95060. */
  95061. target: Vector3;
  95062. /**
  95063. * Define the current local position of the camera in the scene
  95064. */
  95065. position: Vector3;
  95066. protected _upVector: Vector3;
  95067. protected _upToYMatrix: Matrix;
  95068. protected _YToUpMatrix: Matrix;
  95069. /**
  95070. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  95071. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  95072. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  95073. */
  95074. upVector: Vector3;
  95075. /**
  95076. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  95077. */
  95078. setMatUp(): void;
  95079. /**
  95080. * Current inertia value on the longitudinal axis.
  95081. * The bigger this number the longer it will take for the camera to stop.
  95082. */
  95083. inertialAlphaOffset: number;
  95084. /**
  95085. * Current inertia value on the latitudinal axis.
  95086. * The bigger this number the longer it will take for the camera to stop.
  95087. */
  95088. inertialBetaOffset: number;
  95089. /**
  95090. * Current inertia value on the radius axis.
  95091. * The bigger this number the longer it will take for the camera to stop.
  95092. */
  95093. inertialRadiusOffset: number;
  95094. /**
  95095. * Minimum allowed angle on the longitudinal axis.
  95096. * This can help limiting how the Camera is able to move in the scene.
  95097. */
  95098. lowerAlphaLimit: Nullable<number>;
  95099. /**
  95100. * Maximum allowed angle on the longitudinal axis.
  95101. * This can help limiting how the Camera is able to move in the scene.
  95102. */
  95103. upperAlphaLimit: Nullable<number>;
  95104. /**
  95105. * Minimum allowed angle on the latitudinal axis.
  95106. * This can help limiting how the Camera is able to move in the scene.
  95107. */
  95108. lowerBetaLimit: number;
  95109. /**
  95110. * Maximum allowed angle on the latitudinal axis.
  95111. * This can help limiting how the Camera is able to move in the scene.
  95112. */
  95113. upperBetaLimit: number;
  95114. /**
  95115. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  95116. * This can help limiting how the Camera is able to move in the scene.
  95117. */
  95118. lowerRadiusLimit: Nullable<number>;
  95119. /**
  95120. * Maximum allowed distance of the camera to the target (The camera can not get further).
  95121. * This can help limiting how the Camera is able to move in the scene.
  95122. */
  95123. upperRadiusLimit: Nullable<number>;
  95124. /**
  95125. * Defines the current inertia value used during panning of the camera along the X axis.
  95126. */
  95127. inertialPanningX: number;
  95128. /**
  95129. * Defines the current inertia value used during panning of the camera along the Y axis.
  95130. */
  95131. inertialPanningY: number;
  95132. /**
  95133. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  95134. * Basically if your fingers moves away from more than this distance you will be considered
  95135. * in pinch mode.
  95136. */
  95137. pinchToPanMaxDistance: number;
  95138. /**
  95139. * Defines the maximum distance the camera can pan.
  95140. * This could help keeping the cammera always in your scene.
  95141. */
  95142. panningDistanceLimit: Nullable<number>;
  95143. /**
  95144. * Defines the target of the camera before paning.
  95145. */
  95146. panningOriginTarget: Vector3;
  95147. /**
  95148. * Defines the value of the inertia used during panning.
  95149. * 0 would mean stop inertia and one would mean no decelleration at all.
  95150. */
  95151. panningInertia: number;
  95152. /**
  95153. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  95154. */
  95155. angularSensibilityX: number;
  95156. /**
  95157. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  95158. */
  95159. angularSensibilityY: number;
  95160. /**
  95161. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  95162. */
  95163. pinchPrecision: number;
  95164. /**
  95165. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  95166. * It will be used instead of pinchDeltaPrecision if different from 0.
  95167. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95168. */
  95169. pinchDeltaPercentage: number;
  95170. /**
  95171. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  95172. */
  95173. panningSensibility: number;
  95174. /**
  95175. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  95176. */
  95177. keysUp: number[];
  95178. /**
  95179. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  95180. */
  95181. keysDown: number[];
  95182. /**
  95183. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  95184. */
  95185. keysLeft: number[];
  95186. /**
  95187. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  95188. */
  95189. keysRight: number[];
  95190. /**
  95191. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95192. */
  95193. wheelPrecision: number;
  95194. /**
  95195. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  95196. * It will be used instead of pinchDeltaPrecision if different from 0.
  95197. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95198. */
  95199. wheelDeltaPercentage: number;
  95200. /**
  95201. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  95202. */
  95203. zoomOnFactor: number;
  95204. /**
  95205. * Defines a screen offset for the camera position.
  95206. */
  95207. targetScreenOffset: Vector2;
  95208. /**
  95209. * Allows the camera to be completely reversed.
  95210. * If false the camera can not arrive upside down.
  95211. */
  95212. allowUpsideDown: boolean;
  95213. /**
  95214. * Define if double tap/click is used to restore the previously saved state of the camera.
  95215. */
  95216. useInputToRestoreState: boolean;
  95217. /** @hidden */
  95218. _viewMatrix: Matrix;
  95219. /** @hidden */
  95220. _useCtrlForPanning: boolean;
  95221. /** @hidden */
  95222. _panningMouseButton: number;
  95223. /**
  95224. * Defines the input associated to the camera.
  95225. */
  95226. inputs: ArcRotateCameraInputsManager;
  95227. /** @hidden */
  95228. _reset: () => void;
  95229. /**
  95230. * Defines the allowed panning axis.
  95231. */
  95232. panningAxis: Vector3;
  95233. protected _localDirection: Vector3;
  95234. protected _transformedDirection: Vector3;
  95235. private _bouncingBehavior;
  95236. /**
  95237. * Gets the bouncing behavior of the camera if it has been enabled.
  95238. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95239. */
  95240. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  95241. /**
  95242. * Defines if the bouncing behavior of the camera is enabled on the camera.
  95243. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95244. */
  95245. useBouncingBehavior: boolean;
  95246. private _framingBehavior;
  95247. /**
  95248. * Gets the framing behavior of the camera if it has been enabled.
  95249. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95250. */
  95251. readonly framingBehavior: Nullable<FramingBehavior>;
  95252. /**
  95253. * Defines if the framing behavior of the camera is enabled on the camera.
  95254. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95255. */
  95256. useFramingBehavior: boolean;
  95257. private _autoRotationBehavior;
  95258. /**
  95259. * Gets the auto rotation behavior of the camera if it has been enabled.
  95260. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95261. */
  95262. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  95263. /**
  95264. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  95265. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95266. */
  95267. useAutoRotationBehavior: boolean;
  95268. /**
  95269. * Observable triggered when the mesh target has been changed on the camera.
  95270. */
  95271. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  95272. /**
  95273. * Event raised when the camera is colliding with a mesh.
  95274. */
  95275. onCollide: (collidedMesh: AbstractMesh) => void;
  95276. /**
  95277. * Defines whether the camera should check collision with the objects oh the scene.
  95278. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  95279. */
  95280. checkCollisions: boolean;
  95281. /**
  95282. * Defines the collision radius of the camera.
  95283. * This simulates a sphere around the camera.
  95284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95285. */
  95286. collisionRadius: Vector3;
  95287. protected _collider: Collider;
  95288. protected _previousPosition: Vector3;
  95289. protected _collisionVelocity: Vector3;
  95290. protected _newPosition: Vector3;
  95291. protected _previousAlpha: number;
  95292. protected _previousBeta: number;
  95293. protected _previousRadius: number;
  95294. protected _collisionTriggered: boolean;
  95295. protected _targetBoundingCenter: Nullable<Vector3>;
  95296. private _computationVector;
  95297. /**
  95298. * Instantiates a new ArcRotateCamera in a given scene
  95299. * @param name Defines the name of the camera
  95300. * @param alpha Defines the camera rotation along the logitudinal axis
  95301. * @param beta Defines the camera rotation along the latitudinal axis
  95302. * @param radius Defines the camera distance from its target
  95303. * @param target Defines the camera target
  95304. * @param scene Defines the scene the camera belongs to
  95305. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95306. */
  95307. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95308. /** @hidden */
  95309. _initCache(): void;
  95310. /** @hidden */
  95311. _updateCache(ignoreParentClass?: boolean): void;
  95312. protected _getTargetPosition(): Vector3;
  95313. private _storedAlpha;
  95314. private _storedBeta;
  95315. private _storedRadius;
  95316. private _storedTarget;
  95317. /**
  95318. * Stores the current state of the camera (alpha, beta, radius and target)
  95319. * @returns the camera itself
  95320. */
  95321. storeState(): Camera;
  95322. /**
  95323. * @hidden
  95324. * Restored camera state. You must call storeState() first
  95325. */
  95326. _restoreStateValues(): boolean;
  95327. /** @hidden */
  95328. _isSynchronizedViewMatrix(): boolean;
  95329. /**
  95330. * Attached controls to the current camera.
  95331. * @param element Defines the element the controls should be listened from
  95332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95333. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  95334. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  95335. */
  95336. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  95337. /**
  95338. * Detach the current controls from the camera.
  95339. * The camera will stop reacting to inputs.
  95340. * @param element Defines the element to stop listening the inputs from
  95341. */
  95342. detachControl(element: HTMLElement): void;
  95343. /** @hidden */
  95344. _checkInputs(): void;
  95345. protected _checkLimits(): void;
  95346. /**
  95347. * Rebuilds angles (alpha, beta) and radius from the give position and target
  95348. */
  95349. rebuildAnglesAndRadius(): void;
  95350. /**
  95351. * Use a position to define the current camera related information like aplha, beta and radius
  95352. * @param position Defines the position to set the camera at
  95353. */
  95354. setPosition(position: Vector3): void;
  95355. /**
  95356. * Defines the target the camera should look at.
  95357. * This will automatically adapt alpha beta and radius to fit within the new target.
  95358. * @param target Defines the new target as a Vector or a mesh
  95359. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  95360. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  95361. */
  95362. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  95363. /** @hidden */
  95364. _getViewMatrix(): Matrix;
  95365. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  95366. /**
  95367. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  95368. * @param meshes Defines the mesh to zoom on
  95369. * @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)
  95370. */
  95371. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  95372. /**
  95373. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  95374. * The target will be changed but the radius
  95375. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  95376. * @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)
  95377. */
  95378. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  95379. min: Vector3;
  95380. max: Vector3;
  95381. distance: number;
  95382. }, doNotUpdateMaxZ?: boolean): void;
  95383. /**
  95384. * @override
  95385. * Override Camera.createRigCamera
  95386. */
  95387. createRigCamera(name: string, cameraIndex: number): Camera;
  95388. /**
  95389. * @hidden
  95390. * @override
  95391. * Override Camera._updateRigCameras
  95392. */
  95393. _updateRigCameras(): void;
  95394. /**
  95395. * Destroy the camera and release the current resources hold by it.
  95396. */
  95397. dispose(): void;
  95398. /**
  95399. * Gets the current object class name.
  95400. * @return the class name
  95401. */
  95402. getClassName(): string;
  95403. }
  95404. }
  95405. declare module BABYLON {
  95406. /**
  95407. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  95408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95409. */
  95410. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  95411. /**
  95412. * Gets the name of the behavior.
  95413. */
  95414. readonly name: string;
  95415. private _zoomStopsAnimation;
  95416. private _idleRotationSpeed;
  95417. private _idleRotationWaitTime;
  95418. private _idleRotationSpinupTime;
  95419. /**
  95420. * Sets the flag that indicates if user zooming should stop animation.
  95421. */
  95422. /**
  95423. * Gets the flag that indicates if user zooming should stop animation.
  95424. */
  95425. zoomStopsAnimation: boolean;
  95426. /**
  95427. * Sets the default speed at which the camera rotates around the model.
  95428. */
  95429. /**
  95430. * Gets the default speed at which the camera rotates around the model.
  95431. */
  95432. idleRotationSpeed: number;
  95433. /**
  95434. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  95435. */
  95436. /**
  95437. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  95438. */
  95439. idleRotationWaitTime: number;
  95440. /**
  95441. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95442. */
  95443. /**
  95444. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95445. */
  95446. idleRotationSpinupTime: number;
  95447. /**
  95448. * Gets a value indicating if the camera is currently rotating because of this behavior
  95449. */
  95450. readonly rotationInProgress: boolean;
  95451. private _onPrePointerObservableObserver;
  95452. private _onAfterCheckInputsObserver;
  95453. private _attachedCamera;
  95454. private _isPointerDown;
  95455. private _lastFrameTime;
  95456. private _lastInteractionTime;
  95457. private _cameraRotationSpeed;
  95458. /**
  95459. * Initializes the behavior.
  95460. */
  95461. init(): void;
  95462. /**
  95463. * Attaches the behavior to its arc rotate camera.
  95464. * @param camera Defines the camera to attach the behavior to
  95465. */
  95466. attach(camera: ArcRotateCamera): void;
  95467. /**
  95468. * Detaches the behavior from its current arc rotate camera.
  95469. */
  95470. detach(): void;
  95471. /**
  95472. * Returns true if user is scrolling.
  95473. * @return true if user is scrolling.
  95474. */
  95475. private _userIsZooming;
  95476. private _lastFrameRadius;
  95477. private _shouldAnimationStopForInteraction;
  95478. /**
  95479. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  95480. */
  95481. private _applyUserInteraction;
  95482. private _userIsMoving;
  95483. }
  95484. }
  95485. declare module BABYLON {
  95486. /**
  95487. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  95488. */
  95489. export class AttachToBoxBehavior implements Behavior<Mesh> {
  95490. private ui;
  95491. /**
  95492. * The name of the behavior
  95493. */
  95494. name: string;
  95495. /**
  95496. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  95497. */
  95498. distanceAwayFromFace: number;
  95499. /**
  95500. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  95501. */
  95502. distanceAwayFromBottomOfFace: number;
  95503. private _faceVectors;
  95504. private _target;
  95505. private _scene;
  95506. private _onRenderObserver;
  95507. private _tmpMatrix;
  95508. private _tmpVector;
  95509. /**
  95510. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  95511. * @param ui The transform node that should be attched to the mesh
  95512. */
  95513. constructor(ui: TransformNode);
  95514. /**
  95515. * Initializes the behavior
  95516. */
  95517. init(): void;
  95518. private _closestFace;
  95519. private _zeroVector;
  95520. private _lookAtTmpMatrix;
  95521. private _lookAtToRef;
  95522. /**
  95523. * Attaches the AttachToBoxBehavior to the passed in mesh
  95524. * @param target The mesh that the specified node will be attached to
  95525. */
  95526. attach(target: Mesh): void;
  95527. /**
  95528. * Detaches the behavior from the mesh
  95529. */
  95530. detach(): void;
  95531. }
  95532. }
  95533. declare module BABYLON {
  95534. /**
  95535. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95536. */
  95537. export class FadeInOutBehavior implements Behavior<Mesh> {
  95538. /**
  95539. * Time in milliseconds to delay before fading in (Default: 0)
  95540. */
  95541. delay: number;
  95542. /**
  95543. * Time in milliseconds for the mesh to fade in (Default: 300)
  95544. */
  95545. fadeInTime: number;
  95546. private _millisecondsPerFrame;
  95547. private _hovered;
  95548. private _hoverValue;
  95549. private _ownerNode;
  95550. /**
  95551. * Instatiates the FadeInOutBehavior
  95552. */
  95553. constructor();
  95554. /**
  95555. * The name of the behavior
  95556. */
  95557. readonly name: string;
  95558. /**
  95559. * Initializes the behavior
  95560. */
  95561. init(): void;
  95562. /**
  95563. * Attaches the fade behavior on the passed in mesh
  95564. * @param ownerNode The mesh that will be faded in/out once attached
  95565. */
  95566. attach(ownerNode: Mesh): void;
  95567. /**
  95568. * Detaches the behavior from the mesh
  95569. */
  95570. detach(): void;
  95571. /**
  95572. * Triggers the mesh to begin fading in or out
  95573. * @param value if the object should fade in or out (true to fade in)
  95574. */
  95575. fadeIn(value: boolean): void;
  95576. private _update;
  95577. private _setAllVisibility;
  95578. }
  95579. }
  95580. declare module BABYLON {
  95581. /**
  95582. * Class containing a set of static utilities functions for managing Pivots
  95583. * @hidden
  95584. */
  95585. export class PivotTools {
  95586. private static _PivotCached;
  95587. private static _OldPivotPoint;
  95588. private static _PivotTranslation;
  95589. private static _PivotTmpVector;
  95590. /** @hidden */
  95591. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95592. /** @hidden */
  95593. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95594. }
  95595. }
  95596. declare module BABYLON {
  95597. /**
  95598. * Class containing static functions to help procedurally build meshes
  95599. */
  95600. export class PlaneBuilder {
  95601. /**
  95602. * Creates a plane mesh
  95603. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95604. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95605. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95609. * @param name defines the name of the mesh
  95610. * @param options defines the options used to create the mesh
  95611. * @param scene defines the hosting scene
  95612. * @returns the plane mesh
  95613. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95614. */
  95615. static CreatePlane(name: string, options: {
  95616. size?: number;
  95617. width?: number;
  95618. height?: number;
  95619. sideOrientation?: number;
  95620. frontUVs?: Vector4;
  95621. backUVs?: Vector4;
  95622. updatable?: boolean;
  95623. sourcePlane?: Plane;
  95624. }, scene?: Nullable<Scene>): Mesh;
  95625. }
  95626. }
  95627. declare module BABYLON {
  95628. /**
  95629. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95630. */
  95631. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95632. private static _AnyMouseID;
  95633. private _attachedNode;
  95634. private _dragPlane;
  95635. private _scene;
  95636. private _pointerObserver;
  95637. private _beforeRenderObserver;
  95638. private static _planeScene;
  95639. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95640. /**
  95641. * 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)
  95642. */
  95643. maxDragAngle: number;
  95644. /**
  95645. * @hidden
  95646. */
  95647. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95648. /**
  95649. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95650. */
  95651. currentDraggingPointerID: number;
  95652. /**
  95653. * The last position where the pointer hit the drag plane in world space
  95654. */
  95655. lastDragPosition: Vector3;
  95656. /**
  95657. * If the behavior is currently in a dragging state
  95658. */
  95659. dragging: boolean;
  95660. /**
  95661. * 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)
  95662. */
  95663. dragDeltaRatio: number;
  95664. /**
  95665. * If the drag plane orientation should be updated during the dragging (Default: true)
  95666. */
  95667. updateDragPlane: boolean;
  95668. private _debugMode;
  95669. private _moving;
  95670. /**
  95671. * Fires each time the attached mesh is dragged with the pointer
  95672. * * delta between last drag position and current drag position in world space
  95673. * * dragDistance along the drag axis
  95674. * * dragPlaneNormal normal of the current drag plane used during the drag
  95675. * * dragPlanePoint in world space where the drag intersects the drag plane
  95676. */
  95677. onDragObservable: Observable<{
  95678. delta: Vector3;
  95679. dragPlanePoint: Vector3;
  95680. dragPlaneNormal: Vector3;
  95681. dragDistance: number;
  95682. pointerId: number;
  95683. }>;
  95684. /**
  95685. * Fires each time a drag begins (eg. mouse down on mesh)
  95686. */
  95687. onDragStartObservable: Observable<{
  95688. dragPlanePoint: Vector3;
  95689. pointerId: number;
  95690. }>;
  95691. /**
  95692. * Fires each time a drag ends (eg. mouse release after drag)
  95693. */
  95694. onDragEndObservable: Observable<{
  95695. dragPlanePoint: Vector3;
  95696. pointerId: number;
  95697. }>;
  95698. /**
  95699. * If the attached mesh should be moved when dragged
  95700. */
  95701. moveAttached: boolean;
  95702. /**
  95703. * If the drag behavior will react to drag events (Default: true)
  95704. */
  95705. enabled: boolean;
  95706. /**
  95707. * If camera controls should be detached during the drag
  95708. */
  95709. detachCameraControls: boolean;
  95710. /**
  95711. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95712. */
  95713. useObjectOrienationForDragging: boolean;
  95714. private _options;
  95715. /**
  95716. * Creates a pointer drag behavior that can be attached to a mesh
  95717. * @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)
  95718. */
  95719. constructor(options?: {
  95720. dragAxis?: Vector3;
  95721. dragPlaneNormal?: Vector3;
  95722. });
  95723. /**
  95724. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95725. */
  95726. validateDrag: (targetPosition: Vector3) => boolean;
  95727. /**
  95728. * The name of the behavior
  95729. */
  95730. readonly name: string;
  95731. /**
  95732. * Initializes the behavior
  95733. */
  95734. init(): void;
  95735. private _tmpVector;
  95736. private _alternatePickedPoint;
  95737. private _worldDragAxis;
  95738. private _targetPosition;
  95739. private _attachedElement;
  95740. /**
  95741. * Attaches the drag behavior the passed in mesh
  95742. * @param ownerNode The mesh that will be dragged around once attached
  95743. */
  95744. attach(ownerNode: AbstractMesh): void;
  95745. /**
  95746. * Force relase the drag action by code.
  95747. */
  95748. releaseDrag(): void;
  95749. private _startDragRay;
  95750. private _lastPointerRay;
  95751. /**
  95752. * Simulates the start of a pointer drag event on the behavior
  95753. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95754. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95755. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95756. */
  95757. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95758. private _startDrag;
  95759. private _dragDelta;
  95760. private _moveDrag;
  95761. private _pickWithRayOnDragPlane;
  95762. private _pointA;
  95763. private _pointB;
  95764. private _pointC;
  95765. private _lineA;
  95766. private _lineB;
  95767. private _localAxis;
  95768. private _lookAt;
  95769. private _updateDragPlanePosition;
  95770. /**
  95771. * Detaches the behavior from the mesh
  95772. */
  95773. detach(): void;
  95774. }
  95775. }
  95776. declare module BABYLON {
  95777. /**
  95778. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95779. */
  95780. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95781. private _dragBehaviorA;
  95782. private _dragBehaviorB;
  95783. private _startDistance;
  95784. private _initialScale;
  95785. private _targetScale;
  95786. private _ownerNode;
  95787. private _sceneRenderObserver;
  95788. /**
  95789. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95790. */
  95791. constructor();
  95792. /**
  95793. * The name of the behavior
  95794. */
  95795. readonly name: string;
  95796. /**
  95797. * Initializes the behavior
  95798. */
  95799. init(): void;
  95800. private _getCurrentDistance;
  95801. /**
  95802. * Attaches the scale behavior the passed in mesh
  95803. * @param ownerNode The mesh that will be scaled around once attached
  95804. */
  95805. attach(ownerNode: Mesh): void;
  95806. /**
  95807. * Detaches the behavior from the mesh
  95808. */
  95809. detach(): void;
  95810. }
  95811. }
  95812. declare module BABYLON {
  95813. /**
  95814. * 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
  95815. */
  95816. export class SixDofDragBehavior implements Behavior<Mesh> {
  95817. private static _virtualScene;
  95818. private _ownerNode;
  95819. private _sceneRenderObserver;
  95820. private _scene;
  95821. private _targetPosition;
  95822. private _virtualOriginMesh;
  95823. private _virtualDragMesh;
  95824. private _pointerObserver;
  95825. private _moving;
  95826. private _startingOrientation;
  95827. /**
  95828. * 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)
  95829. */
  95830. private zDragFactor;
  95831. /**
  95832. * If the object should rotate to face the drag origin
  95833. */
  95834. rotateDraggedObject: boolean;
  95835. /**
  95836. * If the behavior is currently in a dragging state
  95837. */
  95838. dragging: boolean;
  95839. /**
  95840. * 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)
  95841. */
  95842. dragDeltaRatio: number;
  95843. /**
  95844. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95845. */
  95846. currentDraggingPointerID: number;
  95847. /**
  95848. * If camera controls should be detached during the drag
  95849. */
  95850. detachCameraControls: boolean;
  95851. /**
  95852. * Fires each time a drag starts
  95853. */
  95854. onDragStartObservable: Observable<{}>;
  95855. /**
  95856. * Fires each time a drag ends (eg. mouse release after drag)
  95857. */
  95858. onDragEndObservable: Observable<{}>;
  95859. /**
  95860. * 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
  95861. */
  95862. constructor();
  95863. /**
  95864. * The name of the behavior
  95865. */
  95866. readonly name: string;
  95867. /**
  95868. * Initializes the behavior
  95869. */
  95870. init(): void;
  95871. /**
  95872. * Attaches the scale behavior the passed in mesh
  95873. * @param ownerNode The mesh that will be scaled around once attached
  95874. */
  95875. attach(ownerNode: Mesh): void;
  95876. /**
  95877. * Detaches the behavior from the mesh
  95878. */
  95879. detach(): void;
  95880. }
  95881. }
  95882. declare module BABYLON {
  95883. /**
  95884. * Class used to apply inverse kinematics to bones
  95885. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95886. */
  95887. export class BoneIKController {
  95888. private static _tmpVecs;
  95889. private static _tmpQuat;
  95890. private static _tmpMats;
  95891. /**
  95892. * Gets or sets the target mesh
  95893. */
  95894. targetMesh: AbstractMesh;
  95895. /** Gets or sets the mesh used as pole */
  95896. poleTargetMesh: AbstractMesh;
  95897. /**
  95898. * Gets or sets the bone used as pole
  95899. */
  95900. poleTargetBone: Nullable<Bone>;
  95901. /**
  95902. * Gets or sets the target position
  95903. */
  95904. targetPosition: Vector3;
  95905. /**
  95906. * Gets or sets the pole target position
  95907. */
  95908. poleTargetPosition: Vector3;
  95909. /**
  95910. * Gets or sets the pole target local offset
  95911. */
  95912. poleTargetLocalOffset: Vector3;
  95913. /**
  95914. * Gets or sets the pole angle
  95915. */
  95916. poleAngle: number;
  95917. /**
  95918. * Gets or sets the mesh associated with the controller
  95919. */
  95920. mesh: AbstractMesh;
  95921. /**
  95922. * 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)
  95923. */
  95924. slerpAmount: number;
  95925. private _bone1Quat;
  95926. private _bone1Mat;
  95927. private _bone2Ang;
  95928. private _bone1;
  95929. private _bone2;
  95930. private _bone1Length;
  95931. private _bone2Length;
  95932. private _maxAngle;
  95933. private _maxReach;
  95934. private _rightHandedSystem;
  95935. private _bendAxis;
  95936. private _slerping;
  95937. private _adjustRoll;
  95938. /**
  95939. * Gets or sets maximum allowed angle
  95940. */
  95941. maxAngle: number;
  95942. /**
  95943. * Creates a new BoneIKController
  95944. * @param mesh defines the mesh to control
  95945. * @param bone defines the bone to control
  95946. * @param options defines options to set up the controller
  95947. */
  95948. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95949. targetMesh?: AbstractMesh;
  95950. poleTargetMesh?: AbstractMesh;
  95951. poleTargetBone?: Bone;
  95952. poleTargetLocalOffset?: Vector3;
  95953. poleAngle?: number;
  95954. bendAxis?: Vector3;
  95955. maxAngle?: number;
  95956. slerpAmount?: number;
  95957. });
  95958. private _setMaxAngle;
  95959. /**
  95960. * Force the controller to update the bones
  95961. */
  95962. update(): void;
  95963. }
  95964. }
  95965. declare module BABYLON {
  95966. /**
  95967. * Class used to make a bone look toward a point in space
  95968. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95969. */
  95970. export class BoneLookController {
  95971. private static _tmpVecs;
  95972. private static _tmpQuat;
  95973. private static _tmpMats;
  95974. /**
  95975. * The target Vector3 that the bone will look at
  95976. */
  95977. target: Vector3;
  95978. /**
  95979. * The mesh that the bone is attached to
  95980. */
  95981. mesh: AbstractMesh;
  95982. /**
  95983. * The bone that will be looking to the target
  95984. */
  95985. bone: Bone;
  95986. /**
  95987. * The up axis of the coordinate system that is used when the bone is rotated
  95988. */
  95989. upAxis: Vector3;
  95990. /**
  95991. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95992. */
  95993. upAxisSpace: Space;
  95994. /**
  95995. * Used to make an adjustment to the yaw of the bone
  95996. */
  95997. adjustYaw: number;
  95998. /**
  95999. * Used to make an adjustment to the pitch of the bone
  96000. */
  96001. adjustPitch: number;
  96002. /**
  96003. * Used to make an adjustment to the roll of the bone
  96004. */
  96005. adjustRoll: number;
  96006. /**
  96007. * 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)
  96008. */
  96009. slerpAmount: number;
  96010. private _minYaw;
  96011. private _maxYaw;
  96012. private _minPitch;
  96013. private _maxPitch;
  96014. private _minYawSin;
  96015. private _minYawCos;
  96016. private _maxYawSin;
  96017. private _maxYawCos;
  96018. private _midYawConstraint;
  96019. private _minPitchTan;
  96020. private _maxPitchTan;
  96021. private _boneQuat;
  96022. private _slerping;
  96023. private _transformYawPitch;
  96024. private _transformYawPitchInv;
  96025. private _firstFrameSkipped;
  96026. private _yawRange;
  96027. private _fowardAxis;
  96028. /**
  96029. * Gets or sets the minimum yaw angle that the bone can look to
  96030. */
  96031. minYaw: number;
  96032. /**
  96033. * Gets or sets the maximum yaw angle that the bone can look to
  96034. */
  96035. maxYaw: number;
  96036. /**
  96037. * Gets or sets the minimum pitch angle that the bone can look to
  96038. */
  96039. minPitch: number;
  96040. /**
  96041. * Gets or sets the maximum pitch angle that the bone can look to
  96042. */
  96043. maxPitch: number;
  96044. /**
  96045. * Create a BoneLookController
  96046. * @param mesh the mesh that the bone belongs to
  96047. * @param bone the bone that will be looking to the target
  96048. * @param target the target Vector3 to look at
  96049. * @param options optional settings:
  96050. * * maxYaw: the maximum angle the bone will yaw to
  96051. * * minYaw: the minimum angle the bone will yaw to
  96052. * * maxPitch: the maximum angle the bone will pitch to
  96053. * * minPitch: the minimum angle the bone will yaw to
  96054. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  96055. * * upAxis: the up axis of the coordinate system
  96056. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  96057. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  96058. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  96059. * * adjustYaw: used to make an adjustment to the yaw of the bone
  96060. * * adjustPitch: used to make an adjustment to the pitch of the bone
  96061. * * adjustRoll: used to make an adjustment to the roll of the bone
  96062. **/
  96063. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  96064. maxYaw?: number;
  96065. minYaw?: number;
  96066. maxPitch?: number;
  96067. minPitch?: number;
  96068. slerpAmount?: number;
  96069. upAxis?: Vector3;
  96070. upAxisSpace?: Space;
  96071. yawAxis?: Vector3;
  96072. pitchAxis?: Vector3;
  96073. adjustYaw?: number;
  96074. adjustPitch?: number;
  96075. adjustRoll?: number;
  96076. });
  96077. /**
  96078. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  96079. */
  96080. update(): void;
  96081. private _getAngleDiff;
  96082. private _getAngleBetween;
  96083. private _isAngleBetween;
  96084. }
  96085. }
  96086. declare module BABYLON {
  96087. /**
  96088. * Manage the gamepad inputs to control an arc rotate camera.
  96089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96090. */
  96091. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  96092. /**
  96093. * Defines the camera the input is attached to.
  96094. */
  96095. camera: ArcRotateCamera;
  96096. /**
  96097. * Defines the gamepad the input is gathering event from.
  96098. */
  96099. gamepad: Nullable<Gamepad>;
  96100. /**
  96101. * Defines the gamepad rotation sensiblity.
  96102. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96103. */
  96104. gamepadRotationSensibility: number;
  96105. /**
  96106. * Defines the gamepad move sensiblity.
  96107. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96108. */
  96109. gamepadMoveSensibility: number;
  96110. private _onGamepadConnectedObserver;
  96111. private _onGamepadDisconnectedObserver;
  96112. /**
  96113. * Attach the input controls to a specific dom element to get the input from.
  96114. * @param element Defines the element the controls should be listened from
  96115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96116. */
  96117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96118. /**
  96119. * Detach the current controls from the specified dom element.
  96120. * @param element Defines the element to stop listening the inputs from
  96121. */
  96122. detachControl(element: Nullable<HTMLElement>): void;
  96123. /**
  96124. * Update the current camera state depending on the inputs that have been used this frame.
  96125. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96126. */
  96127. checkInputs(): void;
  96128. /**
  96129. * Gets the class name of the current intput.
  96130. * @returns the class name
  96131. */
  96132. getClassName(): string;
  96133. /**
  96134. * Get the friendly name associated with the input class.
  96135. * @returns the input friendly name
  96136. */
  96137. getSimpleName(): string;
  96138. }
  96139. }
  96140. declare module BABYLON {
  96141. interface ArcRotateCameraInputsManager {
  96142. /**
  96143. * Add orientation input support to the input manager.
  96144. * @returns the current input manager
  96145. */
  96146. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  96147. }
  96148. /**
  96149. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  96150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96151. */
  96152. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  96153. /**
  96154. * Defines the camera the input is attached to.
  96155. */
  96156. camera: ArcRotateCamera;
  96157. /**
  96158. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  96159. */
  96160. alphaCorrection: number;
  96161. /**
  96162. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  96163. */
  96164. gammaCorrection: number;
  96165. private _alpha;
  96166. private _gamma;
  96167. private _dirty;
  96168. private _deviceOrientationHandler;
  96169. /**
  96170. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  96171. */
  96172. constructor();
  96173. /**
  96174. * Attach the input controls to a specific dom element to get the input from.
  96175. * @param element Defines the element the controls should be listened from
  96176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96177. */
  96178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96179. /** @hidden */
  96180. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  96181. /**
  96182. * Update the current camera state depending on the inputs that have been used this frame.
  96183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96184. */
  96185. checkInputs(): void;
  96186. /**
  96187. * Detach the current controls from the specified dom element.
  96188. * @param element Defines the element to stop listening the inputs from
  96189. */
  96190. detachControl(element: Nullable<HTMLElement>): void;
  96191. /**
  96192. * Gets the class name of the current intput.
  96193. * @returns the class name
  96194. */
  96195. getClassName(): string;
  96196. /**
  96197. * Get the friendly name associated with the input class.
  96198. * @returns the input friendly name
  96199. */
  96200. getSimpleName(): string;
  96201. }
  96202. }
  96203. declare module BABYLON {
  96204. /**
  96205. * Listen to mouse events to control the camera.
  96206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96207. */
  96208. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  96209. /**
  96210. * Defines the camera the input is attached to.
  96211. */
  96212. camera: FlyCamera;
  96213. /**
  96214. * Defines if touch is enabled. (Default is true.)
  96215. */
  96216. touchEnabled: boolean;
  96217. /**
  96218. * Defines the buttons associated with the input to handle camera rotation.
  96219. */
  96220. buttons: number[];
  96221. /**
  96222. * Assign buttons for Yaw control.
  96223. */
  96224. buttonsYaw: number[];
  96225. /**
  96226. * Assign buttons for Pitch control.
  96227. */
  96228. buttonsPitch: number[];
  96229. /**
  96230. * Assign buttons for Roll control.
  96231. */
  96232. buttonsRoll: number[];
  96233. /**
  96234. * Detect if any button is being pressed while mouse is moved.
  96235. * -1 = Mouse locked.
  96236. * 0 = Left button.
  96237. * 1 = Middle Button.
  96238. * 2 = Right Button.
  96239. */
  96240. activeButton: number;
  96241. /**
  96242. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  96243. * Higher values reduce its sensitivity.
  96244. */
  96245. angularSensibility: number;
  96246. private _mousemoveCallback;
  96247. private _observer;
  96248. private _rollObserver;
  96249. private previousPosition;
  96250. private noPreventDefault;
  96251. private element;
  96252. /**
  96253. * Listen to mouse events to control the camera.
  96254. * @param touchEnabled Define if touch is enabled. (Default is true.)
  96255. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96256. */
  96257. constructor(touchEnabled?: boolean);
  96258. /**
  96259. * Attach the mouse control to the HTML DOM element.
  96260. * @param element Defines the element that listens to the input events.
  96261. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  96262. */
  96263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96264. /**
  96265. * Detach the current controls from the specified dom element.
  96266. * @param element Defines the element to stop listening the inputs from
  96267. */
  96268. detachControl(element: Nullable<HTMLElement>): void;
  96269. /**
  96270. * Gets the class name of the current input.
  96271. * @returns the class name.
  96272. */
  96273. getClassName(): string;
  96274. /**
  96275. * Get the friendly name associated with the input class.
  96276. * @returns the input's friendly name.
  96277. */
  96278. getSimpleName(): string;
  96279. private _pointerInput;
  96280. private _onMouseMove;
  96281. /**
  96282. * Rotate camera by mouse offset.
  96283. */
  96284. private rotateCamera;
  96285. }
  96286. }
  96287. declare module BABYLON {
  96288. /**
  96289. * Default Inputs manager for the FlyCamera.
  96290. * It groups all the default supported inputs for ease of use.
  96291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96292. */
  96293. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  96294. /**
  96295. * Instantiates a new FlyCameraInputsManager.
  96296. * @param camera Defines the camera the inputs belong to.
  96297. */
  96298. constructor(camera: FlyCamera);
  96299. /**
  96300. * Add keyboard input support to the input manager.
  96301. * @returns the new FlyCameraKeyboardMoveInput().
  96302. */
  96303. addKeyboard(): FlyCameraInputsManager;
  96304. /**
  96305. * Add mouse input support to the input manager.
  96306. * @param touchEnabled Enable touch screen support.
  96307. * @returns the new FlyCameraMouseInput().
  96308. */
  96309. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  96310. }
  96311. }
  96312. declare module BABYLON {
  96313. /**
  96314. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96315. * such as in a 3D Space Shooter or a Flight Simulator.
  96316. */
  96317. export class FlyCamera extends TargetCamera {
  96318. /**
  96319. * Define the collision ellipsoid of the camera.
  96320. * This is helpful for simulating a camera body, like a player's body.
  96321. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96322. */
  96323. ellipsoid: Vector3;
  96324. /**
  96325. * Define an offset for the position of the ellipsoid around the camera.
  96326. * This can be helpful if the camera is attached away from the player's body center,
  96327. * such as at its head.
  96328. */
  96329. ellipsoidOffset: Vector3;
  96330. /**
  96331. * Enable or disable collisions of the camera with the rest of the scene objects.
  96332. */
  96333. checkCollisions: boolean;
  96334. /**
  96335. * Enable or disable gravity on the camera.
  96336. */
  96337. applyGravity: boolean;
  96338. /**
  96339. * Define the current direction the camera is moving to.
  96340. */
  96341. cameraDirection: Vector3;
  96342. /**
  96343. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  96344. * This overrides and empties cameraRotation.
  96345. */
  96346. rotationQuaternion: Quaternion;
  96347. /**
  96348. * Track Roll to maintain the wanted Rolling when looking around.
  96349. */
  96350. _trackRoll: number;
  96351. /**
  96352. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  96353. */
  96354. rollCorrect: number;
  96355. /**
  96356. * Mimic a banked turn, Rolling the camera when Yawing.
  96357. * It's recommended to use rollCorrect = 10 for faster banking correction.
  96358. */
  96359. bankedTurn: boolean;
  96360. /**
  96361. * Limit in radians for how much Roll banking will add. (Default: 90°)
  96362. */
  96363. bankedTurnLimit: number;
  96364. /**
  96365. * Value of 0 disables the banked Roll.
  96366. * Value of 1 is equal to the Yaw angle in radians.
  96367. */
  96368. bankedTurnMultiplier: number;
  96369. /**
  96370. * The inputs manager loads all the input sources, such as keyboard and mouse.
  96371. */
  96372. inputs: FlyCameraInputsManager;
  96373. /**
  96374. * Gets the input sensibility for mouse input.
  96375. * Higher values reduce sensitivity.
  96376. */
  96377. /**
  96378. * Sets the input sensibility for a mouse input.
  96379. * Higher values reduce sensitivity.
  96380. */
  96381. angularSensibility: number;
  96382. /**
  96383. * Get the keys for camera movement forward.
  96384. */
  96385. /**
  96386. * Set the keys for camera movement forward.
  96387. */
  96388. keysForward: number[];
  96389. /**
  96390. * Get the keys for camera movement backward.
  96391. */
  96392. keysBackward: number[];
  96393. /**
  96394. * Get the keys for camera movement up.
  96395. */
  96396. /**
  96397. * Set the keys for camera movement up.
  96398. */
  96399. keysUp: number[];
  96400. /**
  96401. * Get the keys for camera movement down.
  96402. */
  96403. /**
  96404. * Set the keys for camera movement down.
  96405. */
  96406. keysDown: number[];
  96407. /**
  96408. * Get the keys for camera movement left.
  96409. */
  96410. /**
  96411. * Set the keys for camera movement left.
  96412. */
  96413. keysLeft: number[];
  96414. /**
  96415. * Set the keys for camera movement right.
  96416. */
  96417. /**
  96418. * Set the keys for camera movement right.
  96419. */
  96420. keysRight: number[];
  96421. /**
  96422. * Event raised when the camera collides with a mesh in the scene.
  96423. */
  96424. onCollide: (collidedMesh: AbstractMesh) => void;
  96425. private _collider;
  96426. private _needMoveForGravity;
  96427. private _oldPosition;
  96428. private _diffPosition;
  96429. private _newPosition;
  96430. /** @hidden */
  96431. _localDirection: Vector3;
  96432. /** @hidden */
  96433. _transformedDirection: Vector3;
  96434. /**
  96435. * Instantiates a FlyCamera.
  96436. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96437. * such as in a 3D Space Shooter or a Flight Simulator.
  96438. * @param name Define the name of the camera in the scene.
  96439. * @param position Define the starting position of the camera in the scene.
  96440. * @param scene Define the scene the camera belongs to.
  96441. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  96442. */
  96443. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96444. /**
  96445. * Attach a control to the HTML DOM element.
  96446. * @param element Defines the element that listens to the input events.
  96447. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  96448. */
  96449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96450. /**
  96451. * Detach a control from the HTML DOM element.
  96452. * The camera will stop reacting to that input.
  96453. * @param element Defines the element that listens to the input events.
  96454. */
  96455. detachControl(element: HTMLElement): void;
  96456. private _collisionMask;
  96457. /**
  96458. * Get the mask that the camera ignores in collision events.
  96459. */
  96460. /**
  96461. * Set the mask that the camera ignores in collision events.
  96462. */
  96463. collisionMask: number;
  96464. /** @hidden */
  96465. _collideWithWorld(displacement: Vector3): void;
  96466. /** @hidden */
  96467. private _onCollisionPositionChange;
  96468. /** @hidden */
  96469. _checkInputs(): void;
  96470. /** @hidden */
  96471. _decideIfNeedsToMove(): boolean;
  96472. /** @hidden */
  96473. _updatePosition(): void;
  96474. /**
  96475. * Restore the Roll to its target value at the rate specified.
  96476. * @param rate - Higher means slower restoring.
  96477. * @hidden
  96478. */
  96479. restoreRoll(rate: number): void;
  96480. /**
  96481. * Destroy the camera and release the current resources held by it.
  96482. */
  96483. dispose(): void;
  96484. /**
  96485. * Get the current object class name.
  96486. * @returns the class name.
  96487. */
  96488. getClassName(): string;
  96489. }
  96490. }
  96491. declare module BABYLON {
  96492. /**
  96493. * Listen to keyboard events to control the camera.
  96494. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96495. */
  96496. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  96497. /**
  96498. * Defines the camera the input is attached to.
  96499. */
  96500. camera: FlyCamera;
  96501. /**
  96502. * The list of keyboard keys used to control the forward move of the camera.
  96503. */
  96504. keysForward: number[];
  96505. /**
  96506. * The list of keyboard keys used to control the backward move of the camera.
  96507. */
  96508. keysBackward: number[];
  96509. /**
  96510. * The list of keyboard keys used to control the forward move of the camera.
  96511. */
  96512. keysUp: number[];
  96513. /**
  96514. * The list of keyboard keys used to control the backward move of the camera.
  96515. */
  96516. keysDown: number[];
  96517. /**
  96518. * The list of keyboard keys used to control the right strafe move of the camera.
  96519. */
  96520. keysRight: number[];
  96521. /**
  96522. * The list of keyboard keys used to control the left strafe move of the camera.
  96523. */
  96524. keysLeft: number[];
  96525. private _keys;
  96526. private _onCanvasBlurObserver;
  96527. private _onKeyboardObserver;
  96528. private _engine;
  96529. private _scene;
  96530. /**
  96531. * Attach the input controls to a specific dom element to get the input from.
  96532. * @param element Defines the element the controls should be listened from
  96533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96534. */
  96535. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96536. /**
  96537. * Detach the current controls from the specified dom element.
  96538. * @param element Defines the element to stop listening the inputs from
  96539. */
  96540. detachControl(element: Nullable<HTMLElement>): void;
  96541. /**
  96542. * Gets the class name of the current intput.
  96543. * @returns the class name
  96544. */
  96545. getClassName(): string;
  96546. /** @hidden */
  96547. _onLostFocus(e: FocusEvent): void;
  96548. /**
  96549. * Get the friendly name associated with the input class.
  96550. * @returns the input friendly name
  96551. */
  96552. getSimpleName(): string;
  96553. /**
  96554. * Update the current camera state depending on the inputs that have been used this frame.
  96555. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96556. */
  96557. checkInputs(): void;
  96558. }
  96559. }
  96560. declare module BABYLON {
  96561. /**
  96562. * Manage the mouse wheel inputs to control a follow camera.
  96563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96564. */
  96565. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96566. /**
  96567. * Defines the camera the input is attached to.
  96568. */
  96569. camera: FollowCamera;
  96570. /**
  96571. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96572. */
  96573. axisControlRadius: boolean;
  96574. /**
  96575. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96576. */
  96577. axisControlHeight: boolean;
  96578. /**
  96579. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96580. */
  96581. axisControlRotation: boolean;
  96582. /**
  96583. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96584. * relation to mouseWheel events.
  96585. */
  96586. wheelPrecision: number;
  96587. /**
  96588. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96589. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96590. */
  96591. wheelDeltaPercentage: number;
  96592. private _wheel;
  96593. private _observer;
  96594. /**
  96595. * Attach the input controls to a specific dom element to get the input from.
  96596. * @param element Defines the element the controls should be listened from
  96597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96598. */
  96599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96600. /**
  96601. * Detach the current controls from the specified dom element.
  96602. * @param element Defines the element to stop listening the inputs from
  96603. */
  96604. detachControl(element: Nullable<HTMLElement>): void;
  96605. /**
  96606. * Gets the class name of the current intput.
  96607. * @returns the class name
  96608. */
  96609. getClassName(): string;
  96610. /**
  96611. * Get the friendly name associated with the input class.
  96612. * @returns the input friendly name
  96613. */
  96614. getSimpleName(): string;
  96615. }
  96616. }
  96617. declare module BABYLON {
  96618. /**
  96619. * Manage the pointers inputs to control an follow camera.
  96620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96621. */
  96622. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96623. /**
  96624. * Defines the camera the input is attached to.
  96625. */
  96626. camera: FollowCamera;
  96627. /**
  96628. * Gets the class name of the current input.
  96629. * @returns the class name
  96630. */
  96631. getClassName(): string;
  96632. /**
  96633. * Defines the pointer angular sensibility along the X axis or how fast is
  96634. * the camera rotating.
  96635. * A negative number will reverse the axis direction.
  96636. */
  96637. angularSensibilityX: number;
  96638. /**
  96639. * Defines the pointer angular sensibility along the Y axis or how fast is
  96640. * the camera rotating.
  96641. * A negative number will reverse the axis direction.
  96642. */
  96643. angularSensibilityY: number;
  96644. /**
  96645. * Defines the pointer pinch precision or how fast is the camera zooming.
  96646. * A negative number will reverse the axis direction.
  96647. */
  96648. pinchPrecision: number;
  96649. /**
  96650. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96651. * from 0.
  96652. * It defines the percentage of current camera.radius to use as delta when
  96653. * pinch zoom is used.
  96654. */
  96655. pinchDeltaPercentage: number;
  96656. /**
  96657. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96658. */
  96659. axisXControlRadius: boolean;
  96660. /**
  96661. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96662. */
  96663. axisXControlHeight: boolean;
  96664. /**
  96665. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96666. */
  96667. axisXControlRotation: boolean;
  96668. /**
  96669. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96670. */
  96671. axisYControlRadius: boolean;
  96672. /**
  96673. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96674. */
  96675. axisYControlHeight: boolean;
  96676. /**
  96677. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96678. */
  96679. axisYControlRotation: boolean;
  96680. /**
  96681. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96682. */
  96683. axisPinchControlRadius: boolean;
  96684. /**
  96685. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96686. */
  96687. axisPinchControlHeight: boolean;
  96688. /**
  96689. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96690. */
  96691. axisPinchControlRotation: boolean;
  96692. /**
  96693. * Log error messages if basic misconfiguration has occurred.
  96694. */
  96695. warningEnable: boolean;
  96696. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96697. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96698. private _warningCounter;
  96699. private _warning;
  96700. }
  96701. }
  96702. declare module BABYLON {
  96703. /**
  96704. * Default Inputs manager for the FollowCamera.
  96705. * It groups all the default supported inputs for ease of use.
  96706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96707. */
  96708. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96709. /**
  96710. * Instantiates a new FollowCameraInputsManager.
  96711. * @param camera Defines the camera the inputs belong to
  96712. */
  96713. constructor(camera: FollowCamera);
  96714. /**
  96715. * Add keyboard input support to the input manager.
  96716. * @returns the current input manager
  96717. */
  96718. addKeyboard(): FollowCameraInputsManager;
  96719. /**
  96720. * Add mouse wheel input support to the input manager.
  96721. * @returns the current input manager
  96722. */
  96723. addMouseWheel(): FollowCameraInputsManager;
  96724. /**
  96725. * Add pointers input support to the input manager.
  96726. * @returns the current input manager
  96727. */
  96728. addPointers(): FollowCameraInputsManager;
  96729. /**
  96730. * Add orientation input support to the input manager.
  96731. * @returns the current input manager
  96732. */
  96733. addVRDeviceOrientation(): FollowCameraInputsManager;
  96734. }
  96735. }
  96736. declare module BABYLON {
  96737. /**
  96738. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96739. * an arc rotate version arcFollowCamera are available.
  96740. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96741. */
  96742. export class FollowCamera extends TargetCamera {
  96743. /**
  96744. * Distance the follow camera should follow an object at
  96745. */
  96746. radius: number;
  96747. /**
  96748. * Minimum allowed distance of the camera to the axis of rotation
  96749. * (The camera can not get closer).
  96750. * This can help limiting how the Camera is able to move in the scene.
  96751. */
  96752. lowerRadiusLimit: Nullable<number>;
  96753. /**
  96754. * Maximum allowed distance of the camera to the axis of rotation
  96755. * (The camera can not get further).
  96756. * This can help limiting how the Camera is able to move in the scene.
  96757. */
  96758. upperRadiusLimit: Nullable<number>;
  96759. /**
  96760. * Define a rotation offset between the camera and the object it follows
  96761. */
  96762. rotationOffset: number;
  96763. /**
  96764. * Minimum allowed angle to camera position relative to target object.
  96765. * This can help limiting how the Camera is able to move in the scene.
  96766. */
  96767. lowerRotationOffsetLimit: Nullable<number>;
  96768. /**
  96769. * Maximum allowed angle to camera position relative to target object.
  96770. * This can help limiting how the Camera is able to move in the scene.
  96771. */
  96772. upperRotationOffsetLimit: Nullable<number>;
  96773. /**
  96774. * Define a height offset between the camera and the object it follows.
  96775. * It can help following an object from the top (like a car chaing a plane)
  96776. */
  96777. heightOffset: number;
  96778. /**
  96779. * Minimum allowed height of camera position relative to target object.
  96780. * This can help limiting how the Camera is able to move in the scene.
  96781. */
  96782. lowerHeightOffsetLimit: Nullable<number>;
  96783. /**
  96784. * Maximum allowed height of camera position relative to target object.
  96785. * This can help limiting how the Camera is able to move in the scene.
  96786. */
  96787. upperHeightOffsetLimit: Nullable<number>;
  96788. /**
  96789. * Define how fast the camera can accelerate to follow it s target.
  96790. */
  96791. cameraAcceleration: number;
  96792. /**
  96793. * Define the speed limit of the camera following an object.
  96794. */
  96795. maxCameraSpeed: number;
  96796. /**
  96797. * Define the target of the camera.
  96798. */
  96799. lockedTarget: Nullable<AbstractMesh>;
  96800. /**
  96801. * Defines the input associated with the camera.
  96802. */
  96803. inputs: FollowCameraInputsManager;
  96804. /**
  96805. * Instantiates the follow camera.
  96806. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96807. * @param name Define the name of the camera in the scene
  96808. * @param position Define the position of the camera
  96809. * @param scene Define the scene the camera belong to
  96810. * @param lockedTarget Define the target of the camera
  96811. */
  96812. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96813. private _follow;
  96814. /**
  96815. * Attached controls to the current camera.
  96816. * @param element Defines the element the controls should be listened from
  96817. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96818. */
  96819. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96820. /**
  96821. * Detach the current controls from the camera.
  96822. * The camera will stop reacting to inputs.
  96823. * @param element Defines the element to stop listening the inputs from
  96824. */
  96825. detachControl(element: HTMLElement): void;
  96826. /** @hidden */
  96827. _checkInputs(): void;
  96828. private _checkLimits;
  96829. /**
  96830. * Gets the camera class name.
  96831. * @returns the class name
  96832. */
  96833. getClassName(): string;
  96834. }
  96835. /**
  96836. * Arc Rotate version of the follow camera.
  96837. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96838. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96839. */
  96840. export class ArcFollowCamera extends TargetCamera {
  96841. /** The longitudinal angle of the camera */
  96842. alpha: number;
  96843. /** The latitudinal angle of the camera */
  96844. beta: number;
  96845. /** The radius of the camera from its target */
  96846. radius: number;
  96847. /** Define the camera target (the messh it should follow) */
  96848. target: Nullable<AbstractMesh>;
  96849. private _cartesianCoordinates;
  96850. /**
  96851. * Instantiates a new ArcFollowCamera
  96852. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96853. * @param name Define the name of the camera
  96854. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96855. * @param beta Define the rotation angle of the camera around the elevation axis
  96856. * @param radius Define the radius of the camera from its target point
  96857. * @param target Define the target of the camera
  96858. * @param scene Define the scene the camera belongs to
  96859. */
  96860. constructor(name: string,
  96861. /** The longitudinal angle of the camera */
  96862. alpha: number,
  96863. /** The latitudinal angle of the camera */
  96864. beta: number,
  96865. /** The radius of the camera from its target */
  96866. radius: number,
  96867. /** Define the camera target (the messh it should follow) */
  96868. target: Nullable<AbstractMesh>, scene: Scene);
  96869. private _follow;
  96870. /** @hidden */
  96871. _checkInputs(): void;
  96872. /**
  96873. * Returns the class name of the object.
  96874. * It is mostly used internally for serialization purposes.
  96875. */
  96876. getClassName(): string;
  96877. }
  96878. }
  96879. declare module BABYLON {
  96880. /**
  96881. * Manage the keyboard inputs to control the movement of a follow camera.
  96882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96883. */
  96884. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96885. /**
  96886. * Defines the camera the input is attached to.
  96887. */
  96888. camera: FollowCamera;
  96889. /**
  96890. * Defines the list of key codes associated with the up action (increase heightOffset)
  96891. */
  96892. keysHeightOffsetIncr: number[];
  96893. /**
  96894. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96895. */
  96896. keysHeightOffsetDecr: number[];
  96897. /**
  96898. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96899. */
  96900. keysHeightOffsetModifierAlt: boolean;
  96901. /**
  96902. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96903. */
  96904. keysHeightOffsetModifierCtrl: boolean;
  96905. /**
  96906. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96907. */
  96908. keysHeightOffsetModifierShift: boolean;
  96909. /**
  96910. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96911. */
  96912. keysRotationOffsetIncr: number[];
  96913. /**
  96914. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96915. */
  96916. keysRotationOffsetDecr: number[];
  96917. /**
  96918. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96919. */
  96920. keysRotationOffsetModifierAlt: boolean;
  96921. /**
  96922. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96923. */
  96924. keysRotationOffsetModifierCtrl: boolean;
  96925. /**
  96926. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96927. */
  96928. keysRotationOffsetModifierShift: boolean;
  96929. /**
  96930. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96931. */
  96932. keysRadiusIncr: number[];
  96933. /**
  96934. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96935. */
  96936. keysRadiusDecr: number[];
  96937. /**
  96938. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96939. */
  96940. keysRadiusModifierAlt: boolean;
  96941. /**
  96942. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96943. */
  96944. keysRadiusModifierCtrl: boolean;
  96945. /**
  96946. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96947. */
  96948. keysRadiusModifierShift: boolean;
  96949. /**
  96950. * Defines the rate of change of heightOffset.
  96951. */
  96952. heightSensibility: number;
  96953. /**
  96954. * Defines the rate of change of rotationOffset.
  96955. */
  96956. rotationSensibility: number;
  96957. /**
  96958. * Defines the rate of change of radius.
  96959. */
  96960. radiusSensibility: number;
  96961. private _keys;
  96962. private _ctrlPressed;
  96963. private _altPressed;
  96964. private _shiftPressed;
  96965. private _onCanvasBlurObserver;
  96966. private _onKeyboardObserver;
  96967. private _engine;
  96968. private _scene;
  96969. /**
  96970. * Attach the input controls to a specific dom element to get the input from.
  96971. * @param element Defines the element the controls should be listened from
  96972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96973. */
  96974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96975. /**
  96976. * Detach the current controls from the specified dom element.
  96977. * @param element Defines the element to stop listening the inputs from
  96978. */
  96979. detachControl(element: Nullable<HTMLElement>): void;
  96980. /**
  96981. * Update the current camera state depending on the inputs that have been used this frame.
  96982. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96983. */
  96984. checkInputs(): void;
  96985. /**
  96986. * Gets the class name of the current input.
  96987. * @returns the class name
  96988. */
  96989. getClassName(): string;
  96990. /**
  96991. * Get the friendly name associated with the input class.
  96992. * @returns the input friendly name
  96993. */
  96994. getSimpleName(): string;
  96995. /**
  96996. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96997. * allow modification of the heightOffset value.
  96998. */
  96999. private _modifierHeightOffset;
  97000. /**
  97001. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97002. * allow modification of the rotationOffset value.
  97003. */
  97004. private _modifierRotationOffset;
  97005. /**
  97006. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97007. * allow modification of the radius value.
  97008. */
  97009. private _modifierRadius;
  97010. }
  97011. }
  97012. declare module BABYLON {
  97013. interface FreeCameraInputsManager {
  97014. /**
  97015. * @hidden
  97016. */
  97017. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  97018. /**
  97019. * Add orientation input support to the input manager.
  97020. * @returns the current input manager
  97021. */
  97022. addDeviceOrientation(): FreeCameraInputsManager;
  97023. }
  97024. /**
  97025. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  97026. * Screen rotation is taken into account.
  97027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97028. */
  97029. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  97030. private _camera;
  97031. private _screenOrientationAngle;
  97032. private _constantTranform;
  97033. private _screenQuaternion;
  97034. private _alpha;
  97035. private _beta;
  97036. private _gamma;
  97037. /**
  97038. * @hidden
  97039. */
  97040. _onDeviceOrientationChangedObservable: Observable<void>;
  97041. /**
  97042. * Instantiates a new input
  97043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97044. */
  97045. constructor();
  97046. /**
  97047. * Define the camera controlled by the input.
  97048. */
  97049. camera: FreeCamera;
  97050. /**
  97051. * Attach the input controls to a specific dom element to get the input from.
  97052. * @param element Defines the element the controls should be listened from
  97053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97054. */
  97055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97056. private _orientationChanged;
  97057. private _deviceOrientation;
  97058. /**
  97059. * Detach the current controls from the specified dom element.
  97060. * @param element Defines the element to stop listening the inputs from
  97061. */
  97062. detachControl(element: Nullable<HTMLElement>): void;
  97063. /**
  97064. * Update the current camera state depending on the inputs that have been used this frame.
  97065. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97066. */
  97067. checkInputs(): void;
  97068. /**
  97069. * Gets the class name of the current intput.
  97070. * @returns the class name
  97071. */
  97072. getClassName(): string;
  97073. /**
  97074. * Get the friendly name associated with the input class.
  97075. * @returns the input friendly name
  97076. */
  97077. getSimpleName(): string;
  97078. }
  97079. }
  97080. declare module BABYLON {
  97081. /**
  97082. * Manage the gamepad inputs to control a free camera.
  97083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97084. */
  97085. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  97086. /**
  97087. * Define the camera the input is attached to.
  97088. */
  97089. camera: FreeCamera;
  97090. /**
  97091. * Define the Gamepad controlling the input
  97092. */
  97093. gamepad: Nullable<Gamepad>;
  97094. /**
  97095. * Defines the gamepad rotation sensiblity.
  97096. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97097. */
  97098. gamepadAngularSensibility: number;
  97099. /**
  97100. * Defines the gamepad move sensiblity.
  97101. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97102. */
  97103. gamepadMoveSensibility: number;
  97104. private _onGamepadConnectedObserver;
  97105. private _onGamepadDisconnectedObserver;
  97106. private _cameraTransform;
  97107. private _deltaTransform;
  97108. private _vector3;
  97109. private _vector2;
  97110. /**
  97111. * Attach the input controls to a specific dom element to get the input from.
  97112. * @param element Defines the element the controls should be listened from
  97113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97114. */
  97115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97116. /**
  97117. * Detach the current controls from the specified dom element.
  97118. * @param element Defines the element to stop listening the inputs from
  97119. */
  97120. detachControl(element: Nullable<HTMLElement>): void;
  97121. /**
  97122. * Update the current camera state depending on the inputs that have been used this frame.
  97123. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97124. */
  97125. checkInputs(): void;
  97126. /**
  97127. * Gets the class name of the current intput.
  97128. * @returns the class name
  97129. */
  97130. getClassName(): string;
  97131. /**
  97132. * Get the friendly name associated with the input class.
  97133. * @returns the input friendly name
  97134. */
  97135. getSimpleName(): string;
  97136. }
  97137. }
  97138. declare module BABYLON {
  97139. /**
  97140. * Defines the potential axis of a Joystick
  97141. */
  97142. export enum JoystickAxis {
  97143. /** X axis */
  97144. X = 0,
  97145. /** Y axis */
  97146. Y = 1,
  97147. /** Z axis */
  97148. Z = 2
  97149. }
  97150. /**
  97151. * Class used to define virtual joystick (used in touch mode)
  97152. */
  97153. export class VirtualJoystick {
  97154. /**
  97155. * Gets or sets a boolean indicating that left and right values must be inverted
  97156. */
  97157. reverseLeftRight: boolean;
  97158. /**
  97159. * Gets or sets a boolean indicating that up and down values must be inverted
  97160. */
  97161. reverseUpDown: boolean;
  97162. /**
  97163. * Gets the offset value for the position (ie. the change of the position value)
  97164. */
  97165. deltaPosition: Vector3;
  97166. /**
  97167. * Gets a boolean indicating if the virtual joystick was pressed
  97168. */
  97169. pressed: boolean;
  97170. /**
  97171. * Canvas the virtual joystick will render onto, default z-index of this is 5
  97172. */
  97173. static Canvas: Nullable<HTMLCanvasElement>;
  97174. private static _globalJoystickIndex;
  97175. private static vjCanvasContext;
  97176. private static vjCanvasWidth;
  97177. private static vjCanvasHeight;
  97178. private static halfWidth;
  97179. private _action;
  97180. private _axisTargetedByLeftAndRight;
  97181. private _axisTargetedByUpAndDown;
  97182. private _joystickSensibility;
  97183. private _inversedSensibility;
  97184. private _joystickPointerID;
  97185. private _joystickColor;
  97186. private _joystickPointerPos;
  97187. private _joystickPreviousPointerPos;
  97188. private _joystickPointerStartPos;
  97189. private _deltaJoystickVector;
  97190. private _leftJoystick;
  97191. private _touches;
  97192. private _onPointerDownHandlerRef;
  97193. private _onPointerMoveHandlerRef;
  97194. private _onPointerUpHandlerRef;
  97195. private _onResize;
  97196. /**
  97197. * Creates a new virtual joystick
  97198. * @param leftJoystick defines that the joystick is for left hand (false by default)
  97199. */
  97200. constructor(leftJoystick?: boolean);
  97201. /**
  97202. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  97203. * @param newJoystickSensibility defines the new sensibility
  97204. */
  97205. setJoystickSensibility(newJoystickSensibility: number): void;
  97206. private _onPointerDown;
  97207. private _onPointerMove;
  97208. private _onPointerUp;
  97209. /**
  97210. * Change the color of the virtual joystick
  97211. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  97212. */
  97213. setJoystickColor(newColor: string): void;
  97214. /**
  97215. * Defines a callback to call when the joystick is touched
  97216. * @param action defines the callback
  97217. */
  97218. setActionOnTouch(action: () => any): void;
  97219. /**
  97220. * Defines which axis you'd like to control for left & right
  97221. * @param axis defines the axis to use
  97222. */
  97223. setAxisForLeftRight(axis: JoystickAxis): void;
  97224. /**
  97225. * Defines which axis you'd like to control for up & down
  97226. * @param axis defines the axis to use
  97227. */
  97228. setAxisForUpDown(axis: JoystickAxis): void;
  97229. private _drawVirtualJoystick;
  97230. /**
  97231. * Release internal HTML canvas
  97232. */
  97233. releaseCanvas(): void;
  97234. }
  97235. }
  97236. declare module BABYLON {
  97237. interface FreeCameraInputsManager {
  97238. /**
  97239. * Add virtual joystick input support to the input manager.
  97240. * @returns the current input manager
  97241. */
  97242. addVirtualJoystick(): FreeCameraInputsManager;
  97243. }
  97244. /**
  97245. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  97246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97247. */
  97248. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  97249. /**
  97250. * Defines the camera the input is attached to.
  97251. */
  97252. camera: FreeCamera;
  97253. private _leftjoystick;
  97254. private _rightjoystick;
  97255. /**
  97256. * Gets the left stick of the virtual joystick.
  97257. * @returns The virtual Joystick
  97258. */
  97259. getLeftJoystick(): VirtualJoystick;
  97260. /**
  97261. * Gets the right stick of the virtual joystick.
  97262. * @returns The virtual Joystick
  97263. */
  97264. getRightJoystick(): VirtualJoystick;
  97265. /**
  97266. * Update the current camera state depending on the inputs that have been used this frame.
  97267. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97268. */
  97269. checkInputs(): void;
  97270. /**
  97271. * Attach the input controls to a specific dom element to get the input from.
  97272. * @param element Defines the element the controls should be listened from
  97273. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97274. */
  97275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97276. /**
  97277. * Detach the current controls from the specified dom element.
  97278. * @param element Defines the element to stop listening the inputs from
  97279. */
  97280. detachControl(element: Nullable<HTMLElement>): void;
  97281. /**
  97282. * Gets the class name of the current intput.
  97283. * @returns the class name
  97284. */
  97285. getClassName(): string;
  97286. /**
  97287. * Get the friendly name associated with the input class.
  97288. * @returns the input friendly name
  97289. */
  97290. getSimpleName(): string;
  97291. }
  97292. }
  97293. declare module BABYLON {
  97294. /**
  97295. * This represents a FPS type of camera controlled by touch.
  97296. * This is like a universal camera minus the Gamepad controls.
  97297. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97298. */
  97299. export class TouchCamera extends FreeCamera {
  97300. /**
  97301. * Defines the touch sensibility for rotation.
  97302. * The higher the faster.
  97303. */
  97304. touchAngularSensibility: number;
  97305. /**
  97306. * Defines the touch sensibility for move.
  97307. * The higher the faster.
  97308. */
  97309. touchMoveSensibility: number;
  97310. /**
  97311. * Instantiates a new touch camera.
  97312. * This represents a FPS type of camera controlled by touch.
  97313. * This is like a universal camera minus the Gamepad controls.
  97314. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97315. * @param name Define the name of the camera in the scene
  97316. * @param position Define the start position of the camera in the scene
  97317. * @param scene Define the scene the camera belongs to
  97318. */
  97319. constructor(name: string, position: Vector3, scene: Scene);
  97320. /**
  97321. * Gets the current object class name.
  97322. * @return the class name
  97323. */
  97324. getClassName(): string;
  97325. /** @hidden */
  97326. _setupInputs(): void;
  97327. }
  97328. }
  97329. declare module BABYLON {
  97330. /**
  97331. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  97332. * being tilted forward or back and left or right.
  97333. */
  97334. export class DeviceOrientationCamera extends FreeCamera {
  97335. private _initialQuaternion;
  97336. private _quaternionCache;
  97337. private _tmpDragQuaternion;
  97338. /**
  97339. * Creates a new device orientation camera
  97340. * @param name The name of the camera
  97341. * @param position The start position camera
  97342. * @param scene The scene the camera belongs to
  97343. */
  97344. constructor(name: string, position: Vector3, scene: Scene);
  97345. /**
  97346. * @hidden
  97347. * Disabled pointer input on first orientation sensor update (Default: true)
  97348. */
  97349. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  97350. private _dragFactor;
  97351. /**
  97352. * Enabled turning on the y axis when the orientation sensor is active
  97353. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  97354. */
  97355. enableHorizontalDragging(dragFactor?: number): void;
  97356. /**
  97357. * Gets the current instance class name ("DeviceOrientationCamera").
  97358. * This helps avoiding instanceof at run time.
  97359. * @returns the class name
  97360. */
  97361. getClassName(): string;
  97362. /**
  97363. * @hidden
  97364. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  97365. */
  97366. _checkInputs(): void;
  97367. /**
  97368. * Reset the camera to its default orientation on the specified axis only.
  97369. * @param axis The axis to reset
  97370. */
  97371. resetToCurrentRotation(axis?: Axis): void;
  97372. }
  97373. }
  97374. declare module BABYLON {
  97375. /**
  97376. * 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,
  97377. * which still works and will still be found in many Playgrounds.
  97378. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97379. */
  97380. export class UniversalCamera extends TouchCamera {
  97381. /**
  97382. * Defines the gamepad rotation sensiblity.
  97383. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97384. */
  97385. gamepadAngularSensibility: number;
  97386. /**
  97387. * Defines the gamepad move sensiblity.
  97388. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97389. */
  97390. gamepadMoveSensibility: number;
  97391. /**
  97392. * 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,
  97393. * which still works and will still be found in many Playgrounds.
  97394. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97395. * @param name Define the name of the camera in the scene
  97396. * @param position Define the start position of the camera in the scene
  97397. * @param scene Define the scene the camera belongs to
  97398. */
  97399. constructor(name: string, position: Vector3, scene: Scene);
  97400. /**
  97401. * Gets the current object class name.
  97402. * @return the class name
  97403. */
  97404. getClassName(): string;
  97405. }
  97406. }
  97407. declare module BABYLON {
  97408. /**
  97409. * This represents a FPS type of camera. This is only here for back compat purpose.
  97410. * Please use the UniversalCamera instead as both are identical.
  97411. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97412. */
  97413. export class GamepadCamera extends UniversalCamera {
  97414. /**
  97415. * Instantiates a new Gamepad Camera
  97416. * This represents a FPS type of camera. This is only here for back compat purpose.
  97417. * Please use the UniversalCamera instead as both are identical.
  97418. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97419. * @param name Define the name of the camera in the scene
  97420. * @param position Define the start position of the camera in the scene
  97421. * @param scene Define the scene the camera belongs to
  97422. */
  97423. constructor(name: string, position: Vector3, scene: Scene);
  97424. /**
  97425. * Gets the current object class name.
  97426. * @return the class name
  97427. */
  97428. getClassName(): string;
  97429. }
  97430. }
  97431. declare module BABYLON {
  97432. /** @hidden */
  97433. export var passPixelShader: {
  97434. name: string;
  97435. shader: string;
  97436. };
  97437. }
  97438. declare module BABYLON {
  97439. /** @hidden */
  97440. export var passCubePixelShader: {
  97441. name: string;
  97442. shader: string;
  97443. };
  97444. }
  97445. declare module BABYLON {
  97446. /**
  97447. * PassPostProcess which produces an output the same as it's input
  97448. */
  97449. export class PassPostProcess extends PostProcess {
  97450. /**
  97451. * Creates the PassPostProcess
  97452. * @param name The name of the effect.
  97453. * @param options The required width/height ratio to downsize to before computing the render pass.
  97454. * @param camera The camera to apply the render pass to.
  97455. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97456. * @param engine The engine which the post process will be applied. (default: current engine)
  97457. * @param reusable If the post process can be reused on the same frame. (default: false)
  97458. * @param textureType The type of texture to be used when performing the post processing.
  97459. * @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)
  97460. */
  97461. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97462. }
  97463. /**
  97464. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  97465. */
  97466. export class PassCubePostProcess extends PostProcess {
  97467. private _face;
  97468. /**
  97469. * Gets or sets the cube face to display.
  97470. * * 0 is +X
  97471. * * 1 is -X
  97472. * * 2 is +Y
  97473. * * 3 is -Y
  97474. * * 4 is +Z
  97475. * * 5 is -Z
  97476. */
  97477. face: number;
  97478. /**
  97479. * Creates the PassCubePostProcess
  97480. * @param name The name of the effect.
  97481. * @param options The required width/height ratio to downsize to before computing the render pass.
  97482. * @param camera The camera to apply the render pass to.
  97483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97484. * @param engine The engine which the post process will be applied. (default: current engine)
  97485. * @param reusable If the post process can be reused on the same frame. (default: false)
  97486. * @param textureType The type of texture to be used when performing the post processing.
  97487. * @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)
  97488. */
  97489. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97490. }
  97491. }
  97492. declare module BABYLON {
  97493. /** @hidden */
  97494. export var anaglyphPixelShader: {
  97495. name: string;
  97496. shader: string;
  97497. };
  97498. }
  97499. declare module BABYLON {
  97500. /**
  97501. * Postprocess used to generate anaglyphic rendering
  97502. */
  97503. export class AnaglyphPostProcess extends PostProcess {
  97504. private _passedProcess;
  97505. /**
  97506. * Creates a new AnaglyphPostProcess
  97507. * @param name defines postprocess name
  97508. * @param options defines creation options or target ratio scale
  97509. * @param rigCameras defines cameras using this postprocess
  97510. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  97511. * @param engine defines hosting engine
  97512. * @param reusable defines if the postprocess will be reused multiple times per frame
  97513. */
  97514. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  97515. }
  97516. }
  97517. declare module BABYLON {
  97518. /**
  97519. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  97520. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97521. */
  97522. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  97523. /**
  97524. * Creates a new AnaglyphArcRotateCamera
  97525. * @param name defines camera name
  97526. * @param alpha defines alpha angle (in radians)
  97527. * @param beta defines beta angle (in radians)
  97528. * @param radius defines radius
  97529. * @param target defines camera target
  97530. * @param interaxialDistance defines distance between each color axis
  97531. * @param scene defines the hosting scene
  97532. */
  97533. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  97534. /**
  97535. * Gets camera class name
  97536. * @returns AnaglyphArcRotateCamera
  97537. */
  97538. getClassName(): string;
  97539. }
  97540. }
  97541. declare module BABYLON {
  97542. /**
  97543. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  97544. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97545. */
  97546. export class AnaglyphFreeCamera extends FreeCamera {
  97547. /**
  97548. * Creates a new AnaglyphFreeCamera
  97549. * @param name defines camera name
  97550. * @param position defines initial position
  97551. * @param interaxialDistance defines distance between each color axis
  97552. * @param scene defines the hosting scene
  97553. */
  97554. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97555. /**
  97556. * Gets camera class name
  97557. * @returns AnaglyphFreeCamera
  97558. */
  97559. getClassName(): string;
  97560. }
  97561. }
  97562. declare module BABYLON {
  97563. /**
  97564. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  97565. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97566. */
  97567. export class AnaglyphGamepadCamera extends GamepadCamera {
  97568. /**
  97569. * Creates a new AnaglyphGamepadCamera
  97570. * @param name defines camera name
  97571. * @param position defines initial position
  97572. * @param interaxialDistance defines distance between each color axis
  97573. * @param scene defines the hosting scene
  97574. */
  97575. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97576. /**
  97577. * Gets camera class name
  97578. * @returns AnaglyphGamepadCamera
  97579. */
  97580. getClassName(): string;
  97581. }
  97582. }
  97583. declare module BABYLON {
  97584. /**
  97585. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  97586. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97587. */
  97588. export class AnaglyphUniversalCamera extends UniversalCamera {
  97589. /**
  97590. * Creates a new AnaglyphUniversalCamera
  97591. * @param name defines camera name
  97592. * @param position defines initial position
  97593. * @param interaxialDistance defines distance between each color axis
  97594. * @param scene defines the hosting scene
  97595. */
  97596. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97597. /**
  97598. * Gets camera class name
  97599. * @returns AnaglyphUniversalCamera
  97600. */
  97601. getClassName(): string;
  97602. }
  97603. }
  97604. declare module BABYLON {
  97605. /** @hidden */
  97606. export var stereoscopicInterlacePixelShader: {
  97607. name: string;
  97608. shader: string;
  97609. };
  97610. }
  97611. declare module BABYLON {
  97612. /**
  97613. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  97614. */
  97615. export class StereoscopicInterlacePostProcess extends PostProcess {
  97616. private _stepSize;
  97617. private _passedProcess;
  97618. /**
  97619. * Initializes a StereoscopicInterlacePostProcess
  97620. * @param name The name of the effect.
  97621. * @param rigCameras The rig cameras to be appled to the post process
  97622. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  97623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97624. * @param engine The engine which the post process will be applied. (default: current engine)
  97625. * @param reusable If the post process can be reused on the same frame. (default: false)
  97626. */
  97627. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  97628. }
  97629. }
  97630. declare module BABYLON {
  97631. /**
  97632. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  97633. * @see http://doc.babylonjs.com/features/cameras
  97634. */
  97635. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  97636. /**
  97637. * Creates a new StereoscopicArcRotateCamera
  97638. * @param name defines camera name
  97639. * @param alpha defines alpha angle (in radians)
  97640. * @param beta defines beta angle (in radians)
  97641. * @param radius defines radius
  97642. * @param target defines camera target
  97643. * @param interaxialDistance defines distance between each color axis
  97644. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97645. * @param scene defines the hosting scene
  97646. */
  97647. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97648. /**
  97649. * Gets camera class name
  97650. * @returns StereoscopicArcRotateCamera
  97651. */
  97652. getClassName(): string;
  97653. }
  97654. }
  97655. declare module BABYLON {
  97656. /**
  97657. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  97658. * @see http://doc.babylonjs.com/features/cameras
  97659. */
  97660. export class StereoscopicFreeCamera extends FreeCamera {
  97661. /**
  97662. * Creates a new StereoscopicFreeCamera
  97663. * @param name defines camera name
  97664. * @param position defines initial position
  97665. * @param interaxialDistance defines distance between each color axis
  97666. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97667. * @param scene defines the hosting scene
  97668. */
  97669. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97670. /**
  97671. * Gets camera class name
  97672. * @returns StereoscopicFreeCamera
  97673. */
  97674. getClassName(): string;
  97675. }
  97676. }
  97677. declare module BABYLON {
  97678. /**
  97679. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  97680. * @see http://doc.babylonjs.com/features/cameras
  97681. */
  97682. export class StereoscopicGamepadCamera extends GamepadCamera {
  97683. /**
  97684. * Creates a new StereoscopicGamepadCamera
  97685. * @param name defines camera name
  97686. * @param position defines initial position
  97687. * @param interaxialDistance defines distance between each color axis
  97688. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97689. * @param scene defines the hosting scene
  97690. */
  97691. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97692. /**
  97693. * Gets camera class name
  97694. * @returns StereoscopicGamepadCamera
  97695. */
  97696. getClassName(): string;
  97697. }
  97698. }
  97699. declare module BABYLON {
  97700. /**
  97701. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  97702. * @see http://doc.babylonjs.com/features/cameras
  97703. */
  97704. export class StereoscopicUniversalCamera extends UniversalCamera {
  97705. /**
  97706. * Creates a new StereoscopicUniversalCamera
  97707. * @param name defines camera name
  97708. * @param position defines initial position
  97709. * @param interaxialDistance defines distance between each color axis
  97710. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97711. * @param scene defines the hosting scene
  97712. */
  97713. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97714. /**
  97715. * Gets camera class name
  97716. * @returns StereoscopicUniversalCamera
  97717. */
  97718. getClassName(): string;
  97719. }
  97720. }
  97721. declare module BABYLON {
  97722. /**
  97723. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97724. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97725. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97726. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97727. */
  97728. export class VirtualJoysticksCamera extends FreeCamera {
  97729. /**
  97730. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  97731. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97732. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97733. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97734. * @param name Define the name of the camera in the scene
  97735. * @param position Define the start position of the camera in the scene
  97736. * @param scene Define the scene the camera belongs to
  97737. */
  97738. constructor(name: string, position: Vector3, scene: Scene);
  97739. /**
  97740. * Gets the current object class name.
  97741. * @return the class name
  97742. */
  97743. getClassName(): string;
  97744. }
  97745. }
  97746. declare module BABYLON {
  97747. /**
  97748. * This represents all the required metrics to create a VR camera.
  97749. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97750. */
  97751. export class VRCameraMetrics {
  97752. /**
  97753. * Define the horizontal resolution off the screen.
  97754. */
  97755. hResolution: number;
  97756. /**
  97757. * Define the vertical resolution off the screen.
  97758. */
  97759. vResolution: number;
  97760. /**
  97761. * Define the horizontal screen size.
  97762. */
  97763. hScreenSize: number;
  97764. /**
  97765. * Define the vertical screen size.
  97766. */
  97767. vScreenSize: number;
  97768. /**
  97769. * Define the vertical screen center position.
  97770. */
  97771. vScreenCenter: number;
  97772. /**
  97773. * Define the distance of the eyes to the screen.
  97774. */
  97775. eyeToScreenDistance: number;
  97776. /**
  97777. * Define the distance between both lenses
  97778. */
  97779. lensSeparationDistance: number;
  97780. /**
  97781. * Define the distance between both viewer's eyes.
  97782. */
  97783. interpupillaryDistance: number;
  97784. /**
  97785. * Define the distortion factor of the VR postprocess.
  97786. * Please, touch with care.
  97787. */
  97788. distortionK: number[];
  97789. /**
  97790. * Define the chromatic aberration correction factors for the VR post process.
  97791. */
  97792. chromaAbCorrection: number[];
  97793. /**
  97794. * Define the scale factor of the post process.
  97795. * The smaller the better but the slower.
  97796. */
  97797. postProcessScaleFactor: number;
  97798. /**
  97799. * Define an offset for the lens center.
  97800. */
  97801. lensCenterOffset: number;
  97802. /**
  97803. * Define if the current vr camera should compensate the distortion of the lense or not.
  97804. */
  97805. compensateDistortion: boolean;
  97806. /**
  97807. * Defines if multiview should be enabled when rendering (Default: false)
  97808. */
  97809. multiviewEnabled: boolean;
  97810. /**
  97811. * Gets the rendering aspect ratio based on the provided resolutions.
  97812. */
  97813. readonly aspectRatio: number;
  97814. /**
  97815. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97816. */
  97817. readonly aspectRatioFov: number;
  97818. /**
  97819. * @hidden
  97820. */
  97821. readonly leftHMatrix: Matrix;
  97822. /**
  97823. * @hidden
  97824. */
  97825. readonly rightHMatrix: Matrix;
  97826. /**
  97827. * @hidden
  97828. */
  97829. readonly leftPreViewMatrix: Matrix;
  97830. /**
  97831. * @hidden
  97832. */
  97833. readonly rightPreViewMatrix: Matrix;
  97834. /**
  97835. * Get the default VRMetrics based on the most generic setup.
  97836. * @returns the default vr metrics
  97837. */
  97838. static GetDefault(): VRCameraMetrics;
  97839. }
  97840. }
  97841. declare module BABYLON {
  97842. /** @hidden */
  97843. export var vrDistortionCorrectionPixelShader: {
  97844. name: string;
  97845. shader: string;
  97846. };
  97847. }
  97848. declare module BABYLON {
  97849. /**
  97850. * VRDistortionCorrectionPostProcess used for mobile VR
  97851. */
  97852. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97853. private _isRightEye;
  97854. private _distortionFactors;
  97855. private _postProcessScaleFactor;
  97856. private _lensCenterOffset;
  97857. private _scaleIn;
  97858. private _scaleFactor;
  97859. private _lensCenter;
  97860. /**
  97861. * Initializes the VRDistortionCorrectionPostProcess
  97862. * @param name The name of the effect.
  97863. * @param camera The camera to apply the render pass to.
  97864. * @param isRightEye If this is for the right eye distortion
  97865. * @param vrMetrics All the required metrics for the VR camera
  97866. */
  97867. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97868. }
  97869. }
  97870. declare module BABYLON {
  97871. /**
  97872. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97873. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97874. */
  97875. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97876. /**
  97877. * Creates a new VRDeviceOrientationArcRotateCamera
  97878. * @param name defines camera name
  97879. * @param alpha defines the camera rotation along the logitudinal axis
  97880. * @param beta defines the camera rotation along the latitudinal axis
  97881. * @param radius defines the camera distance from its target
  97882. * @param target defines the camera target
  97883. * @param scene defines the scene the camera belongs to
  97884. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97885. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97886. */
  97887. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97888. /**
  97889. * Gets camera class name
  97890. * @returns VRDeviceOrientationArcRotateCamera
  97891. */
  97892. getClassName(): string;
  97893. }
  97894. }
  97895. declare module BABYLON {
  97896. /**
  97897. * Camera used to simulate VR rendering (based on FreeCamera)
  97898. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97899. */
  97900. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97901. /**
  97902. * Creates a new VRDeviceOrientationFreeCamera
  97903. * @param name defines camera name
  97904. * @param position defines the start position of the camera
  97905. * @param scene defines the scene the camera belongs to
  97906. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97907. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97908. */
  97909. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97910. /**
  97911. * Gets camera class name
  97912. * @returns VRDeviceOrientationFreeCamera
  97913. */
  97914. getClassName(): string;
  97915. }
  97916. }
  97917. declare module BABYLON {
  97918. /**
  97919. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97920. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97921. */
  97922. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97923. /**
  97924. * Creates a new VRDeviceOrientationGamepadCamera
  97925. * @param name defines camera name
  97926. * @param position defines the start position of the camera
  97927. * @param scene defines the scene the camera belongs to
  97928. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97929. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97930. */
  97931. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97932. /**
  97933. * Gets camera class name
  97934. * @returns VRDeviceOrientationGamepadCamera
  97935. */
  97936. getClassName(): string;
  97937. }
  97938. }
  97939. declare module BABYLON {
  97940. /**
  97941. * Defines supported buttons for XBox360 compatible gamepads
  97942. */
  97943. export enum Xbox360Button {
  97944. /** A */
  97945. A = 0,
  97946. /** B */
  97947. B = 1,
  97948. /** X */
  97949. X = 2,
  97950. /** Y */
  97951. Y = 3,
  97952. /** Start */
  97953. Start = 4,
  97954. /** Back */
  97955. Back = 5,
  97956. /** Left button */
  97957. LB = 6,
  97958. /** Right button */
  97959. RB = 7,
  97960. /** Left stick */
  97961. LeftStick = 8,
  97962. /** Right stick */
  97963. RightStick = 9
  97964. }
  97965. /** Defines values for XBox360 DPad */
  97966. export enum Xbox360Dpad {
  97967. /** Up */
  97968. Up = 0,
  97969. /** Down */
  97970. Down = 1,
  97971. /** Left */
  97972. Left = 2,
  97973. /** Right */
  97974. Right = 3
  97975. }
  97976. /**
  97977. * Defines a XBox360 gamepad
  97978. */
  97979. export class Xbox360Pad extends Gamepad {
  97980. private _leftTrigger;
  97981. private _rightTrigger;
  97982. private _onlefttriggerchanged;
  97983. private _onrighttriggerchanged;
  97984. private _onbuttondown;
  97985. private _onbuttonup;
  97986. private _ondpaddown;
  97987. private _ondpadup;
  97988. /** Observable raised when a button is pressed */
  97989. onButtonDownObservable: Observable<Xbox360Button>;
  97990. /** Observable raised when a button is released */
  97991. onButtonUpObservable: Observable<Xbox360Button>;
  97992. /** Observable raised when a pad is pressed */
  97993. onPadDownObservable: Observable<Xbox360Dpad>;
  97994. /** Observable raised when a pad is released */
  97995. onPadUpObservable: Observable<Xbox360Dpad>;
  97996. private _buttonA;
  97997. private _buttonB;
  97998. private _buttonX;
  97999. private _buttonY;
  98000. private _buttonBack;
  98001. private _buttonStart;
  98002. private _buttonLB;
  98003. private _buttonRB;
  98004. private _buttonLeftStick;
  98005. private _buttonRightStick;
  98006. private _dPadUp;
  98007. private _dPadDown;
  98008. private _dPadLeft;
  98009. private _dPadRight;
  98010. private _isXboxOnePad;
  98011. /**
  98012. * Creates a new XBox360 gamepad object
  98013. * @param id defines the id of this gamepad
  98014. * @param index defines its index
  98015. * @param gamepad defines the internal HTML gamepad object
  98016. * @param xboxOne defines if it is a XBox One gamepad
  98017. */
  98018. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  98019. /**
  98020. * Defines the callback to call when left trigger is pressed
  98021. * @param callback defines the callback to use
  98022. */
  98023. onlefttriggerchanged(callback: (value: number) => void): void;
  98024. /**
  98025. * Defines the callback to call when right trigger is pressed
  98026. * @param callback defines the callback to use
  98027. */
  98028. onrighttriggerchanged(callback: (value: number) => void): void;
  98029. /**
  98030. * Gets the left trigger value
  98031. */
  98032. /**
  98033. * Sets the left trigger value
  98034. */
  98035. leftTrigger: number;
  98036. /**
  98037. * Gets the right trigger value
  98038. */
  98039. /**
  98040. * Sets the right trigger value
  98041. */
  98042. rightTrigger: number;
  98043. /**
  98044. * Defines the callback to call when a button is pressed
  98045. * @param callback defines the callback to use
  98046. */
  98047. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  98048. /**
  98049. * Defines the callback to call when a button is released
  98050. * @param callback defines the callback to use
  98051. */
  98052. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  98053. /**
  98054. * Defines the callback to call when a pad is pressed
  98055. * @param callback defines the callback to use
  98056. */
  98057. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  98058. /**
  98059. * Defines the callback to call when a pad is released
  98060. * @param callback defines the callback to use
  98061. */
  98062. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  98063. private _setButtonValue;
  98064. private _setDPadValue;
  98065. /**
  98066. * Gets the value of the `A` button
  98067. */
  98068. /**
  98069. * Sets the value of the `A` button
  98070. */
  98071. buttonA: number;
  98072. /**
  98073. * Gets the value of the `B` button
  98074. */
  98075. /**
  98076. * Sets the value of the `B` button
  98077. */
  98078. buttonB: number;
  98079. /**
  98080. * Gets the value of the `X` button
  98081. */
  98082. /**
  98083. * Sets the value of the `X` button
  98084. */
  98085. buttonX: number;
  98086. /**
  98087. * Gets the value of the `Y` button
  98088. */
  98089. /**
  98090. * Sets the value of the `Y` button
  98091. */
  98092. buttonY: number;
  98093. /**
  98094. * Gets the value of the `Start` button
  98095. */
  98096. /**
  98097. * Sets the value of the `Start` button
  98098. */
  98099. buttonStart: number;
  98100. /**
  98101. * Gets the value of the `Back` button
  98102. */
  98103. /**
  98104. * Sets the value of the `Back` button
  98105. */
  98106. buttonBack: number;
  98107. /**
  98108. * Gets the value of the `Left` button
  98109. */
  98110. /**
  98111. * Sets the value of the `Left` button
  98112. */
  98113. buttonLB: number;
  98114. /**
  98115. * Gets the value of the `Right` button
  98116. */
  98117. /**
  98118. * Sets the value of the `Right` button
  98119. */
  98120. buttonRB: number;
  98121. /**
  98122. * Gets the value of the Left joystick
  98123. */
  98124. /**
  98125. * Sets the value of the Left joystick
  98126. */
  98127. buttonLeftStick: number;
  98128. /**
  98129. * Gets the value of the Right joystick
  98130. */
  98131. /**
  98132. * Sets the value of the Right joystick
  98133. */
  98134. buttonRightStick: number;
  98135. /**
  98136. * Gets the value of D-pad up
  98137. */
  98138. /**
  98139. * Sets the value of D-pad up
  98140. */
  98141. dPadUp: number;
  98142. /**
  98143. * Gets the value of D-pad down
  98144. */
  98145. /**
  98146. * Sets the value of D-pad down
  98147. */
  98148. dPadDown: number;
  98149. /**
  98150. * Gets the value of D-pad left
  98151. */
  98152. /**
  98153. * Sets the value of D-pad left
  98154. */
  98155. dPadLeft: number;
  98156. /**
  98157. * Gets the value of D-pad right
  98158. */
  98159. /**
  98160. * Sets the value of D-pad right
  98161. */
  98162. dPadRight: number;
  98163. /**
  98164. * Force the gamepad to synchronize with device values
  98165. */
  98166. update(): void;
  98167. /**
  98168. * Disposes the gamepad
  98169. */
  98170. dispose(): void;
  98171. }
  98172. }
  98173. declare module BABYLON {
  98174. /**
  98175. * Base class of materials working in push mode in babylon JS
  98176. * @hidden
  98177. */
  98178. export class PushMaterial extends Material {
  98179. protected _activeEffect: Effect;
  98180. protected _normalMatrix: Matrix;
  98181. /**
  98182. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98183. * This means that the material can keep using a previous shader while a new one is being compiled.
  98184. * This is mostly used when shader parallel compilation is supported (true by default)
  98185. */
  98186. allowShaderHotSwapping: boolean;
  98187. constructor(name: string, scene: Scene);
  98188. getEffect(): Effect;
  98189. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98190. /**
  98191. * Binds the given world matrix to the active effect
  98192. *
  98193. * @param world the matrix to bind
  98194. */
  98195. bindOnlyWorldMatrix(world: Matrix): void;
  98196. /**
  98197. * Binds the given normal matrix to the active effect
  98198. *
  98199. * @param normalMatrix the matrix to bind
  98200. */
  98201. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98202. bind(world: Matrix, mesh?: Mesh): void;
  98203. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98204. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98205. }
  98206. }
  98207. declare module BABYLON {
  98208. /**
  98209. * This groups all the flags used to control the materials channel.
  98210. */
  98211. export class MaterialFlags {
  98212. private static _DiffuseTextureEnabled;
  98213. /**
  98214. * Are diffuse textures enabled in the application.
  98215. */
  98216. static DiffuseTextureEnabled: boolean;
  98217. private static _AmbientTextureEnabled;
  98218. /**
  98219. * Are ambient textures enabled in the application.
  98220. */
  98221. static AmbientTextureEnabled: boolean;
  98222. private static _OpacityTextureEnabled;
  98223. /**
  98224. * Are opacity textures enabled in the application.
  98225. */
  98226. static OpacityTextureEnabled: boolean;
  98227. private static _ReflectionTextureEnabled;
  98228. /**
  98229. * Are reflection textures enabled in the application.
  98230. */
  98231. static ReflectionTextureEnabled: boolean;
  98232. private static _EmissiveTextureEnabled;
  98233. /**
  98234. * Are emissive textures enabled in the application.
  98235. */
  98236. static EmissiveTextureEnabled: boolean;
  98237. private static _SpecularTextureEnabled;
  98238. /**
  98239. * Are specular textures enabled in the application.
  98240. */
  98241. static SpecularTextureEnabled: boolean;
  98242. private static _BumpTextureEnabled;
  98243. /**
  98244. * Are bump textures enabled in the application.
  98245. */
  98246. static BumpTextureEnabled: boolean;
  98247. private static _LightmapTextureEnabled;
  98248. /**
  98249. * Are lightmap textures enabled in the application.
  98250. */
  98251. static LightmapTextureEnabled: boolean;
  98252. private static _RefractionTextureEnabled;
  98253. /**
  98254. * Are refraction textures enabled in the application.
  98255. */
  98256. static RefractionTextureEnabled: boolean;
  98257. private static _ColorGradingTextureEnabled;
  98258. /**
  98259. * Are color grading textures enabled in the application.
  98260. */
  98261. static ColorGradingTextureEnabled: boolean;
  98262. private static _FresnelEnabled;
  98263. /**
  98264. * Are fresnels enabled in the application.
  98265. */
  98266. static FresnelEnabled: boolean;
  98267. private static _ClearCoatTextureEnabled;
  98268. /**
  98269. * Are clear coat textures enabled in the application.
  98270. */
  98271. static ClearCoatTextureEnabled: boolean;
  98272. private static _ClearCoatBumpTextureEnabled;
  98273. /**
  98274. * Are clear coat bump textures enabled in the application.
  98275. */
  98276. static ClearCoatBumpTextureEnabled: boolean;
  98277. private static _ClearCoatTintTextureEnabled;
  98278. /**
  98279. * Are clear coat tint textures enabled in the application.
  98280. */
  98281. static ClearCoatTintTextureEnabled: boolean;
  98282. private static _SheenTextureEnabled;
  98283. /**
  98284. * Are sheen textures enabled in the application.
  98285. */
  98286. static SheenTextureEnabled: boolean;
  98287. private static _AnisotropicTextureEnabled;
  98288. /**
  98289. * Are anisotropic textures enabled in the application.
  98290. */
  98291. static AnisotropicTextureEnabled: boolean;
  98292. private static _ThicknessTextureEnabled;
  98293. /**
  98294. * Are thickness textures enabled in the application.
  98295. */
  98296. static ThicknessTextureEnabled: boolean;
  98297. }
  98298. }
  98299. declare module BABYLON {
  98300. /** @hidden */
  98301. export var defaultFragmentDeclaration: {
  98302. name: string;
  98303. shader: string;
  98304. };
  98305. }
  98306. declare module BABYLON {
  98307. /** @hidden */
  98308. export var defaultUboDeclaration: {
  98309. name: string;
  98310. shader: string;
  98311. };
  98312. }
  98313. declare module BABYLON {
  98314. /** @hidden */
  98315. export var lightFragmentDeclaration: {
  98316. name: string;
  98317. shader: string;
  98318. };
  98319. }
  98320. declare module BABYLON {
  98321. /** @hidden */
  98322. export var lightUboDeclaration: {
  98323. name: string;
  98324. shader: string;
  98325. };
  98326. }
  98327. declare module BABYLON {
  98328. /** @hidden */
  98329. export var lightsFragmentFunctions: {
  98330. name: string;
  98331. shader: string;
  98332. };
  98333. }
  98334. declare module BABYLON {
  98335. /** @hidden */
  98336. export var shadowsFragmentFunctions: {
  98337. name: string;
  98338. shader: string;
  98339. };
  98340. }
  98341. declare module BABYLON {
  98342. /** @hidden */
  98343. export var fresnelFunction: {
  98344. name: string;
  98345. shader: string;
  98346. };
  98347. }
  98348. declare module BABYLON {
  98349. /** @hidden */
  98350. export var reflectionFunction: {
  98351. name: string;
  98352. shader: string;
  98353. };
  98354. }
  98355. declare module BABYLON {
  98356. /** @hidden */
  98357. export var bumpFragmentFunctions: {
  98358. name: string;
  98359. shader: string;
  98360. };
  98361. }
  98362. declare module BABYLON {
  98363. /** @hidden */
  98364. export var logDepthDeclaration: {
  98365. name: string;
  98366. shader: string;
  98367. };
  98368. }
  98369. declare module BABYLON {
  98370. /** @hidden */
  98371. export var bumpFragment: {
  98372. name: string;
  98373. shader: string;
  98374. };
  98375. }
  98376. declare module BABYLON {
  98377. /** @hidden */
  98378. export var depthPrePass: {
  98379. name: string;
  98380. shader: string;
  98381. };
  98382. }
  98383. declare module BABYLON {
  98384. /** @hidden */
  98385. export var lightFragment: {
  98386. name: string;
  98387. shader: string;
  98388. };
  98389. }
  98390. declare module BABYLON {
  98391. /** @hidden */
  98392. export var logDepthFragment: {
  98393. name: string;
  98394. shader: string;
  98395. };
  98396. }
  98397. declare module BABYLON {
  98398. /** @hidden */
  98399. export var defaultPixelShader: {
  98400. name: string;
  98401. shader: string;
  98402. };
  98403. }
  98404. declare module BABYLON {
  98405. /** @hidden */
  98406. export var defaultVertexDeclaration: {
  98407. name: string;
  98408. shader: string;
  98409. };
  98410. }
  98411. declare module BABYLON {
  98412. /** @hidden */
  98413. export var bumpVertexDeclaration: {
  98414. name: string;
  98415. shader: string;
  98416. };
  98417. }
  98418. declare module BABYLON {
  98419. /** @hidden */
  98420. export var bumpVertex: {
  98421. name: string;
  98422. shader: string;
  98423. };
  98424. }
  98425. declare module BABYLON {
  98426. /** @hidden */
  98427. export var fogVertex: {
  98428. name: string;
  98429. shader: string;
  98430. };
  98431. }
  98432. declare module BABYLON {
  98433. /** @hidden */
  98434. export var shadowsVertex: {
  98435. name: string;
  98436. shader: string;
  98437. };
  98438. }
  98439. declare module BABYLON {
  98440. /** @hidden */
  98441. export var pointCloudVertex: {
  98442. name: string;
  98443. shader: string;
  98444. };
  98445. }
  98446. declare module BABYLON {
  98447. /** @hidden */
  98448. export var logDepthVertex: {
  98449. name: string;
  98450. shader: string;
  98451. };
  98452. }
  98453. declare module BABYLON {
  98454. /** @hidden */
  98455. export var defaultVertexShader: {
  98456. name: string;
  98457. shader: string;
  98458. };
  98459. }
  98460. declare module BABYLON {
  98461. /** @hidden */
  98462. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98463. MAINUV1: boolean;
  98464. MAINUV2: boolean;
  98465. DIFFUSE: boolean;
  98466. DIFFUSEDIRECTUV: number;
  98467. AMBIENT: boolean;
  98468. AMBIENTDIRECTUV: number;
  98469. OPACITY: boolean;
  98470. OPACITYDIRECTUV: number;
  98471. OPACITYRGB: boolean;
  98472. REFLECTION: boolean;
  98473. EMISSIVE: boolean;
  98474. EMISSIVEDIRECTUV: number;
  98475. SPECULAR: boolean;
  98476. SPECULARDIRECTUV: number;
  98477. BUMP: boolean;
  98478. BUMPDIRECTUV: number;
  98479. PARALLAX: boolean;
  98480. PARALLAXOCCLUSION: boolean;
  98481. SPECULAROVERALPHA: boolean;
  98482. CLIPPLANE: boolean;
  98483. CLIPPLANE2: boolean;
  98484. CLIPPLANE3: boolean;
  98485. CLIPPLANE4: boolean;
  98486. ALPHATEST: boolean;
  98487. DEPTHPREPASS: boolean;
  98488. ALPHAFROMDIFFUSE: boolean;
  98489. POINTSIZE: boolean;
  98490. FOG: boolean;
  98491. SPECULARTERM: boolean;
  98492. DIFFUSEFRESNEL: boolean;
  98493. OPACITYFRESNEL: boolean;
  98494. REFLECTIONFRESNEL: boolean;
  98495. REFRACTIONFRESNEL: boolean;
  98496. EMISSIVEFRESNEL: boolean;
  98497. FRESNEL: boolean;
  98498. NORMAL: boolean;
  98499. UV1: boolean;
  98500. UV2: boolean;
  98501. VERTEXCOLOR: boolean;
  98502. VERTEXALPHA: boolean;
  98503. NUM_BONE_INFLUENCERS: number;
  98504. BonesPerMesh: number;
  98505. BONETEXTURE: boolean;
  98506. INSTANCES: boolean;
  98507. GLOSSINESS: boolean;
  98508. ROUGHNESS: boolean;
  98509. EMISSIVEASILLUMINATION: boolean;
  98510. LINKEMISSIVEWITHDIFFUSE: boolean;
  98511. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98512. LIGHTMAP: boolean;
  98513. LIGHTMAPDIRECTUV: number;
  98514. OBJECTSPACE_NORMALMAP: boolean;
  98515. USELIGHTMAPASSHADOWMAP: boolean;
  98516. REFLECTIONMAP_3D: boolean;
  98517. REFLECTIONMAP_SPHERICAL: boolean;
  98518. REFLECTIONMAP_PLANAR: boolean;
  98519. REFLECTIONMAP_CUBIC: boolean;
  98520. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98521. REFLECTIONMAP_PROJECTION: boolean;
  98522. REFLECTIONMAP_SKYBOX: boolean;
  98523. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98524. REFLECTIONMAP_EXPLICIT: boolean;
  98525. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98526. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98527. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98528. INVERTCUBICMAP: boolean;
  98529. LOGARITHMICDEPTH: boolean;
  98530. REFRACTION: boolean;
  98531. REFRACTIONMAP_3D: boolean;
  98532. REFLECTIONOVERALPHA: boolean;
  98533. TWOSIDEDLIGHTING: boolean;
  98534. SHADOWFLOAT: boolean;
  98535. MORPHTARGETS: boolean;
  98536. MORPHTARGETS_NORMAL: boolean;
  98537. MORPHTARGETS_TANGENT: boolean;
  98538. NUM_MORPH_INFLUENCERS: number;
  98539. NONUNIFORMSCALING: boolean;
  98540. PREMULTIPLYALPHA: boolean;
  98541. IMAGEPROCESSING: boolean;
  98542. VIGNETTE: boolean;
  98543. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98544. VIGNETTEBLENDMODEOPAQUE: boolean;
  98545. TONEMAPPING: boolean;
  98546. TONEMAPPING_ACES: boolean;
  98547. CONTRAST: boolean;
  98548. COLORCURVES: boolean;
  98549. COLORGRADING: boolean;
  98550. COLORGRADING3D: boolean;
  98551. SAMPLER3DGREENDEPTH: boolean;
  98552. SAMPLER3DBGRMAP: boolean;
  98553. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98554. MULTIVIEW: boolean;
  98555. /**
  98556. * If the reflection texture on this material is in linear color space
  98557. * @hidden
  98558. */
  98559. IS_REFLECTION_LINEAR: boolean;
  98560. /**
  98561. * If the refraction texture on this material is in linear color space
  98562. * @hidden
  98563. */
  98564. IS_REFRACTION_LINEAR: boolean;
  98565. EXPOSURE: boolean;
  98566. constructor();
  98567. setReflectionMode(modeToEnable: string): void;
  98568. }
  98569. /**
  98570. * This is the default material used in Babylon. It is the best trade off between quality
  98571. * and performances.
  98572. * @see http://doc.babylonjs.com/babylon101/materials
  98573. */
  98574. export class StandardMaterial extends PushMaterial {
  98575. private _diffuseTexture;
  98576. /**
  98577. * The basic texture of the material as viewed under a light.
  98578. */
  98579. diffuseTexture: Nullable<BaseTexture>;
  98580. private _ambientTexture;
  98581. /**
  98582. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98583. */
  98584. ambientTexture: Nullable<BaseTexture>;
  98585. private _opacityTexture;
  98586. /**
  98587. * Define the transparency of the material from a texture.
  98588. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98589. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98590. */
  98591. opacityTexture: Nullable<BaseTexture>;
  98592. private _reflectionTexture;
  98593. /**
  98594. * Define the texture used to display the reflection.
  98595. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98596. */
  98597. reflectionTexture: Nullable<BaseTexture>;
  98598. private _emissiveTexture;
  98599. /**
  98600. * Define texture of the material as if self lit.
  98601. * This will be mixed in the final result even in the absence of light.
  98602. */
  98603. emissiveTexture: Nullable<BaseTexture>;
  98604. private _specularTexture;
  98605. /**
  98606. * Define how the color and intensity of the highlight given by the light in the material.
  98607. */
  98608. specularTexture: Nullable<BaseTexture>;
  98609. private _bumpTexture;
  98610. /**
  98611. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98612. * 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.
  98613. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98614. */
  98615. bumpTexture: Nullable<BaseTexture>;
  98616. private _lightmapTexture;
  98617. /**
  98618. * Complex lighting can be computationally expensive to compute at runtime.
  98619. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98620. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98621. */
  98622. lightmapTexture: Nullable<BaseTexture>;
  98623. private _refractionTexture;
  98624. /**
  98625. * Define the texture used to display the refraction.
  98626. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98627. */
  98628. refractionTexture: Nullable<BaseTexture>;
  98629. /**
  98630. * The color of the material lit by the environmental background lighting.
  98631. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98632. */
  98633. ambientColor: Color3;
  98634. /**
  98635. * The basic color of the material as viewed under a light.
  98636. */
  98637. diffuseColor: Color3;
  98638. /**
  98639. * Define how the color and intensity of the highlight given by the light in the material.
  98640. */
  98641. specularColor: Color3;
  98642. /**
  98643. * Define the color of the material as if self lit.
  98644. * This will be mixed in the final result even in the absence of light.
  98645. */
  98646. emissiveColor: Color3;
  98647. /**
  98648. * Defines how sharp are the highlights in the material.
  98649. * The bigger the value the sharper giving a more glossy feeling to the result.
  98650. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98651. */
  98652. specularPower: number;
  98653. private _useAlphaFromDiffuseTexture;
  98654. /**
  98655. * Does the transparency come from the diffuse texture alpha channel.
  98656. */
  98657. useAlphaFromDiffuseTexture: boolean;
  98658. private _useEmissiveAsIllumination;
  98659. /**
  98660. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98661. */
  98662. useEmissiveAsIllumination: boolean;
  98663. private _linkEmissiveWithDiffuse;
  98664. /**
  98665. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98666. * the emissive level when the final color is close to one.
  98667. */
  98668. linkEmissiveWithDiffuse: boolean;
  98669. private _useSpecularOverAlpha;
  98670. /**
  98671. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98672. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98673. */
  98674. useSpecularOverAlpha: boolean;
  98675. private _useReflectionOverAlpha;
  98676. /**
  98677. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98678. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98679. */
  98680. useReflectionOverAlpha: boolean;
  98681. private _disableLighting;
  98682. /**
  98683. * Does lights from the scene impacts this material.
  98684. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98685. */
  98686. disableLighting: boolean;
  98687. private _useObjectSpaceNormalMap;
  98688. /**
  98689. * Allows using an object space normal map (instead of tangent space).
  98690. */
  98691. useObjectSpaceNormalMap: boolean;
  98692. private _useParallax;
  98693. /**
  98694. * Is parallax enabled or not.
  98695. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98696. */
  98697. useParallax: boolean;
  98698. private _useParallaxOcclusion;
  98699. /**
  98700. * Is parallax occlusion enabled or not.
  98701. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98702. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98703. */
  98704. useParallaxOcclusion: boolean;
  98705. /**
  98706. * 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.
  98707. */
  98708. parallaxScaleBias: number;
  98709. private _roughness;
  98710. /**
  98711. * Helps to define how blurry the reflections should appears in the material.
  98712. */
  98713. roughness: number;
  98714. /**
  98715. * In case of refraction, define the value of the indice of refraction.
  98716. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98717. */
  98718. indexOfRefraction: number;
  98719. /**
  98720. * Invert the refraction texture alongside the y axis.
  98721. * It can be useful with procedural textures or probe for instance.
  98722. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98723. */
  98724. invertRefractionY: boolean;
  98725. /**
  98726. * Defines the alpha limits in alpha test mode.
  98727. */
  98728. alphaCutOff: number;
  98729. private _useLightmapAsShadowmap;
  98730. /**
  98731. * In case of light mapping, define whether the map contains light or shadow informations.
  98732. */
  98733. useLightmapAsShadowmap: boolean;
  98734. private _diffuseFresnelParameters;
  98735. /**
  98736. * Define the diffuse fresnel parameters of the material.
  98737. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98738. */
  98739. diffuseFresnelParameters: FresnelParameters;
  98740. private _opacityFresnelParameters;
  98741. /**
  98742. * Define the opacity fresnel parameters of the material.
  98743. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98744. */
  98745. opacityFresnelParameters: FresnelParameters;
  98746. private _reflectionFresnelParameters;
  98747. /**
  98748. * Define the reflection fresnel parameters of the material.
  98749. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98750. */
  98751. reflectionFresnelParameters: FresnelParameters;
  98752. private _refractionFresnelParameters;
  98753. /**
  98754. * Define the refraction fresnel parameters of the material.
  98755. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98756. */
  98757. refractionFresnelParameters: FresnelParameters;
  98758. private _emissiveFresnelParameters;
  98759. /**
  98760. * Define the emissive fresnel parameters of the material.
  98761. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98762. */
  98763. emissiveFresnelParameters: FresnelParameters;
  98764. private _useReflectionFresnelFromSpecular;
  98765. /**
  98766. * If true automatically deducts the fresnels values from the material specularity.
  98767. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98768. */
  98769. useReflectionFresnelFromSpecular: boolean;
  98770. private _useGlossinessFromSpecularMapAlpha;
  98771. /**
  98772. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98773. */
  98774. useGlossinessFromSpecularMapAlpha: boolean;
  98775. private _maxSimultaneousLights;
  98776. /**
  98777. * Defines the maximum number of lights that can be used in the material
  98778. */
  98779. maxSimultaneousLights: number;
  98780. private _invertNormalMapX;
  98781. /**
  98782. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98783. */
  98784. invertNormalMapX: boolean;
  98785. private _invertNormalMapY;
  98786. /**
  98787. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98788. */
  98789. invertNormalMapY: boolean;
  98790. private _twoSidedLighting;
  98791. /**
  98792. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98793. */
  98794. twoSidedLighting: boolean;
  98795. /**
  98796. * Default configuration related to image processing available in the standard Material.
  98797. */
  98798. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98799. /**
  98800. * Gets the image processing configuration used either in this material.
  98801. */
  98802. /**
  98803. * Sets the Default image processing configuration used either in the this material.
  98804. *
  98805. * If sets to null, the scene one is in use.
  98806. */
  98807. imageProcessingConfiguration: ImageProcessingConfiguration;
  98808. /**
  98809. * Keep track of the image processing observer to allow dispose and replace.
  98810. */
  98811. private _imageProcessingObserver;
  98812. /**
  98813. * Attaches a new image processing configuration to the Standard Material.
  98814. * @param configuration
  98815. */
  98816. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98817. /**
  98818. * Gets wether the color curves effect is enabled.
  98819. */
  98820. /**
  98821. * Sets wether the color curves effect is enabled.
  98822. */
  98823. cameraColorCurvesEnabled: boolean;
  98824. /**
  98825. * Gets wether the color grading effect is enabled.
  98826. */
  98827. /**
  98828. * Gets wether the color grading effect is enabled.
  98829. */
  98830. cameraColorGradingEnabled: boolean;
  98831. /**
  98832. * Gets wether tonemapping is enabled or not.
  98833. */
  98834. /**
  98835. * Sets wether tonemapping is enabled or not
  98836. */
  98837. cameraToneMappingEnabled: boolean;
  98838. /**
  98839. * The camera exposure used on this material.
  98840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98841. * This corresponds to a photographic exposure.
  98842. */
  98843. /**
  98844. * The camera exposure used on this material.
  98845. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98846. * This corresponds to a photographic exposure.
  98847. */
  98848. cameraExposure: number;
  98849. /**
  98850. * Gets The camera contrast used on this material.
  98851. */
  98852. /**
  98853. * Sets The camera contrast used on this material.
  98854. */
  98855. cameraContrast: number;
  98856. /**
  98857. * Gets the Color Grading 2D Lookup Texture.
  98858. */
  98859. /**
  98860. * Sets the Color Grading 2D Lookup Texture.
  98861. */
  98862. cameraColorGradingTexture: Nullable<BaseTexture>;
  98863. /**
  98864. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98865. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98866. * 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;
  98867. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98868. */
  98869. /**
  98870. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98871. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98872. * 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;
  98873. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98874. */
  98875. cameraColorCurves: Nullable<ColorCurves>;
  98876. /**
  98877. * Custom callback helping to override the default shader used in the material.
  98878. */
  98879. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98880. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98881. protected _worldViewProjectionMatrix: Matrix;
  98882. protected _globalAmbientColor: Color3;
  98883. protected _useLogarithmicDepth: boolean;
  98884. /**
  98885. * Instantiates a new standard material.
  98886. * This is the default material used in Babylon. It is the best trade off between quality
  98887. * and performances.
  98888. * @see http://doc.babylonjs.com/babylon101/materials
  98889. * @param name Define the name of the material in the scene
  98890. * @param scene Define the scene the material belong to
  98891. */
  98892. constructor(name: string, scene: Scene);
  98893. /**
  98894. * Gets a boolean indicating that current material needs to register RTT
  98895. */
  98896. readonly hasRenderTargetTextures: boolean;
  98897. /**
  98898. * Gets the current class name of the material e.g. "StandardMaterial"
  98899. * Mainly use in serialization.
  98900. * @returns the class name
  98901. */
  98902. getClassName(): string;
  98903. /**
  98904. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98905. * You can try switching to logarithmic depth.
  98906. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98907. */
  98908. useLogarithmicDepth: boolean;
  98909. /**
  98910. * Specifies if the material will require alpha blending
  98911. * @returns a boolean specifying if alpha blending is needed
  98912. */
  98913. needAlphaBlending(): boolean;
  98914. /**
  98915. * Specifies if this material should be rendered in alpha test mode
  98916. * @returns a boolean specifying if an alpha test is needed.
  98917. */
  98918. needAlphaTesting(): boolean;
  98919. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98920. /**
  98921. * Get the texture used for alpha test purpose.
  98922. * @returns the diffuse texture in case of the standard material.
  98923. */
  98924. getAlphaTestTexture(): Nullable<BaseTexture>;
  98925. /**
  98926. * Get if the submesh is ready to be used and all its information available.
  98927. * Child classes can use it to update shaders
  98928. * @param mesh defines the mesh to check
  98929. * @param subMesh defines which submesh to check
  98930. * @param useInstances specifies that instances should be used
  98931. * @returns a boolean indicating that the submesh is ready or not
  98932. */
  98933. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98934. /**
  98935. * Builds the material UBO layouts.
  98936. * Used internally during the effect preparation.
  98937. */
  98938. buildUniformLayout(): void;
  98939. /**
  98940. * Unbinds the material from the mesh
  98941. */
  98942. unbind(): void;
  98943. /**
  98944. * Binds the submesh to this material by preparing the effect and shader to draw
  98945. * @param world defines the world transformation matrix
  98946. * @param mesh defines the mesh containing the submesh
  98947. * @param subMesh defines the submesh to bind the material to
  98948. */
  98949. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98950. /**
  98951. * Get the list of animatables in the material.
  98952. * @returns the list of animatables object used in the material
  98953. */
  98954. getAnimatables(): IAnimatable[];
  98955. /**
  98956. * Gets the active textures from the material
  98957. * @returns an array of textures
  98958. */
  98959. getActiveTextures(): BaseTexture[];
  98960. /**
  98961. * Specifies if the material uses a texture
  98962. * @param texture defines the texture to check against the material
  98963. * @returns a boolean specifying if the material uses the texture
  98964. */
  98965. hasTexture(texture: BaseTexture): boolean;
  98966. /**
  98967. * Disposes the material
  98968. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98969. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98970. */
  98971. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98972. /**
  98973. * Makes a duplicate of the material, and gives it a new name
  98974. * @param name defines the new name for the duplicated material
  98975. * @returns the cloned material
  98976. */
  98977. clone(name: string): StandardMaterial;
  98978. /**
  98979. * Serializes this material in a JSON representation
  98980. * @returns the serialized material object
  98981. */
  98982. serialize(): any;
  98983. /**
  98984. * Creates a standard material from parsed material data
  98985. * @param source defines the JSON representation of the material
  98986. * @param scene defines the hosting scene
  98987. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98988. * @returns a new standard material
  98989. */
  98990. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98991. /**
  98992. * Are diffuse textures enabled in the application.
  98993. */
  98994. static DiffuseTextureEnabled: boolean;
  98995. /**
  98996. * Are ambient textures enabled in the application.
  98997. */
  98998. static AmbientTextureEnabled: boolean;
  98999. /**
  99000. * Are opacity textures enabled in the application.
  99001. */
  99002. static OpacityTextureEnabled: boolean;
  99003. /**
  99004. * Are reflection textures enabled in the application.
  99005. */
  99006. static ReflectionTextureEnabled: boolean;
  99007. /**
  99008. * Are emissive textures enabled in the application.
  99009. */
  99010. static EmissiveTextureEnabled: boolean;
  99011. /**
  99012. * Are specular textures enabled in the application.
  99013. */
  99014. static SpecularTextureEnabled: boolean;
  99015. /**
  99016. * Are bump textures enabled in the application.
  99017. */
  99018. static BumpTextureEnabled: boolean;
  99019. /**
  99020. * Are lightmap textures enabled in the application.
  99021. */
  99022. static LightmapTextureEnabled: boolean;
  99023. /**
  99024. * Are refraction textures enabled in the application.
  99025. */
  99026. static RefractionTextureEnabled: boolean;
  99027. /**
  99028. * Are color grading textures enabled in the application.
  99029. */
  99030. static ColorGradingTextureEnabled: boolean;
  99031. /**
  99032. * Are fresnels enabled in the application.
  99033. */
  99034. static FresnelEnabled: boolean;
  99035. }
  99036. }
  99037. declare module BABYLON {
  99038. /**
  99039. * A class extending Texture allowing drawing on a texture
  99040. * @see http://doc.babylonjs.com/how_to/dynamictexture
  99041. */
  99042. export class DynamicTexture extends Texture {
  99043. private _generateMipMaps;
  99044. private _canvas;
  99045. private _context;
  99046. private _engine;
  99047. /**
  99048. * Creates a DynamicTexture
  99049. * @param name defines the name of the texture
  99050. * @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
  99051. * @param scene defines the scene where you want the texture
  99052. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  99053. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  99054. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  99055. */
  99056. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  99057. /**
  99058. * Get the current class name of the texture useful for serialization or dynamic coding.
  99059. * @returns "DynamicTexture"
  99060. */
  99061. getClassName(): string;
  99062. /**
  99063. * Gets the current state of canRescale
  99064. */
  99065. readonly canRescale: boolean;
  99066. private _recreate;
  99067. /**
  99068. * Scales the texture
  99069. * @param ratio the scale factor to apply to both width and height
  99070. */
  99071. scale(ratio: number): void;
  99072. /**
  99073. * Resizes the texture
  99074. * @param width the new width
  99075. * @param height the new height
  99076. */
  99077. scaleTo(width: number, height: number): void;
  99078. /**
  99079. * Gets the context of the canvas used by the texture
  99080. * @returns the canvas context of the dynamic texture
  99081. */
  99082. getContext(): CanvasRenderingContext2D;
  99083. /**
  99084. * Clears the texture
  99085. */
  99086. clear(): void;
  99087. /**
  99088. * Updates the texture
  99089. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99090. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  99091. */
  99092. update(invertY?: boolean, premulAlpha?: boolean): void;
  99093. /**
  99094. * Draws text onto the texture
  99095. * @param text defines the text to be drawn
  99096. * @param x defines the placement of the text from the left
  99097. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  99098. * @param font defines the font to be used with font-style, font-size, font-name
  99099. * @param color defines the color used for the text
  99100. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  99101. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99102. * @param update defines whether texture is immediately update (default is true)
  99103. */
  99104. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  99105. /**
  99106. * Clones the texture
  99107. * @returns the clone of the texture.
  99108. */
  99109. clone(): DynamicTexture;
  99110. /**
  99111. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  99112. * @returns a serialized dynamic texture object
  99113. */
  99114. serialize(): any;
  99115. /** @hidden */
  99116. _rebuild(): void;
  99117. }
  99118. }
  99119. declare module BABYLON {
  99120. /** @hidden */
  99121. export var imageProcessingPixelShader: {
  99122. name: string;
  99123. shader: string;
  99124. };
  99125. }
  99126. declare module BABYLON {
  99127. /**
  99128. * ImageProcessingPostProcess
  99129. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99130. */
  99131. export class ImageProcessingPostProcess extends PostProcess {
  99132. /**
  99133. * Default configuration related to image processing available in the PBR Material.
  99134. */
  99135. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99136. /**
  99137. * Gets the image processing configuration used either in this material.
  99138. */
  99139. /**
  99140. * Sets the Default image processing configuration used either in the this material.
  99141. *
  99142. * If sets to null, the scene one is in use.
  99143. */
  99144. imageProcessingConfiguration: ImageProcessingConfiguration;
  99145. /**
  99146. * Keep track of the image processing observer to allow dispose and replace.
  99147. */
  99148. private _imageProcessingObserver;
  99149. /**
  99150. * Attaches a new image processing configuration to the PBR Material.
  99151. * @param configuration
  99152. */
  99153. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99154. /**
  99155. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99156. */
  99157. /**
  99158. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99159. */
  99160. colorCurves: Nullable<ColorCurves>;
  99161. /**
  99162. * Gets wether the color curves effect is enabled.
  99163. */
  99164. /**
  99165. * Sets wether the color curves effect is enabled.
  99166. */
  99167. colorCurvesEnabled: boolean;
  99168. /**
  99169. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99170. */
  99171. /**
  99172. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99173. */
  99174. colorGradingTexture: Nullable<BaseTexture>;
  99175. /**
  99176. * Gets wether the color grading effect is enabled.
  99177. */
  99178. /**
  99179. * Gets wether the color grading effect is enabled.
  99180. */
  99181. colorGradingEnabled: boolean;
  99182. /**
  99183. * Gets exposure used in the effect.
  99184. */
  99185. /**
  99186. * Sets exposure used in the effect.
  99187. */
  99188. exposure: number;
  99189. /**
  99190. * Gets wether tonemapping is enabled or not.
  99191. */
  99192. /**
  99193. * Sets wether tonemapping is enabled or not
  99194. */
  99195. toneMappingEnabled: boolean;
  99196. /**
  99197. * Gets the type of tone mapping effect.
  99198. */
  99199. /**
  99200. * Sets the type of tone mapping effect.
  99201. */
  99202. toneMappingType: number;
  99203. /**
  99204. * Gets contrast used in the effect.
  99205. */
  99206. /**
  99207. * Sets contrast used in the effect.
  99208. */
  99209. contrast: number;
  99210. /**
  99211. * Gets Vignette stretch size.
  99212. */
  99213. /**
  99214. * Sets Vignette stretch size.
  99215. */
  99216. vignetteStretch: number;
  99217. /**
  99218. * Gets Vignette centre X Offset.
  99219. */
  99220. /**
  99221. * Sets Vignette centre X Offset.
  99222. */
  99223. vignetteCentreX: number;
  99224. /**
  99225. * Gets Vignette centre Y Offset.
  99226. */
  99227. /**
  99228. * Sets Vignette centre Y Offset.
  99229. */
  99230. vignetteCentreY: number;
  99231. /**
  99232. * Gets Vignette weight or intensity of the vignette effect.
  99233. */
  99234. /**
  99235. * Sets Vignette weight or intensity of the vignette effect.
  99236. */
  99237. vignetteWeight: number;
  99238. /**
  99239. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99240. * if vignetteEnabled is set to true.
  99241. */
  99242. /**
  99243. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99244. * if vignetteEnabled is set to true.
  99245. */
  99246. vignetteColor: Color4;
  99247. /**
  99248. * Gets Camera field of view used by the Vignette effect.
  99249. */
  99250. /**
  99251. * Sets Camera field of view used by the Vignette effect.
  99252. */
  99253. vignetteCameraFov: number;
  99254. /**
  99255. * Gets the vignette blend mode allowing different kind of effect.
  99256. */
  99257. /**
  99258. * Sets the vignette blend mode allowing different kind of effect.
  99259. */
  99260. vignetteBlendMode: number;
  99261. /**
  99262. * Gets wether the vignette effect is enabled.
  99263. */
  99264. /**
  99265. * Sets wether the vignette effect is enabled.
  99266. */
  99267. vignetteEnabled: boolean;
  99268. private _fromLinearSpace;
  99269. /**
  99270. * Gets wether the input of the processing is in Gamma or Linear Space.
  99271. */
  99272. /**
  99273. * Sets wether the input of the processing is in Gamma or Linear Space.
  99274. */
  99275. fromLinearSpace: boolean;
  99276. /**
  99277. * Defines cache preventing GC.
  99278. */
  99279. private _defines;
  99280. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99281. /**
  99282. * "ImageProcessingPostProcess"
  99283. * @returns "ImageProcessingPostProcess"
  99284. */
  99285. getClassName(): string;
  99286. protected _updateParameters(): void;
  99287. dispose(camera?: Camera): void;
  99288. }
  99289. }
  99290. declare module BABYLON {
  99291. /**
  99292. * Class containing static functions to help procedurally build meshes
  99293. */
  99294. export class GroundBuilder {
  99295. /**
  99296. * Creates a ground mesh
  99297. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  99298. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  99299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99300. * @param name defines the name of the mesh
  99301. * @param options defines the options used to create the mesh
  99302. * @param scene defines the hosting scene
  99303. * @returns the ground mesh
  99304. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  99305. */
  99306. static CreateGround(name: string, options: {
  99307. width?: number;
  99308. height?: number;
  99309. subdivisions?: number;
  99310. subdivisionsX?: number;
  99311. subdivisionsY?: number;
  99312. updatable?: boolean;
  99313. }, scene: any): Mesh;
  99314. /**
  99315. * Creates a tiled ground mesh
  99316. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  99317. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  99318. * * 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
  99319. * * 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
  99320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99321. * @param name defines the name of the mesh
  99322. * @param options defines the options used to create the mesh
  99323. * @param scene defines the hosting scene
  99324. * @returns the tiled ground mesh
  99325. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  99326. */
  99327. static CreateTiledGround(name: string, options: {
  99328. xmin: number;
  99329. zmin: number;
  99330. xmax: number;
  99331. zmax: number;
  99332. subdivisions?: {
  99333. w: number;
  99334. h: number;
  99335. };
  99336. precision?: {
  99337. w: number;
  99338. h: number;
  99339. };
  99340. updatable?: boolean;
  99341. }, scene?: Nullable<Scene>): Mesh;
  99342. /**
  99343. * Creates a ground mesh from a height map
  99344. * * The parameter `url` sets the URL of the height map image resource.
  99345. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  99346. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  99347. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  99348. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  99349. * * 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.
  99350. * * 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).
  99351. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99353. * @param name defines the name of the mesh
  99354. * @param url defines the url to the height map
  99355. * @param options defines the options used to create the mesh
  99356. * @param scene defines the hosting scene
  99357. * @returns the ground mesh
  99358. * @see https://doc.babylonjs.com/babylon101/height_map
  99359. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  99360. */
  99361. static CreateGroundFromHeightMap(name: string, url: string, options: {
  99362. width?: number;
  99363. height?: number;
  99364. subdivisions?: number;
  99365. minHeight?: number;
  99366. maxHeight?: number;
  99367. colorFilter?: Color3;
  99368. alphaFilter?: number;
  99369. updatable?: boolean;
  99370. onReady?: (mesh: GroundMesh) => void;
  99371. }, scene?: Nullable<Scene>): GroundMesh;
  99372. }
  99373. }
  99374. declare module BABYLON {
  99375. /**
  99376. * Class containing static functions to help procedurally build meshes
  99377. */
  99378. export class TorusBuilder {
  99379. /**
  99380. * Creates a torus mesh
  99381. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  99382. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  99383. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  99384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99387. * @param name defines the name of the mesh
  99388. * @param options defines the options used to create the mesh
  99389. * @param scene defines the hosting scene
  99390. * @returns the torus mesh
  99391. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  99392. */
  99393. static CreateTorus(name: string, options: {
  99394. diameter?: number;
  99395. thickness?: number;
  99396. tessellation?: number;
  99397. updatable?: boolean;
  99398. sideOrientation?: number;
  99399. frontUVs?: Vector4;
  99400. backUVs?: Vector4;
  99401. }, scene: any): Mesh;
  99402. }
  99403. }
  99404. declare module BABYLON {
  99405. /**
  99406. * Class containing static functions to help procedurally build meshes
  99407. */
  99408. export class CylinderBuilder {
  99409. /**
  99410. * Creates a cylinder or a cone mesh
  99411. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  99412. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  99413. * * 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.
  99414. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  99415. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  99416. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  99417. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  99418. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  99419. * * 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).
  99420. * * 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
  99421. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  99422. * * 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
  99423. * * 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.
  99424. * * If `enclose` is false, a ring surface is one element.
  99425. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  99426. * * 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
  99427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99430. * @param name defines the name of the mesh
  99431. * @param options defines the options used to create the mesh
  99432. * @param scene defines the hosting scene
  99433. * @returns the cylinder mesh
  99434. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  99435. */
  99436. static CreateCylinder(name: string, options: {
  99437. height?: number;
  99438. diameterTop?: number;
  99439. diameterBottom?: number;
  99440. diameter?: number;
  99441. tessellation?: number;
  99442. subdivisions?: number;
  99443. arc?: number;
  99444. faceColors?: Color4[];
  99445. faceUV?: Vector4[];
  99446. updatable?: boolean;
  99447. hasRings?: boolean;
  99448. enclose?: boolean;
  99449. sideOrientation?: number;
  99450. frontUVs?: Vector4;
  99451. backUVs?: Vector4;
  99452. }, scene: any): Mesh;
  99453. }
  99454. }
  99455. declare module BABYLON {
  99456. /**
  99457. * Manager for handling gamepads
  99458. */
  99459. export class GamepadManager {
  99460. private _scene?;
  99461. private _babylonGamepads;
  99462. private _oneGamepadConnected;
  99463. /** @hidden */
  99464. _isMonitoring: boolean;
  99465. private _gamepadEventSupported;
  99466. private _gamepadSupport;
  99467. /**
  99468. * observable to be triggered when the gamepad controller has been connected
  99469. */
  99470. onGamepadConnectedObservable: Observable<Gamepad>;
  99471. /**
  99472. * observable to be triggered when the gamepad controller has been disconnected
  99473. */
  99474. onGamepadDisconnectedObservable: Observable<Gamepad>;
  99475. private _onGamepadConnectedEvent;
  99476. private _onGamepadDisconnectedEvent;
  99477. /**
  99478. * Initializes the gamepad manager
  99479. * @param _scene BabylonJS scene
  99480. */
  99481. constructor(_scene?: Scene | undefined);
  99482. /**
  99483. * The gamepads in the game pad manager
  99484. */
  99485. readonly gamepads: Gamepad[];
  99486. /**
  99487. * Get the gamepad controllers based on type
  99488. * @param type The type of gamepad controller
  99489. * @returns Nullable gamepad
  99490. */
  99491. getGamepadByType(type?: number): Nullable<Gamepad>;
  99492. /**
  99493. * Disposes the gamepad manager
  99494. */
  99495. dispose(): void;
  99496. private _addNewGamepad;
  99497. private _startMonitoringGamepads;
  99498. private _stopMonitoringGamepads;
  99499. /** @hidden */
  99500. _checkGamepadsStatus(): void;
  99501. private _updateGamepadObjects;
  99502. }
  99503. }
  99504. declare module BABYLON {
  99505. interface Scene {
  99506. /** @hidden */
  99507. _gamepadManager: Nullable<GamepadManager>;
  99508. /**
  99509. * Gets the gamepad manager associated with the scene
  99510. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  99511. */
  99512. gamepadManager: GamepadManager;
  99513. }
  99514. /**
  99515. * Interface representing a free camera inputs manager
  99516. */
  99517. interface FreeCameraInputsManager {
  99518. /**
  99519. * Adds gamepad input support to the FreeCameraInputsManager.
  99520. * @returns the FreeCameraInputsManager
  99521. */
  99522. addGamepad(): FreeCameraInputsManager;
  99523. }
  99524. /**
  99525. * Interface representing an arc rotate camera inputs manager
  99526. */
  99527. interface ArcRotateCameraInputsManager {
  99528. /**
  99529. * Adds gamepad input support to the ArcRotateCamera InputManager.
  99530. * @returns the camera inputs manager
  99531. */
  99532. addGamepad(): ArcRotateCameraInputsManager;
  99533. }
  99534. /**
  99535. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  99536. */
  99537. export class GamepadSystemSceneComponent implements ISceneComponent {
  99538. /**
  99539. * The component name helpfull to identify the component in the list of scene components.
  99540. */
  99541. readonly name: string;
  99542. /**
  99543. * The scene the component belongs to.
  99544. */
  99545. scene: Scene;
  99546. /**
  99547. * Creates a new instance of the component for the given scene
  99548. * @param scene Defines the scene to register the component in
  99549. */
  99550. constructor(scene: Scene);
  99551. /**
  99552. * Registers the component in a given scene
  99553. */
  99554. register(): void;
  99555. /**
  99556. * Rebuilds the elements related to this component in case of
  99557. * context lost for instance.
  99558. */
  99559. rebuild(): void;
  99560. /**
  99561. * Disposes the component and the associated ressources
  99562. */
  99563. dispose(): void;
  99564. private _beforeCameraUpdate;
  99565. }
  99566. }
  99567. declare module BABYLON {
  99568. /**
  99569. * Options to modify the vr teleportation behavior.
  99570. */
  99571. export interface VRTeleportationOptions {
  99572. /**
  99573. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99574. */
  99575. floorMeshName?: string;
  99576. /**
  99577. * A list of meshes to be used as the teleportation floor. (default: empty)
  99578. */
  99579. floorMeshes?: Mesh[];
  99580. }
  99581. /**
  99582. * Options to modify the vr experience helper's behavior.
  99583. */
  99584. export interface VRExperienceHelperOptions extends WebVROptions {
  99585. /**
  99586. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99587. */
  99588. createDeviceOrientationCamera?: boolean;
  99589. /**
  99590. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99591. */
  99592. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99593. /**
  99594. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99595. */
  99596. laserToggle?: boolean;
  99597. /**
  99598. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99599. */
  99600. floorMeshes?: Mesh[];
  99601. /**
  99602. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99603. */
  99604. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99605. }
  99606. /**
  99607. * Event containing information after VR has been entered
  99608. */
  99609. export class OnAfterEnteringVRObservableEvent {
  99610. /**
  99611. * If entering vr was successful
  99612. */
  99613. success: boolean;
  99614. }
  99615. /**
  99616. * Helps to quickly add VR support to an existing scene.
  99617. * See http://doc.babylonjs.com/how_to/webvr_helper
  99618. */
  99619. export class VRExperienceHelper {
  99620. /** Options to modify the vr experience helper's behavior. */
  99621. webVROptions: VRExperienceHelperOptions;
  99622. private _scene;
  99623. private _position;
  99624. private _btnVR;
  99625. private _btnVRDisplayed;
  99626. private _webVRsupported;
  99627. private _webVRready;
  99628. private _webVRrequesting;
  99629. private _webVRpresenting;
  99630. private _hasEnteredVR;
  99631. private _fullscreenVRpresenting;
  99632. private _canvas;
  99633. private _webVRCamera;
  99634. private _vrDeviceOrientationCamera;
  99635. private _deviceOrientationCamera;
  99636. private _existingCamera;
  99637. private _onKeyDown;
  99638. private _onVrDisplayPresentChange;
  99639. private _onVRDisplayChanged;
  99640. private _onVRRequestPresentStart;
  99641. private _onVRRequestPresentComplete;
  99642. /**
  99643. * Observable raised right before entering VR.
  99644. */
  99645. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99646. /**
  99647. * Observable raised when entering VR has completed.
  99648. */
  99649. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99650. /**
  99651. * Observable raised when exiting VR.
  99652. */
  99653. onExitingVRObservable: Observable<VRExperienceHelper>;
  99654. /**
  99655. * Observable raised when controller mesh is loaded.
  99656. */
  99657. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99658. /** Return this.onEnteringVRObservable
  99659. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99660. */
  99661. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99662. /** Return this.onExitingVRObservable
  99663. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99664. */
  99665. readonly onExitingVR: Observable<VRExperienceHelper>;
  99666. /** Return this.onControllerMeshLoadedObservable
  99667. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99668. */
  99669. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99670. private _rayLength;
  99671. private _useCustomVRButton;
  99672. private _teleportationRequested;
  99673. private _teleportActive;
  99674. private _floorMeshName;
  99675. private _floorMeshesCollection;
  99676. private _rotationAllowed;
  99677. private _teleportBackwardsVector;
  99678. private _teleportationTarget;
  99679. private _isDefaultTeleportationTarget;
  99680. private _postProcessMove;
  99681. private _teleportationFillColor;
  99682. private _teleportationBorderColor;
  99683. private _rotationAngle;
  99684. private _haloCenter;
  99685. private _cameraGazer;
  99686. private _padSensibilityUp;
  99687. private _padSensibilityDown;
  99688. private _leftController;
  99689. private _rightController;
  99690. /**
  99691. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99692. */
  99693. onNewMeshSelected: Observable<AbstractMesh>;
  99694. /**
  99695. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99696. */
  99697. onNewMeshPicked: Observable<PickingInfo>;
  99698. private _circleEase;
  99699. /**
  99700. * Observable raised before camera teleportation
  99701. */
  99702. onBeforeCameraTeleport: Observable<Vector3>;
  99703. /**
  99704. * Observable raised after camera teleportation
  99705. */
  99706. onAfterCameraTeleport: Observable<Vector3>;
  99707. /**
  99708. * Observable raised when current selected mesh gets unselected
  99709. */
  99710. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99711. private _raySelectionPredicate;
  99712. /**
  99713. * To be optionaly changed by user to define custom ray selection
  99714. */
  99715. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99716. /**
  99717. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99718. */
  99719. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99720. /**
  99721. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99722. */
  99723. teleportationEnabled: boolean;
  99724. private _defaultHeight;
  99725. private _teleportationInitialized;
  99726. private _interactionsEnabled;
  99727. private _interactionsRequested;
  99728. private _displayGaze;
  99729. private _displayLaserPointer;
  99730. /**
  99731. * The mesh used to display where the user is going to teleport.
  99732. */
  99733. /**
  99734. * Sets the mesh to be used to display where the user is going to teleport.
  99735. */
  99736. teleportationTarget: Mesh;
  99737. /**
  99738. * 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
  99739. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99740. * See http://doc.babylonjs.com/resources/baking_transformations
  99741. */
  99742. gazeTrackerMesh: Mesh;
  99743. /**
  99744. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99745. */
  99746. updateGazeTrackerScale: boolean;
  99747. /**
  99748. * If the gaze trackers color should be updated when selecting meshes
  99749. */
  99750. updateGazeTrackerColor: boolean;
  99751. /**
  99752. * The gaze tracking mesh corresponding to the left controller
  99753. */
  99754. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99755. /**
  99756. * The gaze tracking mesh corresponding to the right controller
  99757. */
  99758. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99759. /**
  99760. * If the ray of the gaze should be displayed.
  99761. */
  99762. /**
  99763. * Sets if the ray of the gaze should be displayed.
  99764. */
  99765. displayGaze: boolean;
  99766. /**
  99767. * If the ray of the LaserPointer should be displayed.
  99768. */
  99769. /**
  99770. * Sets if the ray of the LaserPointer should be displayed.
  99771. */
  99772. displayLaserPointer: boolean;
  99773. /**
  99774. * The deviceOrientationCamera used as the camera when not in VR.
  99775. */
  99776. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99777. /**
  99778. * Based on the current WebVR support, returns the current VR camera used.
  99779. */
  99780. readonly currentVRCamera: Nullable<Camera>;
  99781. /**
  99782. * The webVRCamera which is used when in VR.
  99783. */
  99784. readonly webVRCamera: WebVRFreeCamera;
  99785. /**
  99786. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99787. */
  99788. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99789. private readonly _teleportationRequestInitiated;
  99790. /**
  99791. * Defines wether or not Pointer lock should be requested when switching to
  99792. * full screen.
  99793. */
  99794. requestPointerLockOnFullScreen: boolean;
  99795. /**
  99796. * Instantiates a VRExperienceHelper.
  99797. * Helps to quickly add VR support to an existing scene.
  99798. * @param scene The scene the VRExperienceHelper belongs to.
  99799. * @param webVROptions Options to modify the vr experience helper's behavior.
  99800. */
  99801. constructor(scene: Scene,
  99802. /** Options to modify the vr experience helper's behavior. */
  99803. webVROptions?: VRExperienceHelperOptions);
  99804. private _onDefaultMeshLoaded;
  99805. private _onResize;
  99806. private _onFullscreenChange;
  99807. /**
  99808. * Gets a value indicating if we are currently in VR mode.
  99809. */
  99810. readonly isInVRMode: boolean;
  99811. private onVrDisplayPresentChange;
  99812. private onVRDisplayChanged;
  99813. private moveButtonToBottomRight;
  99814. private displayVRButton;
  99815. private updateButtonVisibility;
  99816. private _cachedAngularSensibility;
  99817. /**
  99818. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99819. * Otherwise, will use the fullscreen API.
  99820. */
  99821. enterVR(): void;
  99822. /**
  99823. * Attempt to exit VR, or fullscreen.
  99824. */
  99825. exitVR(): void;
  99826. /**
  99827. * The position of the vr experience helper.
  99828. */
  99829. /**
  99830. * Sets the position of the vr experience helper.
  99831. */
  99832. position: Vector3;
  99833. /**
  99834. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99835. */
  99836. enableInteractions(): void;
  99837. private readonly _noControllerIsActive;
  99838. private beforeRender;
  99839. private _isTeleportationFloor;
  99840. /**
  99841. * Adds a floor mesh to be used for teleportation.
  99842. * @param floorMesh the mesh to be used for teleportation.
  99843. */
  99844. addFloorMesh(floorMesh: Mesh): void;
  99845. /**
  99846. * Removes a floor mesh from being used for teleportation.
  99847. * @param floorMesh the mesh to be removed.
  99848. */
  99849. removeFloorMesh(floorMesh: Mesh): void;
  99850. /**
  99851. * Enables interactions and teleportation using the VR controllers and gaze.
  99852. * @param vrTeleportationOptions options to modify teleportation behavior.
  99853. */
  99854. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99855. private _onNewGamepadConnected;
  99856. private _tryEnableInteractionOnController;
  99857. private _onNewGamepadDisconnected;
  99858. private _enableInteractionOnController;
  99859. private _checkTeleportWithRay;
  99860. private _checkRotate;
  99861. private _checkTeleportBackwards;
  99862. private _enableTeleportationOnController;
  99863. private _createTeleportationCircles;
  99864. private _displayTeleportationTarget;
  99865. private _hideTeleportationTarget;
  99866. private _rotateCamera;
  99867. private _moveTeleportationSelectorTo;
  99868. private _workingVector;
  99869. private _workingQuaternion;
  99870. private _workingMatrix;
  99871. /**
  99872. * Teleports the users feet to the desired location
  99873. * @param location The location where the user's feet should be placed
  99874. */
  99875. teleportCamera(location: Vector3): void;
  99876. private _convertNormalToDirectionOfRay;
  99877. private _castRayAndSelectObject;
  99878. private _notifySelectedMeshUnselected;
  99879. /**
  99880. * Sets the color of the laser ray from the vr controllers.
  99881. * @param color new color for the ray.
  99882. */
  99883. changeLaserColor(color: Color3): void;
  99884. /**
  99885. * Sets the color of the ray from the vr headsets gaze.
  99886. * @param color new color for the ray.
  99887. */
  99888. changeGazeColor(color: Color3): void;
  99889. /**
  99890. * Exits VR and disposes of the vr experience helper
  99891. */
  99892. dispose(): void;
  99893. /**
  99894. * Gets the name of the VRExperienceHelper class
  99895. * @returns "VRExperienceHelper"
  99896. */
  99897. getClassName(): string;
  99898. }
  99899. }
  99900. declare module BABYLON {
  99901. /**
  99902. * Manages an XRSession
  99903. * @see https://doc.babylonjs.com/how_to/webxr
  99904. */
  99905. export class WebXRSessionManager implements IDisposable {
  99906. private scene;
  99907. /**
  99908. * Fires every time a new xrFrame arrives which can be used to update the camera
  99909. */
  99910. onXRFrameObservable: Observable<any>;
  99911. /**
  99912. * Fires when the xr session is ended either by the device or manually done
  99913. */
  99914. onXRSessionEnded: Observable<any>;
  99915. /** @hidden */
  99916. _xrSession: XRSession;
  99917. /** @hidden */
  99918. _frameOfReference: XRFrameOfReference;
  99919. /** @hidden */
  99920. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99921. /** @hidden */
  99922. _currentXRFrame: Nullable<XRFrame>;
  99923. private _xrNavigator;
  99924. private _xrDevice;
  99925. private _tmpMatrix;
  99926. /**
  99927. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99928. * @param scene The scene which the session should be created for
  99929. */
  99930. constructor(scene: Scene);
  99931. /**
  99932. * Initializes the manager
  99933. * After initialization enterXR can be called to start an XR session
  99934. * @returns Promise which resolves after it is initialized
  99935. */
  99936. initializeAsync(): Promise<void>;
  99937. /**
  99938. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99939. * @param sessionCreationOptions xr options to create the session with
  99940. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99941. * @returns Promise which resolves after it enters XR
  99942. */
  99943. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99944. /**
  99945. * Stops the xrSession and restores the renderloop
  99946. * @returns Promise which resolves after it exits XR
  99947. */
  99948. exitXRAsync(): Promise<void>;
  99949. /**
  99950. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99951. * @param ray ray to cast into the environment
  99952. * @returns Promise which resolves with a collision point in the environment if it exists
  99953. */
  99954. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99955. /**
  99956. * Checks if a session would be supported for the creation options specified
  99957. * @param options creation options to check if they are supported
  99958. * @returns true if supported
  99959. */
  99960. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99961. /**
  99962. * @hidden
  99963. * Converts the render layer of xrSession to a render target
  99964. * @param session session to create render target for
  99965. * @param scene scene the new render target should be created for
  99966. */
  99967. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99968. /**
  99969. * Disposes of the session manager
  99970. */
  99971. dispose(): void;
  99972. }
  99973. }
  99974. declare module BABYLON {
  99975. /**
  99976. * WebXR Camera which holds the views for the xrSession
  99977. * @see https://doc.babylonjs.com/how_to/webxr
  99978. */
  99979. export class WebXRCamera extends FreeCamera {
  99980. private static _TmpMatrix;
  99981. /**
  99982. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99983. * @param name the name of the camera
  99984. * @param scene the scene to add the camera to
  99985. */
  99986. constructor(name: string, scene: Scene);
  99987. private _updateNumberOfRigCameras;
  99988. /** @hidden */
  99989. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99990. /**
  99991. * Updates the cameras position from the current pose information of the XR session
  99992. * @param xrSessionManager the session containing pose information
  99993. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99994. */
  99995. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99996. }
  99997. }
  99998. declare module BABYLON {
  99999. /**
  100000. * States of the webXR experience
  100001. */
  100002. export enum WebXRState {
  100003. /**
  100004. * Transitioning to being in XR mode
  100005. */
  100006. ENTERING_XR = 0,
  100007. /**
  100008. * Transitioning to non XR mode
  100009. */
  100010. EXITING_XR = 1,
  100011. /**
  100012. * In XR mode and presenting
  100013. */
  100014. IN_XR = 2,
  100015. /**
  100016. * Not entered XR mode
  100017. */
  100018. NOT_IN_XR = 3
  100019. }
  100020. /**
  100021. * Helper class used to enable XR
  100022. * @see https://doc.babylonjs.com/how_to/webxr
  100023. */
  100024. export class WebXRExperienceHelper implements IDisposable {
  100025. private scene;
  100026. /**
  100027. * 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
  100028. */
  100029. container: AbstractMesh;
  100030. /**
  100031. * Camera used to render xr content
  100032. */
  100033. camera: WebXRCamera;
  100034. /**
  100035. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  100036. */
  100037. state: WebXRState;
  100038. private _setState;
  100039. private static _TmpVector;
  100040. /**
  100041. * Fires when the state of the experience helper has changed
  100042. */
  100043. onStateChangedObservable: Observable<WebXRState>;
  100044. /** @hidden */
  100045. _sessionManager: WebXRSessionManager;
  100046. private _nonVRCamera;
  100047. private _originalSceneAutoClear;
  100048. private _supported;
  100049. /**
  100050. * Creates the experience helper
  100051. * @param scene the scene to attach the experience helper to
  100052. * @returns a promise for the experience helper
  100053. */
  100054. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  100055. /**
  100056. * Creates a WebXRExperienceHelper
  100057. * @param scene The scene the helper should be created in
  100058. */
  100059. private constructor();
  100060. /**
  100061. * Exits XR mode and returns the scene to its original state
  100062. * @returns promise that resolves after xr mode has exited
  100063. */
  100064. exitXRAsync(): Promise<void>;
  100065. /**
  100066. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  100067. * @param sessionCreationOptions options for the XR session
  100068. * @param frameOfReference frame of reference of the XR session
  100069. * @returns promise that resolves after xr mode has entered
  100070. */
  100071. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  100072. /**
  100073. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100074. * @param ray ray to cast into the environment
  100075. * @returns Promise which resolves with a collision point in the environment if it exists
  100076. */
  100077. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100078. /**
  100079. * Updates the global position of the camera by moving the camera's container
  100080. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  100081. * @param position The desired global position of the camera
  100082. */
  100083. setPositionOfCameraUsingContainer(position: Vector3): void;
  100084. /**
  100085. * Rotates the xr camera by rotating the camera's container around the camera's position
  100086. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  100087. * @param rotation the desired quaternion rotation to apply to the camera
  100088. */
  100089. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  100090. /**
  100091. * Checks if the creation options are supported by the xr session
  100092. * @param options creation options
  100093. * @returns true if supported
  100094. */
  100095. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100096. /**
  100097. * Disposes of the experience helper
  100098. */
  100099. dispose(): void;
  100100. }
  100101. }
  100102. declare module BABYLON {
  100103. /**
  100104. * Button which can be used to enter a different mode of XR
  100105. */
  100106. export class WebXREnterExitUIButton {
  100107. /** button element */
  100108. element: HTMLElement;
  100109. /** XR initialization options for the button */
  100110. initializationOptions: XRSessionCreationOptions;
  100111. /**
  100112. * Creates a WebXREnterExitUIButton
  100113. * @param element button element
  100114. * @param initializationOptions XR initialization options for the button
  100115. */
  100116. constructor(
  100117. /** button element */
  100118. element: HTMLElement,
  100119. /** XR initialization options for the button */
  100120. initializationOptions: XRSessionCreationOptions);
  100121. /**
  100122. * Overwritable function which can be used to update the button's visuals when the state changes
  100123. * @param activeButton the current active button in the UI
  100124. */
  100125. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  100126. }
  100127. /**
  100128. * Options to create the webXR UI
  100129. */
  100130. export class WebXREnterExitUIOptions {
  100131. /**
  100132. * Context to enter xr with
  100133. */
  100134. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  100135. /**
  100136. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  100137. */
  100138. customButtons?: Array<WebXREnterExitUIButton>;
  100139. }
  100140. /**
  100141. * UI to allow the user to enter/exit XR mode
  100142. */
  100143. export class WebXREnterExitUI implements IDisposable {
  100144. private scene;
  100145. private _overlay;
  100146. private _buttons;
  100147. private _activeButton;
  100148. /**
  100149. * Fired every time the active button is changed.
  100150. *
  100151. * When xr is entered via a button that launches xr that button will be the callback parameter
  100152. *
  100153. * When exiting xr the callback parameter will be null)
  100154. */
  100155. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  100156. /**
  100157. * Creates UI to allow the user to enter/exit XR mode
  100158. * @param scene the scene to add the ui to
  100159. * @param helper the xr experience helper to enter/exit xr with
  100160. * @param options options to configure the UI
  100161. * @returns the created ui
  100162. */
  100163. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  100164. private constructor();
  100165. private _updateButtons;
  100166. /**
  100167. * Disposes of the object
  100168. */
  100169. dispose(): void;
  100170. }
  100171. }
  100172. declare module BABYLON {
  100173. /**
  100174. * Represents an XR input
  100175. */
  100176. export class WebXRController {
  100177. /**
  100178. * 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
  100179. */
  100180. grip?: AbstractMesh;
  100181. /**
  100182. * Pointer which can be used to select objects or attach a visible laser to
  100183. */
  100184. pointer: AbstractMesh;
  100185. /**
  100186. * Creates the controller
  100187. * @see https://doc.babylonjs.com/how_to/webxr
  100188. * @param scene the scene which the controller should be associated to
  100189. */
  100190. constructor(scene: Scene);
  100191. /**
  100192. * Disposes of the object
  100193. */
  100194. dispose(): void;
  100195. }
  100196. /**
  100197. * XR input used to track XR inputs such as controllers/rays
  100198. */
  100199. export class WebXRInput implements IDisposable {
  100200. private helper;
  100201. /**
  100202. * XR controllers being tracked
  100203. */
  100204. controllers: Array<WebXRController>;
  100205. private _tmpMatrix;
  100206. private _frameObserver;
  100207. /**
  100208. * Initializes the WebXRInput
  100209. * @param helper experience helper which the input should be created for
  100210. */
  100211. constructor(helper: WebXRExperienceHelper);
  100212. /**
  100213. * Disposes of the object
  100214. */
  100215. dispose(): void;
  100216. }
  100217. }
  100218. declare module BABYLON {
  100219. /**
  100220. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  100221. */
  100222. export class WebXRManagedOutputCanvas implements IDisposable {
  100223. private _canvas;
  100224. /**
  100225. * xrpresent context of the canvas which can be used to display/mirror xr content
  100226. */
  100227. canvasContext: Nullable<WebGLRenderingContext>;
  100228. /**
  100229. * Initializes the canvas to be added/removed upon entering/exiting xr
  100230. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  100231. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  100232. */
  100233. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  100234. /**
  100235. * Disposes of the object
  100236. */
  100237. dispose(): void;
  100238. private _setManagedOutputCanvas;
  100239. private _addCanvas;
  100240. private _removeCanvas;
  100241. }
  100242. }
  100243. declare module BABYLON {
  100244. /**
  100245. * Contains an array of blocks representing the octree
  100246. */
  100247. export interface IOctreeContainer<T> {
  100248. /**
  100249. * Blocks within the octree
  100250. */
  100251. blocks: Array<OctreeBlock<T>>;
  100252. }
  100253. /**
  100254. * Class used to store a cell in an octree
  100255. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100256. */
  100257. export class OctreeBlock<T> {
  100258. /**
  100259. * Gets the content of the current block
  100260. */
  100261. entries: T[];
  100262. /**
  100263. * Gets the list of block children
  100264. */
  100265. blocks: Array<OctreeBlock<T>>;
  100266. private _depth;
  100267. private _maxDepth;
  100268. private _capacity;
  100269. private _minPoint;
  100270. private _maxPoint;
  100271. private _boundingVectors;
  100272. private _creationFunc;
  100273. /**
  100274. * Creates a new block
  100275. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  100276. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  100277. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100278. * @param depth defines the current depth of this block in the octree
  100279. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  100280. * @param creationFunc defines a callback to call when an element is added to the block
  100281. */
  100282. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  100283. /**
  100284. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100285. */
  100286. readonly capacity: number;
  100287. /**
  100288. * Gets the minimum vector (in world space) of the block's bounding box
  100289. */
  100290. readonly minPoint: Vector3;
  100291. /**
  100292. * Gets the maximum vector (in world space) of the block's bounding box
  100293. */
  100294. readonly maxPoint: Vector3;
  100295. /**
  100296. * Add a new element to this block
  100297. * @param entry defines the element to add
  100298. */
  100299. addEntry(entry: T): void;
  100300. /**
  100301. * Remove an element from this block
  100302. * @param entry defines the element to remove
  100303. */
  100304. removeEntry(entry: T): void;
  100305. /**
  100306. * Add an array of elements to this block
  100307. * @param entries defines the array of elements to add
  100308. */
  100309. addEntries(entries: T[]): void;
  100310. /**
  100311. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  100312. * @param frustumPlanes defines the frustum planes to test
  100313. * @param selection defines the array to store current content if selection is positive
  100314. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100315. */
  100316. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100317. /**
  100318. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  100319. * @param sphereCenter defines the bounding sphere center
  100320. * @param sphereRadius defines the bounding sphere radius
  100321. * @param selection defines the array to store current content if selection is positive
  100322. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100323. */
  100324. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100325. /**
  100326. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  100327. * @param ray defines the ray to test with
  100328. * @param selection defines the array to store current content if selection is positive
  100329. */
  100330. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  100331. /**
  100332. * Subdivide the content into child blocks (this block will then be empty)
  100333. */
  100334. createInnerBlocks(): void;
  100335. /**
  100336. * @hidden
  100337. */
  100338. 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;
  100339. }
  100340. }
  100341. declare module BABYLON {
  100342. /**
  100343. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  100344. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100345. */
  100346. export class Octree<T> {
  100347. /** 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.) */
  100348. maxDepth: number;
  100349. /**
  100350. * Blocks within the octree containing objects
  100351. */
  100352. blocks: Array<OctreeBlock<T>>;
  100353. /**
  100354. * Content stored in the octree
  100355. */
  100356. dynamicContent: T[];
  100357. private _maxBlockCapacity;
  100358. private _selectionContent;
  100359. private _creationFunc;
  100360. /**
  100361. * Creates a octree
  100362. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100363. * @param creationFunc function to be used to instatiate the octree
  100364. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  100365. * @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.)
  100366. */
  100367. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  100368. /** 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. maxDepth?: number);
  100370. /**
  100371. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  100372. * @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);
  100373. * @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);
  100374. * @param entries meshes to be added to the octree blocks
  100375. */
  100376. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  100377. /**
  100378. * Adds a mesh to the octree
  100379. * @param entry Mesh to add to the octree
  100380. */
  100381. addMesh(entry: T): void;
  100382. /**
  100383. * Remove an element from the octree
  100384. * @param entry defines the element to remove
  100385. */
  100386. removeMesh(entry: T): void;
  100387. /**
  100388. * Selects an array of meshes within the frustum
  100389. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  100390. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  100391. * @returns array of meshes within the frustum
  100392. */
  100393. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  100394. /**
  100395. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  100396. * @param sphereCenter defines the bounding sphere center
  100397. * @param sphereRadius defines the bounding sphere radius
  100398. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100399. * @returns an array of objects that intersect the sphere
  100400. */
  100401. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  100402. /**
  100403. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  100404. * @param ray defines the ray to test with
  100405. * @returns array of intersected objects
  100406. */
  100407. intersectsRay(ray: Ray): SmartArray<T>;
  100408. /**
  100409. * Adds a mesh into the octree block if it intersects the block
  100410. */
  100411. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  100412. /**
  100413. * Adds a submesh into the octree block if it intersects the block
  100414. */
  100415. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  100416. }
  100417. }
  100418. declare module BABYLON {
  100419. interface Scene {
  100420. /**
  100421. * @hidden
  100422. * Backing Filed
  100423. */
  100424. _selectionOctree: Octree<AbstractMesh>;
  100425. /**
  100426. * Gets the octree used to boost mesh selection (picking)
  100427. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100428. */
  100429. selectionOctree: Octree<AbstractMesh>;
  100430. /**
  100431. * Creates or updates the octree used to boost selection (picking)
  100432. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100433. * @param maxCapacity defines the maximum capacity per leaf
  100434. * @param maxDepth defines the maximum depth of the octree
  100435. * @returns an octree of AbstractMesh
  100436. */
  100437. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  100438. }
  100439. interface AbstractMesh {
  100440. /**
  100441. * @hidden
  100442. * Backing Field
  100443. */
  100444. _submeshesOctree: Octree<SubMesh>;
  100445. /**
  100446. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  100447. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  100448. * @param maxCapacity defines the maximum size of each block (64 by default)
  100449. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  100450. * @returns the new octree
  100451. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  100452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100453. */
  100454. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  100455. }
  100456. /**
  100457. * Defines the octree scene component responsible to manage any octrees
  100458. * in a given scene.
  100459. */
  100460. export class OctreeSceneComponent {
  100461. /**
  100462. * The component name help to identify the component in the list of scene components.
  100463. */
  100464. readonly name: string;
  100465. /**
  100466. * The scene the component belongs to.
  100467. */
  100468. scene: Scene;
  100469. /**
  100470. * Indicates if the meshes have been checked to make sure they are isEnabled()
  100471. */
  100472. readonly checksIsEnabled: boolean;
  100473. /**
  100474. * Creates a new instance of the component for the given scene
  100475. * @param scene Defines the scene to register the component in
  100476. */
  100477. constructor(scene: Scene);
  100478. /**
  100479. * Registers the component in a given scene
  100480. */
  100481. register(): void;
  100482. /**
  100483. * Return the list of active meshes
  100484. * @returns the list of active meshes
  100485. */
  100486. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100487. /**
  100488. * Return the list of active sub meshes
  100489. * @param mesh The mesh to get the candidates sub meshes from
  100490. * @returns the list of active sub meshes
  100491. */
  100492. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100493. private _tempRay;
  100494. /**
  100495. * Return the list of sub meshes intersecting with a given local ray
  100496. * @param mesh defines the mesh to find the submesh for
  100497. * @param localRay defines the ray in local space
  100498. * @returns the list of intersecting sub meshes
  100499. */
  100500. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  100501. /**
  100502. * Return the list of sub meshes colliding with a collider
  100503. * @param mesh defines the mesh to find the submesh for
  100504. * @param collider defines the collider to evaluate the collision against
  100505. * @returns the list of colliding sub meshes
  100506. */
  100507. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  100508. /**
  100509. * Rebuilds the elements related to this component in case of
  100510. * context lost for instance.
  100511. */
  100512. rebuild(): void;
  100513. /**
  100514. * Disposes the component and the associated ressources.
  100515. */
  100516. dispose(): void;
  100517. }
  100518. }
  100519. declare module BABYLON {
  100520. /**
  100521. * Renders a layer on top of an existing scene
  100522. */
  100523. export class UtilityLayerRenderer implements IDisposable {
  100524. /** the original scene that will be rendered on top of */
  100525. originalScene: Scene;
  100526. private _pointerCaptures;
  100527. private _lastPointerEvents;
  100528. private static _DefaultUtilityLayer;
  100529. private static _DefaultKeepDepthUtilityLayer;
  100530. private _sharedGizmoLight;
  100531. /**
  100532. * @hidden
  100533. * Light which used by gizmos to get light shading
  100534. */
  100535. _getSharedGizmoLight(): HemisphericLight;
  100536. /**
  100537. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100538. */
  100539. pickUtilitySceneFirst: boolean;
  100540. /**
  100541. * 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)
  100542. */
  100543. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100544. /**
  100545. * 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)
  100546. */
  100547. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100548. /**
  100549. * The scene that is rendered on top of the original scene
  100550. */
  100551. utilityLayerScene: Scene;
  100552. /**
  100553. * If the utility layer should automatically be rendered on top of existing scene
  100554. */
  100555. shouldRender: boolean;
  100556. /**
  100557. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100558. */
  100559. onlyCheckPointerDownEvents: boolean;
  100560. /**
  100561. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100562. */
  100563. processAllEvents: boolean;
  100564. /**
  100565. * Observable raised when the pointer move from the utility layer scene to the main scene
  100566. */
  100567. onPointerOutObservable: Observable<number>;
  100568. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100569. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100570. private _afterRenderObserver;
  100571. private _sceneDisposeObserver;
  100572. private _originalPointerObserver;
  100573. /**
  100574. * Instantiates a UtilityLayerRenderer
  100575. * @param originalScene the original scene that will be rendered on top of
  100576. * @param handleEvents boolean indicating if the utility layer should handle events
  100577. */
  100578. constructor(
  100579. /** the original scene that will be rendered on top of */
  100580. originalScene: Scene, handleEvents?: boolean);
  100581. private _notifyObservers;
  100582. /**
  100583. * Renders the utility layers scene on top of the original scene
  100584. */
  100585. render(): void;
  100586. /**
  100587. * Disposes of the renderer
  100588. */
  100589. dispose(): void;
  100590. private _updateCamera;
  100591. }
  100592. }
  100593. declare module BABYLON {
  100594. /**
  100595. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100596. */
  100597. export class Gizmo implements IDisposable {
  100598. /** The utility layer the gizmo will be added to */
  100599. gizmoLayer: UtilityLayerRenderer;
  100600. /**
  100601. * The root mesh of the gizmo
  100602. */
  100603. _rootMesh: Mesh;
  100604. private _attachedMesh;
  100605. /**
  100606. * Ratio for the scale of the gizmo (Default: 1)
  100607. */
  100608. scaleRatio: number;
  100609. /**
  100610. * If a custom mesh has been set (Default: false)
  100611. */
  100612. protected _customMeshSet: boolean;
  100613. /**
  100614. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100615. * * When set, interactions will be enabled
  100616. */
  100617. attachedMesh: Nullable<AbstractMesh>;
  100618. /**
  100619. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100620. * @param mesh The mesh to replace the default mesh of the gizmo
  100621. */
  100622. setCustomMesh(mesh: Mesh): void;
  100623. /**
  100624. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100625. */
  100626. updateGizmoRotationToMatchAttachedMesh: boolean;
  100627. /**
  100628. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100629. */
  100630. updateGizmoPositionToMatchAttachedMesh: boolean;
  100631. /**
  100632. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100633. */
  100634. protected _updateScale: boolean;
  100635. protected _interactionsEnabled: boolean;
  100636. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100637. private _beforeRenderObserver;
  100638. private _tempVector;
  100639. /**
  100640. * Creates a gizmo
  100641. * @param gizmoLayer The utility layer the gizmo will be added to
  100642. */
  100643. constructor(
  100644. /** The utility layer the gizmo will be added to */
  100645. gizmoLayer?: UtilityLayerRenderer);
  100646. /**
  100647. * Updates the gizmo to match the attached mesh's position/rotation
  100648. */
  100649. protected _update(): void;
  100650. /**
  100651. * Disposes of the gizmo
  100652. */
  100653. dispose(): void;
  100654. }
  100655. }
  100656. declare module BABYLON {
  100657. /**
  100658. * Single axis drag gizmo
  100659. */
  100660. export class AxisDragGizmo extends Gizmo {
  100661. /**
  100662. * Drag behavior responsible for the gizmos dragging interactions
  100663. */
  100664. dragBehavior: PointerDragBehavior;
  100665. private _pointerObserver;
  100666. /**
  100667. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100668. */
  100669. snapDistance: number;
  100670. /**
  100671. * Event that fires each time the gizmo snaps to a new location.
  100672. * * snapDistance is the the change in distance
  100673. */
  100674. onSnapObservable: Observable<{
  100675. snapDistance: number;
  100676. }>;
  100677. /** @hidden */
  100678. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100679. /** @hidden */
  100680. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100681. /**
  100682. * Creates an AxisDragGizmo
  100683. * @param gizmoLayer The utility layer the gizmo will be added to
  100684. * @param dragAxis The axis which the gizmo will be able to drag on
  100685. * @param color The color of the gizmo
  100686. */
  100687. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100688. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100689. /**
  100690. * Disposes of the gizmo
  100691. */
  100692. dispose(): void;
  100693. }
  100694. }
  100695. declare module BABYLON.Debug {
  100696. /**
  100697. * The Axes viewer will show 3 axes in a specific point in space
  100698. */
  100699. export class AxesViewer {
  100700. private _xAxis;
  100701. private _yAxis;
  100702. private _zAxis;
  100703. private _scaleLinesFactor;
  100704. private _instanced;
  100705. /**
  100706. * Gets the hosting scene
  100707. */
  100708. scene: Scene;
  100709. /**
  100710. * Gets or sets a number used to scale line length
  100711. */
  100712. scaleLines: number;
  100713. /** Gets the node hierarchy used to render x-axis */
  100714. readonly xAxis: TransformNode;
  100715. /** Gets the node hierarchy used to render y-axis */
  100716. readonly yAxis: TransformNode;
  100717. /** Gets the node hierarchy used to render z-axis */
  100718. readonly zAxis: TransformNode;
  100719. /**
  100720. * Creates a new AxesViewer
  100721. * @param scene defines the hosting scene
  100722. * @param scaleLines defines a number used to scale line length (1 by default)
  100723. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100724. * @param xAxis defines the node hierarchy used to render the x-axis
  100725. * @param yAxis defines the node hierarchy used to render the y-axis
  100726. * @param zAxis defines the node hierarchy used to render the z-axis
  100727. */
  100728. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100729. /**
  100730. * Force the viewer to update
  100731. * @param position defines the position of the viewer
  100732. * @param xaxis defines the x axis of the viewer
  100733. * @param yaxis defines the y axis of the viewer
  100734. * @param zaxis defines the z axis of the viewer
  100735. */
  100736. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100737. /**
  100738. * Creates an instance of this axes viewer.
  100739. * @returns a new axes viewer with instanced meshes
  100740. */
  100741. createInstance(): AxesViewer;
  100742. /** Releases resources */
  100743. dispose(): void;
  100744. private static _SetRenderingGroupId;
  100745. }
  100746. }
  100747. declare module BABYLON.Debug {
  100748. /**
  100749. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100750. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100751. */
  100752. export class BoneAxesViewer extends AxesViewer {
  100753. /**
  100754. * Gets or sets the target mesh where to display the axes viewer
  100755. */
  100756. mesh: Nullable<Mesh>;
  100757. /**
  100758. * Gets or sets the target bone where to display the axes viewer
  100759. */
  100760. bone: Nullable<Bone>;
  100761. /** Gets current position */
  100762. pos: Vector3;
  100763. /** Gets direction of X axis */
  100764. xaxis: Vector3;
  100765. /** Gets direction of Y axis */
  100766. yaxis: Vector3;
  100767. /** Gets direction of Z axis */
  100768. zaxis: Vector3;
  100769. /**
  100770. * Creates a new BoneAxesViewer
  100771. * @param scene defines the hosting scene
  100772. * @param bone defines the target bone
  100773. * @param mesh defines the target mesh
  100774. * @param scaleLines defines a scaling factor for line length (1 by default)
  100775. */
  100776. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100777. /**
  100778. * Force the viewer to update
  100779. */
  100780. update(): void;
  100781. /** Releases resources */
  100782. dispose(): void;
  100783. }
  100784. }
  100785. declare module BABYLON {
  100786. /**
  100787. * Interface used to define scene explorer extensibility option
  100788. */
  100789. export interface IExplorerExtensibilityOption {
  100790. /**
  100791. * Define the option label
  100792. */
  100793. label: string;
  100794. /**
  100795. * Defines the action to execute on click
  100796. */
  100797. action: (entity: any) => void;
  100798. }
  100799. /**
  100800. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100801. */
  100802. export interface IExplorerExtensibilityGroup {
  100803. /**
  100804. * Defines a predicate to test if a given type mut be extended
  100805. */
  100806. predicate: (entity: any) => boolean;
  100807. /**
  100808. * Gets the list of options added to a type
  100809. */
  100810. entries: IExplorerExtensibilityOption[];
  100811. }
  100812. /**
  100813. * Interface used to define the options to use to create the Inspector
  100814. */
  100815. export interface IInspectorOptions {
  100816. /**
  100817. * Display in overlay mode (default: false)
  100818. */
  100819. overlay?: boolean;
  100820. /**
  100821. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100822. */
  100823. globalRoot?: HTMLElement;
  100824. /**
  100825. * Display the Scene explorer
  100826. */
  100827. showExplorer?: boolean;
  100828. /**
  100829. * Display the property inspector
  100830. */
  100831. showInspector?: boolean;
  100832. /**
  100833. * Display in embed mode (both panes on the right)
  100834. */
  100835. embedMode?: boolean;
  100836. /**
  100837. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100838. */
  100839. handleResize?: boolean;
  100840. /**
  100841. * Allow the panes to popup (default: true)
  100842. */
  100843. enablePopup?: boolean;
  100844. /**
  100845. * Allow the panes to be closed by users (default: true)
  100846. */
  100847. enableClose?: boolean;
  100848. /**
  100849. * Optional list of extensibility entries
  100850. */
  100851. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100852. /**
  100853. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100854. */
  100855. inspectorURL?: string;
  100856. }
  100857. interface Scene {
  100858. /**
  100859. * @hidden
  100860. * Backing field
  100861. */
  100862. _debugLayer: DebugLayer;
  100863. /**
  100864. * Gets the debug layer (aka Inspector) associated with the scene
  100865. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100866. */
  100867. debugLayer: DebugLayer;
  100868. }
  100869. /**
  100870. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100871. * what is happening in your scene
  100872. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100873. */
  100874. export class DebugLayer {
  100875. /**
  100876. * Define the url to get the inspector script from.
  100877. * By default it uses the babylonjs CDN.
  100878. * @ignoreNaming
  100879. */
  100880. static InspectorURL: string;
  100881. private _scene;
  100882. private BJSINSPECTOR;
  100883. /**
  100884. * Observable triggered when a property is changed through the inspector.
  100885. */
  100886. onPropertyChangedObservable: Observable<{
  100887. object: any;
  100888. property: string;
  100889. value: any;
  100890. initialValue: any;
  100891. }>;
  100892. /**
  100893. * Instantiates a new debug layer.
  100894. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100895. * what is happening in your scene
  100896. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100897. * @param scene Defines the scene to inspect
  100898. */
  100899. constructor(scene: Scene);
  100900. /** Creates the inspector window. */
  100901. private _createInspector;
  100902. /**
  100903. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100904. * @param entity defines the entity to select
  100905. * @param lineContainerTitle defines the specific block to highlight
  100906. */
  100907. select(entity: any, lineContainerTitle?: string): void;
  100908. /** Get the inspector from bundle or global */
  100909. private _getGlobalInspector;
  100910. /**
  100911. * Get if the inspector is visible or not.
  100912. * @returns true if visible otherwise, false
  100913. */
  100914. isVisible(): boolean;
  100915. /**
  100916. * Hide the inspector and close its window.
  100917. */
  100918. hide(): void;
  100919. /**
  100920. * Launch the debugLayer.
  100921. * @param config Define the configuration of the inspector
  100922. * @return a promise fulfilled when the debug layer is visible
  100923. */
  100924. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100925. }
  100926. }
  100927. declare module BABYLON {
  100928. /**
  100929. * Class containing static functions to help procedurally build meshes
  100930. */
  100931. export class BoxBuilder {
  100932. /**
  100933. * Creates a box mesh
  100934. * * The parameter `size` sets the size (float) of each box side (default 1)
  100935. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100936. * * 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)
  100937. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100941. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100942. * @param name defines the name of the mesh
  100943. * @param options defines the options used to create the mesh
  100944. * @param scene defines the hosting scene
  100945. * @returns the box mesh
  100946. */
  100947. static CreateBox(name: string, options: {
  100948. size?: number;
  100949. width?: number;
  100950. height?: number;
  100951. depth?: number;
  100952. faceUV?: Vector4[];
  100953. faceColors?: Color4[];
  100954. sideOrientation?: number;
  100955. frontUVs?: Vector4;
  100956. backUVs?: Vector4;
  100957. wrap?: boolean;
  100958. topBaseAt?: number;
  100959. bottomBaseAt?: number;
  100960. updatable?: boolean;
  100961. }, scene?: Nullable<Scene>): Mesh;
  100962. }
  100963. }
  100964. declare module BABYLON {
  100965. /**
  100966. * Class containing static functions to help procedurally build meshes
  100967. */
  100968. export class SphereBuilder {
  100969. /**
  100970. * Creates a sphere mesh
  100971. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100972. * * 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`)
  100973. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100974. * * 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
  100975. * * 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)
  100976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100979. * @param name defines the name of the mesh
  100980. * @param options defines the options used to create the mesh
  100981. * @param scene defines the hosting scene
  100982. * @returns the sphere mesh
  100983. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100984. */
  100985. static CreateSphere(name: string, options: {
  100986. segments?: number;
  100987. diameter?: number;
  100988. diameterX?: number;
  100989. diameterY?: number;
  100990. diameterZ?: number;
  100991. arc?: number;
  100992. slice?: number;
  100993. sideOrientation?: number;
  100994. frontUVs?: Vector4;
  100995. backUVs?: Vector4;
  100996. updatable?: boolean;
  100997. }, scene: any): Mesh;
  100998. }
  100999. }
  101000. declare module BABYLON.Debug {
  101001. /**
  101002. * Used to show the physics impostor around the specific mesh
  101003. */
  101004. export class PhysicsViewer {
  101005. /** @hidden */
  101006. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  101007. /** @hidden */
  101008. protected _meshes: Array<Nullable<AbstractMesh>>;
  101009. /** @hidden */
  101010. protected _scene: Nullable<Scene>;
  101011. /** @hidden */
  101012. protected _numMeshes: number;
  101013. /** @hidden */
  101014. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  101015. private _renderFunction;
  101016. private _utilityLayer;
  101017. private _debugBoxMesh;
  101018. private _debugSphereMesh;
  101019. private _debugCylinderMesh;
  101020. private _debugMaterial;
  101021. private _debugMeshMeshes;
  101022. /**
  101023. * Creates a new PhysicsViewer
  101024. * @param scene defines the hosting scene
  101025. */
  101026. constructor(scene: Scene);
  101027. /** @hidden */
  101028. protected _updateDebugMeshes(): void;
  101029. /**
  101030. * Renders a specified physic impostor
  101031. * @param impostor defines the impostor to render
  101032. * @param targetMesh defines the mesh represented by the impostor
  101033. * @returns the new debug mesh used to render the impostor
  101034. */
  101035. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  101036. /**
  101037. * Hides a specified physic impostor
  101038. * @param impostor defines the impostor to hide
  101039. */
  101040. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  101041. private _getDebugMaterial;
  101042. private _getDebugBoxMesh;
  101043. private _getDebugSphereMesh;
  101044. private _getDebugCylinderMesh;
  101045. private _getDebugMeshMesh;
  101046. private _getDebugMesh;
  101047. /** Releases all resources */
  101048. dispose(): void;
  101049. }
  101050. }
  101051. declare module BABYLON {
  101052. /**
  101053. * Class containing static functions to help procedurally build meshes
  101054. */
  101055. export class LinesBuilder {
  101056. /**
  101057. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  101058. * * 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
  101059. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  101060. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  101061. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  101062. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  101063. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  101064. * * 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
  101065. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  101066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101067. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  101068. * @param name defines the name of the new line system
  101069. * @param options defines the options used to create the line system
  101070. * @param scene defines the hosting scene
  101071. * @returns a new line system mesh
  101072. */
  101073. static CreateLineSystem(name: string, options: {
  101074. lines: Vector3[][];
  101075. updatable?: boolean;
  101076. instance?: Nullable<LinesMesh>;
  101077. colors?: Nullable<Color4[][]>;
  101078. useVertexAlpha?: boolean;
  101079. }, scene: Nullable<Scene>): LinesMesh;
  101080. /**
  101081. * Creates a line mesh
  101082. * 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
  101083. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101084. * * The parameter `points` is an array successive Vector3
  101085. * * 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
  101086. * * The optional parameter `colors` is an array of successive Color4, one per line point
  101087. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  101088. * * When updating an instance, remember that only point positions can change, not the number of points
  101089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101090. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  101091. * @param name defines the name of the new line system
  101092. * @param options defines the options used to create the line system
  101093. * @param scene defines the hosting scene
  101094. * @returns a new line mesh
  101095. */
  101096. static CreateLines(name: string, options: {
  101097. points: Vector3[];
  101098. updatable?: boolean;
  101099. instance?: Nullable<LinesMesh>;
  101100. colors?: Color4[];
  101101. useVertexAlpha?: boolean;
  101102. }, scene?: Nullable<Scene>): LinesMesh;
  101103. /**
  101104. * Creates a dashed line mesh
  101105. * * 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
  101106. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101107. * * The parameter `points` is an array successive Vector3
  101108. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  101109. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  101110. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101111. * * 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
  101112. * * When updating an instance, remember that only point positions can change, not the number of points
  101113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101114. * @param name defines the name of the mesh
  101115. * @param options defines the options used to create the mesh
  101116. * @param scene defines the hosting scene
  101117. * @returns the dashed line mesh
  101118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  101119. */
  101120. static CreateDashedLines(name: string, options: {
  101121. points: Vector3[];
  101122. dashSize?: number;
  101123. gapSize?: number;
  101124. dashNb?: number;
  101125. updatable?: boolean;
  101126. instance?: LinesMesh;
  101127. }, scene?: Nullable<Scene>): LinesMesh;
  101128. }
  101129. }
  101130. declare module BABYLON {
  101131. /**
  101132. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101133. * in order to better appreciate the issue one might have.
  101134. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101135. */
  101136. export class RayHelper {
  101137. /**
  101138. * Defines the ray we are currently tryin to visualize.
  101139. */
  101140. ray: Nullable<Ray>;
  101141. private _renderPoints;
  101142. private _renderLine;
  101143. private _renderFunction;
  101144. private _scene;
  101145. private _updateToMeshFunction;
  101146. private _attachedToMesh;
  101147. private _meshSpaceDirection;
  101148. private _meshSpaceOrigin;
  101149. /**
  101150. * Helper function to create a colored helper in a scene in one line.
  101151. * @param ray Defines the ray we are currently tryin to visualize
  101152. * @param scene Defines the scene the ray is used in
  101153. * @param color Defines the color we want to see the ray in
  101154. * @returns The newly created ray helper.
  101155. */
  101156. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  101157. /**
  101158. * Instantiate a new ray helper.
  101159. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101160. * in order to better appreciate the issue one might have.
  101161. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101162. * @param ray Defines the ray we are currently tryin to visualize
  101163. */
  101164. constructor(ray: Ray);
  101165. /**
  101166. * Shows the ray we are willing to debug.
  101167. * @param scene Defines the scene the ray needs to be rendered in
  101168. * @param color Defines the color the ray needs to be rendered in
  101169. */
  101170. show(scene: Scene, color?: Color3): void;
  101171. /**
  101172. * Hides the ray we are debugging.
  101173. */
  101174. hide(): void;
  101175. private _render;
  101176. /**
  101177. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  101178. * @param mesh Defines the mesh we want the helper attached to
  101179. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  101180. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  101181. * @param length Defines the length of the ray
  101182. */
  101183. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  101184. /**
  101185. * Detach the ray helper from the mesh it has previously been attached to.
  101186. */
  101187. detachFromMesh(): void;
  101188. private _updateToMesh;
  101189. /**
  101190. * Dispose the helper and release its associated resources.
  101191. */
  101192. dispose(): void;
  101193. }
  101194. }
  101195. declare module BABYLON.Debug {
  101196. /**
  101197. * Class used to render a debug view of a given skeleton
  101198. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  101199. */
  101200. export class SkeletonViewer {
  101201. /** defines the skeleton to render */
  101202. skeleton: Skeleton;
  101203. /** defines the mesh attached to the skeleton */
  101204. mesh: AbstractMesh;
  101205. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101206. autoUpdateBonesMatrices: boolean;
  101207. /** defines the rendering group id to use with the viewer */
  101208. renderingGroupId: number;
  101209. /** Gets or sets the color used to render the skeleton */
  101210. color: Color3;
  101211. private _scene;
  101212. private _debugLines;
  101213. private _debugMesh;
  101214. private _isEnabled;
  101215. private _renderFunction;
  101216. private _utilityLayer;
  101217. /**
  101218. * Returns the mesh used to render the bones
  101219. */
  101220. readonly debugMesh: Nullable<LinesMesh>;
  101221. /**
  101222. * Creates a new SkeletonViewer
  101223. * @param skeleton defines the skeleton to render
  101224. * @param mesh defines the mesh attached to the skeleton
  101225. * @param scene defines the hosting scene
  101226. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  101227. * @param renderingGroupId defines the rendering group id to use with the viewer
  101228. */
  101229. constructor(
  101230. /** defines the skeleton to render */
  101231. skeleton: Skeleton,
  101232. /** defines the mesh attached to the skeleton */
  101233. mesh: AbstractMesh, scene: Scene,
  101234. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101235. autoUpdateBonesMatrices?: boolean,
  101236. /** defines the rendering group id to use with the viewer */
  101237. renderingGroupId?: number);
  101238. /** Gets or sets a boolean indicating if the viewer is enabled */
  101239. isEnabled: boolean;
  101240. private _getBonePosition;
  101241. private _getLinesForBonesWithLength;
  101242. private _getLinesForBonesNoLength;
  101243. /** Update the viewer to sync with current skeleton state */
  101244. update(): void;
  101245. /** Release associated resources */
  101246. dispose(): void;
  101247. }
  101248. }
  101249. declare module BABYLON {
  101250. /**
  101251. * Options to create the null engine
  101252. */
  101253. export class NullEngineOptions {
  101254. /**
  101255. * Render width (Default: 512)
  101256. */
  101257. renderWidth: number;
  101258. /**
  101259. * Render height (Default: 256)
  101260. */
  101261. renderHeight: number;
  101262. /**
  101263. * Texture size (Default: 512)
  101264. */
  101265. textureSize: number;
  101266. /**
  101267. * If delta time between frames should be constant
  101268. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101269. */
  101270. deterministicLockstep: boolean;
  101271. /**
  101272. * Maximum about of steps between frames (Default: 4)
  101273. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101274. */
  101275. lockstepMaxSteps: number;
  101276. }
  101277. /**
  101278. * The null engine class provides support for headless version of babylon.js.
  101279. * This can be used in server side scenario or for testing purposes
  101280. */
  101281. export class NullEngine extends Engine {
  101282. private _options;
  101283. /**
  101284. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101285. */
  101286. isDeterministicLockStep(): boolean;
  101287. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  101288. getLockstepMaxSteps(): number;
  101289. /**
  101290. * Sets hardware scaling, used to save performance if needed
  101291. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101292. */
  101293. getHardwareScalingLevel(): number;
  101294. constructor(options?: NullEngineOptions);
  101295. createVertexBuffer(vertices: FloatArray): DataBuffer;
  101296. createIndexBuffer(indices: IndicesArray): DataBuffer;
  101297. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101298. getRenderWidth(useScreen?: boolean): number;
  101299. getRenderHeight(useScreen?: boolean): number;
  101300. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  101301. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  101302. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101303. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101304. bindSamplers(effect: Effect): void;
  101305. enableEffect(effect: Effect): void;
  101306. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101307. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  101308. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  101309. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  101310. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  101311. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  101312. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  101313. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  101314. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  101315. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  101316. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  101317. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  101318. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  101319. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  101320. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  101321. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101322. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101323. setFloat(uniform: WebGLUniformLocation, value: number): void;
  101324. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  101325. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  101326. setBool(uniform: WebGLUniformLocation, bool: number): void;
  101327. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  101328. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  101329. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  101330. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101331. bindBuffers(vertexBuffers: {
  101332. [key: string]: VertexBuffer;
  101333. }, indexBuffer: DataBuffer, effect: Effect): void;
  101334. wipeCaches(bruteForce?: boolean): void;
  101335. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101336. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101337. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101338. /** @hidden */
  101339. _createTexture(): WebGLTexture;
  101340. /** @hidden */
  101341. _releaseTexture(texture: InternalTexture): void;
  101342. 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;
  101343. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  101344. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  101345. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  101346. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101347. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  101348. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  101349. areAllEffectsReady(): boolean;
  101350. /**
  101351. * @hidden
  101352. * Get the current error code of the webGL context
  101353. * @returns the error code
  101354. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  101355. */
  101356. getError(): number;
  101357. /** @hidden */
  101358. _getUnpackAlignement(): number;
  101359. /** @hidden */
  101360. _unpackFlipY(value: boolean): void;
  101361. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  101362. /**
  101363. * Updates a dynamic vertex buffer.
  101364. * @param vertexBuffer the vertex buffer to update
  101365. * @param data the data used to update the vertex buffer
  101366. * @param byteOffset the byte offset of the data (optional)
  101367. * @param byteLength the byte length of the data (optional)
  101368. */
  101369. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  101370. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  101371. /** @hidden */
  101372. _bindTexture(channel: number, texture: InternalTexture): void;
  101373. /** @hidden */
  101374. _releaseBuffer(buffer: DataBuffer): boolean;
  101375. releaseEffects(): void;
  101376. displayLoadingUI(): void;
  101377. hideLoadingUI(): void;
  101378. /** @hidden */
  101379. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101380. /** @hidden */
  101381. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101382. /** @hidden */
  101383. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101384. /** @hidden */
  101385. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  101386. }
  101387. }
  101388. declare module BABYLON {
  101389. /** @hidden */
  101390. export class _OcclusionDataStorage {
  101391. /** @hidden */
  101392. occlusionInternalRetryCounter: number;
  101393. /** @hidden */
  101394. isOcclusionQueryInProgress: boolean;
  101395. /** @hidden */
  101396. isOccluded: boolean;
  101397. /** @hidden */
  101398. occlusionRetryCount: number;
  101399. /** @hidden */
  101400. occlusionType: number;
  101401. /** @hidden */
  101402. occlusionQueryAlgorithmType: number;
  101403. }
  101404. interface Engine {
  101405. /**
  101406. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  101407. * @return the new query
  101408. */
  101409. createQuery(): WebGLQuery;
  101410. /**
  101411. * Delete and release a webGL query
  101412. * @param query defines the query to delete
  101413. * @return the current engine
  101414. */
  101415. deleteQuery(query: WebGLQuery): Engine;
  101416. /**
  101417. * Check if a given query has resolved and got its value
  101418. * @param query defines the query to check
  101419. * @returns true if the query got its value
  101420. */
  101421. isQueryResultAvailable(query: WebGLQuery): boolean;
  101422. /**
  101423. * Gets the value of a given query
  101424. * @param query defines the query to check
  101425. * @returns the value of the query
  101426. */
  101427. getQueryResult(query: WebGLQuery): number;
  101428. /**
  101429. * Initiates an occlusion query
  101430. * @param algorithmType defines the algorithm to use
  101431. * @param query defines the query to use
  101432. * @returns the current engine
  101433. * @see http://doc.babylonjs.com/features/occlusionquery
  101434. */
  101435. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  101436. /**
  101437. * Ends an occlusion query
  101438. * @see http://doc.babylonjs.com/features/occlusionquery
  101439. * @param algorithmType defines the algorithm to use
  101440. * @returns the current engine
  101441. */
  101442. endOcclusionQuery(algorithmType: number): Engine;
  101443. /**
  101444. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  101445. * Please note that only one query can be issued at a time
  101446. * @returns a time token used to track the time span
  101447. */
  101448. startTimeQuery(): Nullable<_TimeToken>;
  101449. /**
  101450. * Ends a time query
  101451. * @param token defines the token used to measure the time span
  101452. * @returns the time spent (in ns)
  101453. */
  101454. endTimeQuery(token: _TimeToken): int;
  101455. /** @hidden */
  101456. _currentNonTimestampToken: Nullable<_TimeToken>;
  101457. /** @hidden */
  101458. _createTimeQuery(): WebGLQuery;
  101459. /** @hidden */
  101460. _deleteTimeQuery(query: WebGLQuery): void;
  101461. /** @hidden */
  101462. _getGlAlgorithmType(algorithmType: number): number;
  101463. /** @hidden */
  101464. _getTimeQueryResult(query: WebGLQuery): any;
  101465. /** @hidden */
  101466. _getTimeQueryAvailability(query: WebGLQuery): any;
  101467. }
  101468. interface AbstractMesh {
  101469. /**
  101470. * Backing filed
  101471. * @hidden
  101472. */
  101473. __occlusionDataStorage: _OcclusionDataStorage;
  101474. /**
  101475. * Access property
  101476. * @hidden
  101477. */
  101478. _occlusionDataStorage: _OcclusionDataStorage;
  101479. /**
  101480. * 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.
  101481. * The default value is -1 which means don't break the query and wait till the result
  101482. * @see http://doc.babylonjs.com/features/occlusionquery
  101483. */
  101484. occlusionRetryCount: number;
  101485. /**
  101486. * 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:
  101487. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  101488. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  101489. * * 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.
  101490. * @see http://doc.babylonjs.com/features/occlusionquery
  101491. */
  101492. occlusionType: number;
  101493. /**
  101494. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101495. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  101496. * * 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.
  101497. * @see http://doc.babylonjs.com/features/occlusionquery
  101498. */
  101499. occlusionQueryAlgorithmType: number;
  101500. /**
  101501. * 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
  101502. * @see http://doc.babylonjs.com/features/occlusionquery
  101503. */
  101504. isOccluded: boolean;
  101505. /**
  101506. * Flag to check the progress status of the query
  101507. * @see http://doc.babylonjs.com/features/occlusionquery
  101508. */
  101509. isOcclusionQueryInProgress: boolean;
  101510. }
  101511. }
  101512. declare module BABYLON {
  101513. /** @hidden */
  101514. export var _forceTransformFeedbackToBundle: boolean;
  101515. interface Engine {
  101516. /**
  101517. * Creates a webGL transform feedback object
  101518. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101519. * @returns the webGL transform feedback object
  101520. */
  101521. createTransformFeedback(): WebGLTransformFeedback;
  101522. /**
  101523. * Delete a webGL transform feedback object
  101524. * @param value defines the webGL transform feedback object to delete
  101525. */
  101526. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101527. /**
  101528. * Bind a webGL transform feedback object to the webgl context
  101529. * @param value defines the webGL transform feedback object to bind
  101530. */
  101531. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101532. /**
  101533. * Begins a transform feedback operation
  101534. * @param usePoints defines if points or triangles must be used
  101535. */
  101536. beginTransformFeedback(usePoints: boolean): void;
  101537. /**
  101538. * Ends a transform feedback operation
  101539. */
  101540. endTransformFeedback(): void;
  101541. /**
  101542. * Specify the varyings to use with transform feedback
  101543. * @param program defines the associated webGL program
  101544. * @param value defines the list of strings representing the varying names
  101545. */
  101546. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101547. /**
  101548. * Bind a webGL buffer for a transform feedback operation
  101549. * @param value defines the webGL buffer to bind
  101550. */
  101551. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  101552. }
  101553. }
  101554. declare module BABYLON {
  101555. /**
  101556. * Creation options of the multi render target texture.
  101557. */
  101558. export interface IMultiRenderTargetOptions {
  101559. /**
  101560. * Define if the texture needs to create mip maps after render.
  101561. */
  101562. generateMipMaps?: boolean;
  101563. /**
  101564. * Define the types of all the draw buffers we want to create
  101565. */
  101566. types?: number[];
  101567. /**
  101568. * Define the sampling modes of all the draw buffers we want to create
  101569. */
  101570. samplingModes?: number[];
  101571. /**
  101572. * Define if a depth buffer is required
  101573. */
  101574. generateDepthBuffer?: boolean;
  101575. /**
  101576. * Define if a stencil buffer is required
  101577. */
  101578. generateStencilBuffer?: boolean;
  101579. /**
  101580. * Define if a depth texture is required instead of a depth buffer
  101581. */
  101582. generateDepthTexture?: boolean;
  101583. /**
  101584. * Define the number of desired draw buffers
  101585. */
  101586. textureCount?: number;
  101587. /**
  101588. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101589. */
  101590. doNotChangeAspectRatio?: boolean;
  101591. /**
  101592. * Define the default type of the buffers we are creating
  101593. */
  101594. defaultType?: number;
  101595. }
  101596. /**
  101597. * A multi render target, like a render target provides the ability to render to a texture.
  101598. * Unlike the render target, it can render to several draw buffers in one draw.
  101599. * This is specially interesting in deferred rendering or for any effects requiring more than
  101600. * just one color from a single pass.
  101601. */
  101602. export class MultiRenderTarget extends RenderTargetTexture {
  101603. private _internalTextures;
  101604. private _textures;
  101605. private _multiRenderTargetOptions;
  101606. /**
  101607. * Get if draw buffers are currently supported by the used hardware and browser.
  101608. */
  101609. readonly isSupported: boolean;
  101610. /**
  101611. * Get the list of textures generated by the multi render target.
  101612. */
  101613. readonly textures: Texture[];
  101614. /**
  101615. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101616. */
  101617. readonly depthTexture: Texture;
  101618. /**
  101619. * Set the wrapping mode on U of all the textures we are rendering to.
  101620. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101621. */
  101622. wrapU: number;
  101623. /**
  101624. * Set the wrapping mode on V of all the textures we are rendering to.
  101625. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101626. */
  101627. wrapV: number;
  101628. /**
  101629. * Instantiate a new multi render target texture.
  101630. * A multi render target, like a render target provides the ability to render to a texture.
  101631. * Unlike the render target, it can render to several draw buffers in one draw.
  101632. * This is specially interesting in deferred rendering or for any effects requiring more than
  101633. * just one color from a single pass.
  101634. * @param name Define the name of the texture
  101635. * @param size Define the size of the buffers to render to
  101636. * @param count Define the number of target we are rendering into
  101637. * @param scene Define the scene the texture belongs to
  101638. * @param options Define the options used to create the multi render target
  101639. */
  101640. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101641. /** @hidden */
  101642. _rebuild(): void;
  101643. private _createInternalTextures;
  101644. private _createTextures;
  101645. /**
  101646. * Define the number of samples used if MSAA is enabled.
  101647. */
  101648. samples: number;
  101649. /**
  101650. * Resize all the textures in the multi render target.
  101651. * Be carrefull as it will recreate all the data in the new texture.
  101652. * @param size Define the new size
  101653. */
  101654. resize(size: any): void;
  101655. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101656. /**
  101657. * Dispose the render targets and their associated resources
  101658. */
  101659. dispose(): void;
  101660. /**
  101661. * Release all the underlying texture used as draw buffers.
  101662. */
  101663. releaseInternalTextures(): void;
  101664. }
  101665. }
  101666. declare module BABYLON {
  101667. interface Engine {
  101668. /**
  101669. * Unbind a list of render target textures from the webGL context
  101670. * This is used only when drawBuffer extension or webGL2 are active
  101671. * @param textures defines the render target textures to unbind
  101672. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101673. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101674. */
  101675. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101676. /**
  101677. * Create a multi render target texture
  101678. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101679. * @param size defines the size of the texture
  101680. * @param options defines the creation options
  101681. * @returns the cube texture as an InternalTexture
  101682. */
  101683. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101684. /**
  101685. * Update the sample count for a given multiple render target texture
  101686. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101687. * @param textures defines the textures to update
  101688. * @param samples defines the sample count to set
  101689. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101690. */
  101691. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101692. }
  101693. }
  101694. declare module BABYLON {
  101695. /**
  101696. * Gather the list of clipboard event types as constants.
  101697. */
  101698. export class ClipboardEventTypes {
  101699. /**
  101700. * The clipboard event is fired when a copy command is active (pressed).
  101701. */
  101702. static readonly COPY: number;
  101703. /**
  101704. * The clipboard event is fired when a cut command is active (pressed).
  101705. */
  101706. static readonly CUT: number;
  101707. /**
  101708. * The clipboard event is fired when a paste command is active (pressed).
  101709. */
  101710. static readonly PASTE: number;
  101711. }
  101712. /**
  101713. * This class is used to store clipboard related info for the onClipboardObservable event.
  101714. */
  101715. export class ClipboardInfo {
  101716. /**
  101717. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101718. */
  101719. type: number;
  101720. /**
  101721. * Defines the related dom event
  101722. */
  101723. event: ClipboardEvent;
  101724. /**
  101725. *Creates an instance of ClipboardInfo.
  101726. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101727. * @param event Defines the related dom event
  101728. */
  101729. constructor(
  101730. /**
  101731. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101732. */
  101733. type: number,
  101734. /**
  101735. * Defines the related dom event
  101736. */
  101737. event: ClipboardEvent);
  101738. /**
  101739. * Get the clipboard event's type from the keycode.
  101740. * @param keyCode Defines the keyCode for the current keyboard event.
  101741. * @return {number}
  101742. */
  101743. static GetTypeFromCharacter(keyCode: number): number;
  101744. }
  101745. }
  101746. declare module BABYLON {
  101747. /**
  101748. * Class used to represent data loading progression
  101749. */
  101750. export class SceneLoaderProgressEvent {
  101751. /** defines if data length to load can be evaluated */
  101752. readonly lengthComputable: boolean;
  101753. /** defines the loaded data length */
  101754. readonly loaded: number;
  101755. /** defines the data length to load */
  101756. readonly total: number;
  101757. /**
  101758. * Create a new progress event
  101759. * @param lengthComputable defines if data length to load can be evaluated
  101760. * @param loaded defines the loaded data length
  101761. * @param total defines the data length to load
  101762. */
  101763. constructor(
  101764. /** defines if data length to load can be evaluated */
  101765. lengthComputable: boolean,
  101766. /** defines the loaded data length */
  101767. loaded: number,
  101768. /** defines the data length to load */
  101769. total: number);
  101770. /**
  101771. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101772. * @param event defines the source event
  101773. * @returns a new SceneLoaderProgressEvent
  101774. */
  101775. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101776. }
  101777. /**
  101778. * Interface used by SceneLoader plugins to define supported file extensions
  101779. */
  101780. export interface ISceneLoaderPluginExtensions {
  101781. /**
  101782. * Defines the list of supported extensions
  101783. */
  101784. [extension: string]: {
  101785. isBinary: boolean;
  101786. };
  101787. }
  101788. /**
  101789. * Interface used by SceneLoader plugin factory
  101790. */
  101791. export interface ISceneLoaderPluginFactory {
  101792. /**
  101793. * Defines the name of the factory
  101794. */
  101795. name: string;
  101796. /**
  101797. * Function called to create a new plugin
  101798. * @return the new plugin
  101799. */
  101800. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101801. /**
  101802. * Boolean indicating if the plugin can direct load specific data
  101803. */
  101804. canDirectLoad?: (data: string) => boolean;
  101805. }
  101806. /**
  101807. * Interface used to define a SceneLoader plugin
  101808. */
  101809. export interface ISceneLoaderPlugin {
  101810. /**
  101811. * The friendly name of this plugin.
  101812. */
  101813. name: string;
  101814. /**
  101815. * The file extensions supported by this plugin.
  101816. */
  101817. extensions: string | ISceneLoaderPluginExtensions;
  101818. /**
  101819. * Import meshes into a scene.
  101820. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101821. * @param scene The scene to import into
  101822. * @param data The data to import
  101823. * @param rootUrl The root url for scene and resources
  101824. * @param meshes The meshes array to import into
  101825. * @param particleSystems The particle systems array to import into
  101826. * @param skeletons The skeletons array to import into
  101827. * @param onError The callback when import fails
  101828. * @returns True if successful or false otherwise
  101829. */
  101830. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  101831. /**
  101832. * Load into a scene.
  101833. * @param scene The scene to load into
  101834. * @param data The data to import
  101835. * @param rootUrl The root url for scene and resources
  101836. * @param onError The callback when import fails
  101837. * @returns true if successful or false otherwise
  101838. */
  101839. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  101840. /**
  101841. * The callback that returns true if the data can be directly loaded.
  101842. */
  101843. canDirectLoad?: (data: string) => boolean;
  101844. /**
  101845. * The callback that allows custom handling of the root url based on the response url.
  101846. */
  101847. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101848. /**
  101849. * Load into an asset container.
  101850. * @param scene The scene to load into
  101851. * @param data The data to import
  101852. * @param rootUrl The root url for scene and resources
  101853. * @param onError The callback when import fails
  101854. * @returns The loaded asset container
  101855. */
  101856. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101857. }
  101858. /**
  101859. * Interface used to define an async SceneLoader plugin
  101860. */
  101861. export interface ISceneLoaderPluginAsync {
  101862. /**
  101863. * The friendly name of this plugin.
  101864. */
  101865. name: string;
  101866. /**
  101867. * The file extensions supported by this plugin.
  101868. */
  101869. extensions: string | ISceneLoaderPluginExtensions;
  101870. /**
  101871. * Import meshes into a scene.
  101872. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101873. * @param scene The scene to import into
  101874. * @param data The data to import
  101875. * @param rootUrl The root url for scene and resources
  101876. * @param onProgress The callback when the load progresses
  101877. * @param fileName Defines the name of the file to load
  101878. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101879. */
  101880. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101881. meshes: AbstractMesh[];
  101882. particleSystems: IParticleSystem[];
  101883. skeletons: Skeleton[];
  101884. animationGroups: AnimationGroup[];
  101885. }>;
  101886. /**
  101887. * Load into a scene.
  101888. * @param scene The scene to load into
  101889. * @param data The data to import
  101890. * @param rootUrl The root url for scene and resources
  101891. * @param onProgress The callback when the load progresses
  101892. * @param fileName Defines the name of the file to load
  101893. * @returns Nothing
  101894. */
  101895. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101896. /**
  101897. * The callback that returns true if the data can be directly loaded.
  101898. */
  101899. canDirectLoad?: (data: string) => boolean;
  101900. /**
  101901. * The callback that allows custom handling of the root url based on the response url.
  101902. */
  101903. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101904. /**
  101905. * Load into an asset container.
  101906. * @param scene The scene to load into
  101907. * @param data The data to import
  101908. * @param rootUrl The root url for scene and resources
  101909. * @param onProgress The callback when the load progresses
  101910. * @param fileName Defines the name of the file to load
  101911. * @returns The loaded asset container
  101912. */
  101913. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101914. }
  101915. /**
  101916. * Class used to load scene from various file formats using registered plugins
  101917. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101918. */
  101919. export class SceneLoader {
  101920. /**
  101921. * No logging while loading
  101922. */
  101923. static readonly NO_LOGGING: number;
  101924. /**
  101925. * Minimal logging while loading
  101926. */
  101927. static readonly MINIMAL_LOGGING: number;
  101928. /**
  101929. * Summary logging while loading
  101930. */
  101931. static readonly SUMMARY_LOGGING: number;
  101932. /**
  101933. * Detailled logging while loading
  101934. */
  101935. static readonly DETAILED_LOGGING: number;
  101936. /**
  101937. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101938. */
  101939. static ForceFullSceneLoadingForIncremental: boolean;
  101940. /**
  101941. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101942. */
  101943. static ShowLoadingScreen: boolean;
  101944. /**
  101945. * Defines the current logging level (while loading the scene)
  101946. * @ignorenaming
  101947. */
  101948. static loggingLevel: number;
  101949. /**
  101950. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101951. */
  101952. static CleanBoneMatrixWeights: boolean;
  101953. /**
  101954. * Event raised when a plugin is used to load a scene
  101955. */
  101956. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101957. private static _registeredPlugins;
  101958. private static _getDefaultPlugin;
  101959. private static _getPluginForExtension;
  101960. private static _getPluginForDirectLoad;
  101961. private static _getPluginForFilename;
  101962. private static _getDirectLoad;
  101963. private static _loadData;
  101964. private static _getFileInfo;
  101965. /**
  101966. * Gets a plugin that can load the given extension
  101967. * @param extension defines the extension to load
  101968. * @returns a plugin or null if none works
  101969. */
  101970. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101971. /**
  101972. * Gets a boolean indicating that the given extension can be loaded
  101973. * @param extension defines the extension to load
  101974. * @returns true if the extension is supported
  101975. */
  101976. static IsPluginForExtensionAvailable(extension: string): boolean;
  101977. /**
  101978. * Adds a new plugin to the list of registered plugins
  101979. * @param plugin defines the plugin to add
  101980. */
  101981. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101982. /**
  101983. * Import meshes into a scene
  101984. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101985. * @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)
  101986. * @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)
  101987. * @param scene the instance of BABYLON.Scene to append to
  101988. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101989. * @param onProgress a callback with a progress event for each file being loaded
  101990. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101991. * @param pluginExtension the extension used to determine the plugin
  101992. * @returns The loaded plugin
  101993. */
  101994. 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>;
  101995. /**
  101996. * Import meshes into a scene
  101997. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101998. * @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)
  101999. * @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)
  102000. * @param scene the instance of BABYLON.Scene to append to
  102001. * @param onProgress a callback with a progress event for each file being loaded
  102002. * @param pluginExtension the extension used to determine the plugin
  102003. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  102004. */
  102005. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  102006. meshes: AbstractMesh[];
  102007. particleSystems: IParticleSystem[];
  102008. skeletons: Skeleton[];
  102009. animationGroups: AnimationGroup[];
  102010. }>;
  102011. /**
  102012. * Load a scene
  102013. * @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)
  102014. * @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)
  102015. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102016. * @param onSuccess a callback with the scene when import succeeds
  102017. * @param onProgress a callback with a progress event for each file being loaded
  102018. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102019. * @param pluginExtension the extension used to determine the plugin
  102020. * @returns The loaded plugin
  102021. */
  102022. 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>;
  102023. /**
  102024. * Load a scene
  102025. * @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)
  102026. * @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)
  102027. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102028. * @param onProgress a callback with a progress event for each file being loaded
  102029. * @param pluginExtension the extension used to determine the plugin
  102030. * @returns The loaded scene
  102031. */
  102032. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102033. /**
  102034. * Append a scene
  102035. * @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)
  102036. * @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)
  102037. * @param scene is the instance of BABYLON.Scene to append to
  102038. * @param onSuccess a callback with the scene when import succeeds
  102039. * @param onProgress a callback with a progress event for each file being loaded
  102040. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102041. * @param pluginExtension the extension used to determine the plugin
  102042. * @returns The loaded plugin
  102043. */
  102044. 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>;
  102045. /**
  102046. * Append a scene
  102047. * @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)
  102048. * @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)
  102049. * @param scene is the instance of BABYLON.Scene to append to
  102050. * @param onProgress a callback with a progress event for each file being loaded
  102051. * @param pluginExtension the extension used to determine the plugin
  102052. * @returns The given scene
  102053. */
  102054. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102055. /**
  102056. * Load a scene into an asset container
  102057. * @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)
  102058. * @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)
  102059. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  102060. * @param onSuccess a callback with the scene when import succeeds
  102061. * @param onProgress a callback with a progress event for each file being loaded
  102062. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102063. * @param pluginExtension the extension used to determine the plugin
  102064. * @returns The loaded plugin
  102065. */
  102066. 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>;
  102067. /**
  102068. * Load a scene into an asset container
  102069. * @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)
  102070. * @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)
  102071. * @param scene is the instance of Scene to append to
  102072. * @param onProgress a callback with a progress event for each file being loaded
  102073. * @param pluginExtension the extension used to determine the plugin
  102074. * @returns The loaded asset container
  102075. */
  102076. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  102077. }
  102078. }
  102079. declare module BABYLON {
  102080. /**
  102081. * Google Daydream controller
  102082. */
  102083. export class DaydreamController extends WebVRController {
  102084. /**
  102085. * Base Url for the controller model.
  102086. */
  102087. static MODEL_BASE_URL: string;
  102088. /**
  102089. * File name for the controller model.
  102090. */
  102091. static MODEL_FILENAME: string;
  102092. /**
  102093. * Gamepad Id prefix used to identify Daydream Controller.
  102094. */
  102095. static readonly GAMEPAD_ID_PREFIX: string;
  102096. /**
  102097. * Creates a new DaydreamController from a gamepad
  102098. * @param vrGamepad the gamepad that the controller should be created from
  102099. */
  102100. constructor(vrGamepad: any);
  102101. /**
  102102. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102103. * @param scene scene in which to add meshes
  102104. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102105. */
  102106. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102107. /**
  102108. * Called once for each button that changed state since the last frame
  102109. * @param buttonIdx Which button index changed
  102110. * @param state New state of the button
  102111. * @param changes Which properties on the state changed since last frame
  102112. */
  102113. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102114. }
  102115. }
  102116. declare module BABYLON {
  102117. /**
  102118. * Gear VR Controller
  102119. */
  102120. export class GearVRController extends WebVRController {
  102121. /**
  102122. * Base Url for the controller model.
  102123. */
  102124. static MODEL_BASE_URL: string;
  102125. /**
  102126. * File name for the controller model.
  102127. */
  102128. static MODEL_FILENAME: string;
  102129. /**
  102130. * Gamepad Id prefix used to identify this controller.
  102131. */
  102132. static readonly GAMEPAD_ID_PREFIX: string;
  102133. private readonly _buttonIndexToObservableNameMap;
  102134. /**
  102135. * Creates a new GearVRController from a gamepad
  102136. * @param vrGamepad the gamepad that the controller should be created from
  102137. */
  102138. constructor(vrGamepad: any);
  102139. /**
  102140. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102141. * @param scene scene in which to add meshes
  102142. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102143. */
  102144. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102145. /**
  102146. * Called once for each button that changed state since the last frame
  102147. * @param buttonIdx Which button index changed
  102148. * @param state New state of the button
  102149. * @param changes Which properties on the state changed since last frame
  102150. */
  102151. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102152. }
  102153. }
  102154. declare module BABYLON {
  102155. /**
  102156. * Generic Controller
  102157. */
  102158. export class GenericController extends WebVRController {
  102159. /**
  102160. * Base Url for the controller model.
  102161. */
  102162. static readonly MODEL_BASE_URL: string;
  102163. /**
  102164. * File name for the controller model.
  102165. */
  102166. static readonly MODEL_FILENAME: string;
  102167. /**
  102168. * Creates a new GenericController from a gamepad
  102169. * @param vrGamepad the gamepad that the controller should be created from
  102170. */
  102171. constructor(vrGamepad: any);
  102172. /**
  102173. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102174. * @param scene scene in which to add meshes
  102175. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102176. */
  102177. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102178. /**
  102179. * Called once for each button that changed state since the last frame
  102180. * @param buttonIdx Which button index changed
  102181. * @param state New state of the button
  102182. * @param changes Which properties on the state changed since last frame
  102183. */
  102184. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102185. }
  102186. }
  102187. declare module BABYLON {
  102188. /**
  102189. * Oculus Touch Controller
  102190. */
  102191. export class OculusTouchController extends WebVRController {
  102192. /**
  102193. * Base Url for the controller model.
  102194. */
  102195. static MODEL_BASE_URL: string;
  102196. /**
  102197. * File name for the left controller model.
  102198. */
  102199. static MODEL_LEFT_FILENAME: string;
  102200. /**
  102201. * File name for the right controller model.
  102202. */
  102203. static MODEL_RIGHT_FILENAME: string;
  102204. /**
  102205. * Fired when the secondary trigger on this controller is modified
  102206. */
  102207. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  102208. /**
  102209. * Fired when the thumb rest on this controller is modified
  102210. */
  102211. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  102212. /**
  102213. * Creates a new OculusTouchController from a gamepad
  102214. * @param vrGamepad the gamepad that the controller should be created from
  102215. */
  102216. constructor(vrGamepad: any);
  102217. /**
  102218. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102219. * @param scene scene in which to add meshes
  102220. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102221. */
  102222. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102223. /**
  102224. * Fired when the A button on this controller is modified
  102225. */
  102226. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102227. /**
  102228. * Fired when the B button on this controller is modified
  102229. */
  102230. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102231. /**
  102232. * Fired when the X button on this controller is modified
  102233. */
  102234. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102235. /**
  102236. * Fired when the Y button on this controller is modified
  102237. */
  102238. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102239. /**
  102240. * Called once for each button that changed state since the last frame
  102241. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  102242. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  102243. * 2) secondary trigger (same)
  102244. * 3) A (right) X (left), touch, pressed = value
  102245. * 4) B / Y
  102246. * 5) thumb rest
  102247. * @param buttonIdx Which button index changed
  102248. * @param state New state of the button
  102249. * @param changes Which properties on the state changed since last frame
  102250. */
  102251. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102252. }
  102253. }
  102254. declare module BABYLON {
  102255. /**
  102256. * Vive Controller
  102257. */
  102258. export class ViveController extends WebVRController {
  102259. /**
  102260. * Base Url for the controller model.
  102261. */
  102262. static MODEL_BASE_URL: string;
  102263. /**
  102264. * File name for the controller model.
  102265. */
  102266. static MODEL_FILENAME: string;
  102267. /**
  102268. * Creates a new ViveController from a gamepad
  102269. * @param vrGamepad the gamepad that the controller should be created from
  102270. */
  102271. constructor(vrGamepad: any);
  102272. /**
  102273. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102274. * @param scene scene in which to add meshes
  102275. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102276. */
  102277. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102278. /**
  102279. * Fired when the left button on this controller is modified
  102280. */
  102281. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102282. /**
  102283. * Fired when the right button on this controller is modified
  102284. */
  102285. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102286. /**
  102287. * Fired when the menu button on this controller is modified
  102288. */
  102289. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102290. /**
  102291. * Called once for each button that changed state since the last frame
  102292. * Vive mapping:
  102293. * 0: touchpad
  102294. * 1: trigger
  102295. * 2: left AND right buttons
  102296. * 3: menu button
  102297. * @param buttonIdx Which button index changed
  102298. * @param state New state of the button
  102299. * @param changes Which properties on the state changed since last frame
  102300. */
  102301. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102302. }
  102303. }
  102304. declare module BABYLON {
  102305. /**
  102306. * Defines the WindowsMotionController object that the state of the windows motion controller
  102307. */
  102308. export class WindowsMotionController extends WebVRController {
  102309. /**
  102310. * The base url used to load the left and right controller models
  102311. */
  102312. static MODEL_BASE_URL: string;
  102313. /**
  102314. * The name of the left controller model file
  102315. */
  102316. static MODEL_LEFT_FILENAME: string;
  102317. /**
  102318. * The name of the right controller model file
  102319. */
  102320. static MODEL_RIGHT_FILENAME: string;
  102321. /**
  102322. * The controller name prefix for this controller type
  102323. */
  102324. static readonly GAMEPAD_ID_PREFIX: string;
  102325. /**
  102326. * The controller id pattern for this controller type
  102327. */
  102328. private static readonly GAMEPAD_ID_PATTERN;
  102329. private _loadedMeshInfo;
  102330. private readonly _mapping;
  102331. /**
  102332. * Fired when the trackpad on this controller is clicked
  102333. */
  102334. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  102335. /**
  102336. * Fired when the trackpad on this controller is modified
  102337. */
  102338. onTrackpadValuesChangedObservable: Observable<StickValues>;
  102339. /**
  102340. * The current x and y values of this controller's trackpad
  102341. */
  102342. trackpad: StickValues;
  102343. /**
  102344. * Creates a new WindowsMotionController from a gamepad
  102345. * @param vrGamepad the gamepad that the controller should be created from
  102346. */
  102347. constructor(vrGamepad: any);
  102348. /**
  102349. * Fired when the trigger on this controller is modified
  102350. */
  102351. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102352. /**
  102353. * Fired when the menu button on this controller is modified
  102354. */
  102355. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102356. /**
  102357. * Fired when the grip button on this controller is modified
  102358. */
  102359. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102360. /**
  102361. * Fired when the thumbstick button on this controller is modified
  102362. */
  102363. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102364. /**
  102365. * Fired when the touchpad button on this controller is modified
  102366. */
  102367. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102368. /**
  102369. * Fired when the touchpad values on this controller are modified
  102370. */
  102371. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  102372. private _updateTrackpad;
  102373. /**
  102374. * Called once per frame by the engine.
  102375. */
  102376. update(): void;
  102377. /**
  102378. * Called once for each button that changed state since the last frame
  102379. * @param buttonIdx Which button index changed
  102380. * @param state New state of the button
  102381. * @param changes Which properties on the state changed since last frame
  102382. */
  102383. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102384. /**
  102385. * Moves the buttons on the controller mesh based on their current state
  102386. * @param buttonName the name of the button to move
  102387. * @param buttonValue the value of the button which determines the buttons new position
  102388. */
  102389. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  102390. /**
  102391. * Moves the axis on the controller mesh based on its current state
  102392. * @param axis the index of the axis
  102393. * @param axisValue the value of the axis which determines the meshes new position
  102394. * @hidden
  102395. */
  102396. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  102397. /**
  102398. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102399. * @param scene scene in which to add meshes
  102400. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102401. */
  102402. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  102403. /**
  102404. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  102405. * can be transformed by button presses and axes values, based on this._mapping.
  102406. *
  102407. * @param scene scene in which the meshes exist
  102408. * @param meshes list of meshes that make up the controller model to process
  102409. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  102410. */
  102411. private processModel;
  102412. private createMeshInfo;
  102413. /**
  102414. * Gets the ray of the controller in the direction the controller is pointing
  102415. * @param length the length the resulting ray should be
  102416. * @returns a ray in the direction the controller is pointing
  102417. */
  102418. getForwardRay(length?: number): Ray;
  102419. /**
  102420. * Disposes of the controller
  102421. */
  102422. dispose(): void;
  102423. }
  102424. }
  102425. declare module BABYLON {
  102426. /**
  102427. * Single axis scale gizmo
  102428. */
  102429. export class AxisScaleGizmo extends Gizmo {
  102430. private _coloredMaterial;
  102431. /**
  102432. * Drag behavior responsible for the gizmos dragging interactions
  102433. */
  102434. dragBehavior: PointerDragBehavior;
  102435. private _pointerObserver;
  102436. /**
  102437. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102438. */
  102439. snapDistance: number;
  102440. /**
  102441. * Event that fires each time the gizmo snaps to a new location.
  102442. * * snapDistance is the the change in distance
  102443. */
  102444. onSnapObservable: Observable<{
  102445. snapDistance: number;
  102446. }>;
  102447. /**
  102448. * If the scaling operation should be done on all axis (default: false)
  102449. */
  102450. uniformScaling: boolean;
  102451. /**
  102452. * Creates an AxisScaleGizmo
  102453. * @param gizmoLayer The utility layer the gizmo will be added to
  102454. * @param dragAxis The axis which the gizmo will be able to scale on
  102455. * @param color The color of the gizmo
  102456. */
  102457. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102458. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102459. /**
  102460. * Disposes of the gizmo
  102461. */
  102462. dispose(): void;
  102463. /**
  102464. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102465. * @param mesh The mesh to replace the default mesh of the gizmo
  102466. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  102467. */
  102468. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  102469. }
  102470. }
  102471. declare module BABYLON {
  102472. /**
  102473. * Bounding box gizmo
  102474. */
  102475. export class BoundingBoxGizmo extends Gizmo {
  102476. private _lineBoundingBox;
  102477. private _rotateSpheresParent;
  102478. private _scaleBoxesParent;
  102479. private _boundingDimensions;
  102480. private _renderObserver;
  102481. private _pointerObserver;
  102482. private _scaleDragSpeed;
  102483. private _tmpQuaternion;
  102484. private _tmpVector;
  102485. private _tmpRotationMatrix;
  102486. /**
  102487. * 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)
  102488. */
  102489. ignoreChildren: boolean;
  102490. /**
  102491. * 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)
  102492. */
  102493. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  102494. /**
  102495. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  102496. */
  102497. rotationSphereSize: number;
  102498. /**
  102499. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  102500. */
  102501. scaleBoxSize: number;
  102502. /**
  102503. * 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)
  102504. */
  102505. fixedDragMeshScreenSize: boolean;
  102506. /**
  102507. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  102508. */
  102509. fixedDragMeshScreenSizeDistanceFactor: number;
  102510. /**
  102511. * Fired when a rotation sphere or scale box is dragged
  102512. */
  102513. onDragStartObservable: Observable<{}>;
  102514. /**
  102515. * Fired when a scale box is dragged
  102516. */
  102517. onScaleBoxDragObservable: Observable<{}>;
  102518. /**
  102519. * Fired when a scale box drag is ended
  102520. */
  102521. onScaleBoxDragEndObservable: Observable<{}>;
  102522. /**
  102523. * Fired when a rotation sphere is dragged
  102524. */
  102525. onRotationSphereDragObservable: Observable<{}>;
  102526. /**
  102527. * Fired when a rotation sphere drag is ended
  102528. */
  102529. onRotationSphereDragEndObservable: Observable<{}>;
  102530. /**
  102531. * 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)
  102532. */
  102533. scalePivot: Nullable<Vector3>;
  102534. /**
  102535. * Mesh used as a pivot to rotate the attached mesh
  102536. */
  102537. private _anchorMesh;
  102538. private _existingMeshScale;
  102539. private _dragMesh;
  102540. private pointerDragBehavior;
  102541. private coloredMaterial;
  102542. private hoverColoredMaterial;
  102543. /**
  102544. * Sets the color of the bounding box gizmo
  102545. * @param color the color to set
  102546. */
  102547. setColor(color: Color3): void;
  102548. /**
  102549. * Creates an BoundingBoxGizmo
  102550. * @param gizmoLayer The utility layer the gizmo will be added to
  102551. * @param color The color of the gizmo
  102552. */
  102553. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102554. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102555. private _selectNode;
  102556. /**
  102557. * Updates the bounding box information for the Gizmo
  102558. */
  102559. updateBoundingBox(): void;
  102560. private _updateRotationSpheres;
  102561. private _updateScaleBoxes;
  102562. /**
  102563. * Enables rotation on the specified axis and disables rotation on the others
  102564. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102565. */
  102566. setEnabledRotationAxis(axis: string): void;
  102567. /**
  102568. * Enables/disables scaling
  102569. * @param enable if scaling should be enabled
  102570. */
  102571. setEnabledScaling(enable: boolean): void;
  102572. private _updateDummy;
  102573. /**
  102574. * Enables a pointer drag behavior on the bounding box of the gizmo
  102575. */
  102576. enableDragBehavior(): void;
  102577. /**
  102578. * Disposes of the gizmo
  102579. */
  102580. dispose(): void;
  102581. /**
  102582. * 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)
  102583. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102584. * @returns the bounding box mesh with the passed in mesh as a child
  102585. */
  102586. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102587. /**
  102588. * CustomMeshes are not supported by this gizmo
  102589. * @param mesh The mesh to replace the default mesh of the gizmo
  102590. */
  102591. setCustomMesh(mesh: Mesh): void;
  102592. }
  102593. }
  102594. declare module BABYLON {
  102595. /**
  102596. * Single plane rotation gizmo
  102597. */
  102598. export class PlaneRotationGizmo extends Gizmo {
  102599. /**
  102600. * Drag behavior responsible for the gizmos dragging interactions
  102601. */
  102602. dragBehavior: PointerDragBehavior;
  102603. private _pointerObserver;
  102604. /**
  102605. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102606. */
  102607. snapDistance: number;
  102608. /**
  102609. * Event that fires each time the gizmo snaps to a new location.
  102610. * * snapDistance is the the change in distance
  102611. */
  102612. onSnapObservable: Observable<{
  102613. snapDistance: number;
  102614. }>;
  102615. /**
  102616. * Creates a PlaneRotationGizmo
  102617. * @param gizmoLayer The utility layer the gizmo will be added to
  102618. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102619. * @param color The color of the gizmo
  102620. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102621. */
  102622. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102623. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102624. /**
  102625. * Disposes of the gizmo
  102626. */
  102627. dispose(): void;
  102628. }
  102629. }
  102630. declare module BABYLON {
  102631. /**
  102632. * Gizmo that enables rotating a mesh along 3 axis
  102633. */
  102634. export class RotationGizmo extends Gizmo {
  102635. /**
  102636. * Internal gizmo used for interactions on the x axis
  102637. */
  102638. xGizmo: PlaneRotationGizmo;
  102639. /**
  102640. * Internal gizmo used for interactions on the y axis
  102641. */
  102642. yGizmo: PlaneRotationGizmo;
  102643. /**
  102644. * Internal gizmo used for interactions on the z axis
  102645. */
  102646. zGizmo: PlaneRotationGizmo;
  102647. /** Fires an event when any of it's sub gizmos are dragged */
  102648. onDragStartObservable: Observable<{}>;
  102649. /** Fires an event when any of it's sub gizmos are released from dragging */
  102650. onDragEndObservable: Observable<{}>;
  102651. attachedMesh: Nullable<AbstractMesh>;
  102652. /**
  102653. * Creates a RotationGizmo
  102654. * @param gizmoLayer The utility layer the gizmo will be added to
  102655. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102656. */
  102657. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102658. updateGizmoRotationToMatchAttachedMesh: boolean;
  102659. /**
  102660. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102661. */
  102662. snapDistance: number;
  102663. /**
  102664. * Ratio for the scale of the gizmo (Default: 1)
  102665. */
  102666. scaleRatio: number;
  102667. /**
  102668. * Disposes of the gizmo
  102669. */
  102670. dispose(): void;
  102671. /**
  102672. * CustomMeshes are not supported by this gizmo
  102673. * @param mesh The mesh to replace the default mesh of the gizmo
  102674. */
  102675. setCustomMesh(mesh: Mesh): void;
  102676. }
  102677. }
  102678. declare module BABYLON {
  102679. /**
  102680. * Gizmo that enables dragging a mesh along 3 axis
  102681. */
  102682. export class PositionGizmo extends Gizmo {
  102683. /**
  102684. * Internal gizmo used for interactions on the x axis
  102685. */
  102686. xGizmo: AxisDragGizmo;
  102687. /**
  102688. * Internal gizmo used for interactions on the y axis
  102689. */
  102690. yGizmo: AxisDragGizmo;
  102691. /**
  102692. * Internal gizmo used for interactions on the z axis
  102693. */
  102694. zGizmo: AxisDragGizmo;
  102695. /** Fires an event when any of it's sub gizmos are dragged */
  102696. onDragStartObservable: Observable<{}>;
  102697. /** Fires an event when any of it's sub gizmos are released from dragging */
  102698. onDragEndObservable: Observable<{}>;
  102699. attachedMesh: Nullable<AbstractMesh>;
  102700. /**
  102701. * Creates a PositionGizmo
  102702. * @param gizmoLayer The utility layer the gizmo will be added to
  102703. */
  102704. constructor(gizmoLayer?: UtilityLayerRenderer);
  102705. updateGizmoRotationToMatchAttachedMesh: boolean;
  102706. /**
  102707. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102708. */
  102709. snapDistance: number;
  102710. /**
  102711. * Ratio for the scale of the gizmo (Default: 1)
  102712. */
  102713. scaleRatio: number;
  102714. /**
  102715. * Disposes of the gizmo
  102716. */
  102717. dispose(): void;
  102718. /**
  102719. * CustomMeshes are not supported by this gizmo
  102720. * @param mesh The mesh to replace the default mesh of the gizmo
  102721. */
  102722. setCustomMesh(mesh: Mesh): void;
  102723. }
  102724. }
  102725. declare module BABYLON {
  102726. /**
  102727. * Class containing static functions to help procedurally build meshes
  102728. */
  102729. export class PolyhedronBuilder {
  102730. /**
  102731. * Creates a polyhedron mesh
  102732. * * 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
  102733. * * The parameter `size` (positive float, default 1) sets the polygon size
  102734. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102735. * * 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`
  102736. * * 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
  102737. * * 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)`)
  102738. * * 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
  102739. * * 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
  102740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102743. * @param name defines the name of the mesh
  102744. * @param options defines the options used to create the mesh
  102745. * @param scene defines the hosting scene
  102746. * @returns the polyhedron mesh
  102747. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102748. */
  102749. static CreatePolyhedron(name: string, options: {
  102750. type?: number;
  102751. size?: number;
  102752. sizeX?: number;
  102753. sizeY?: number;
  102754. sizeZ?: number;
  102755. custom?: any;
  102756. faceUV?: Vector4[];
  102757. faceColors?: Color4[];
  102758. flat?: boolean;
  102759. updatable?: boolean;
  102760. sideOrientation?: number;
  102761. frontUVs?: Vector4;
  102762. backUVs?: Vector4;
  102763. }, scene?: Nullable<Scene>): Mesh;
  102764. }
  102765. }
  102766. declare module BABYLON {
  102767. /**
  102768. * Gizmo that enables scaling a mesh along 3 axis
  102769. */
  102770. export class ScaleGizmo extends Gizmo {
  102771. /**
  102772. * Internal gizmo used for interactions on the x axis
  102773. */
  102774. xGizmo: AxisScaleGizmo;
  102775. /**
  102776. * Internal gizmo used for interactions on the y axis
  102777. */
  102778. yGizmo: AxisScaleGizmo;
  102779. /**
  102780. * Internal gizmo used for interactions on the z axis
  102781. */
  102782. zGizmo: AxisScaleGizmo;
  102783. /**
  102784. * Internal gizmo used to scale all axis equally
  102785. */
  102786. uniformScaleGizmo: AxisScaleGizmo;
  102787. /** Fires an event when any of it's sub gizmos are dragged */
  102788. onDragStartObservable: Observable<{}>;
  102789. /** Fires an event when any of it's sub gizmos are released from dragging */
  102790. onDragEndObservable: Observable<{}>;
  102791. attachedMesh: Nullable<AbstractMesh>;
  102792. /**
  102793. * Creates a ScaleGizmo
  102794. * @param gizmoLayer The utility layer the gizmo will be added to
  102795. */
  102796. constructor(gizmoLayer?: UtilityLayerRenderer);
  102797. updateGizmoRotationToMatchAttachedMesh: boolean;
  102798. /**
  102799. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102800. */
  102801. snapDistance: number;
  102802. /**
  102803. * Ratio for the scale of the gizmo (Default: 1)
  102804. */
  102805. scaleRatio: number;
  102806. /**
  102807. * Disposes of the gizmo
  102808. */
  102809. dispose(): void;
  102810. }
  102811. }
  102812. declare module BABYLON {
  102813. /**
  102814. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102815. */
  102816. export class GizmoManager implements IDisposable {
  102817. private scene;
  102818. /**
  102819. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102820. */
  102821. gizmos: {
  102822. positionGizmo: Nullable<PositionGizmo>;
  102823. rotationGizmo: Nullable<RotationGizmo>;
  102824. scaleGizmo: Nullable<ScaleGizmo>;
  102825. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102826. };
  102827. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102828. clearGizmoOnEmptyPointerEvent: boolean;
  102829. /** Fires an event when the manager is attached to a mesh */
  102830. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  102831. private _gizmosEnabled;
  102832. private _pointerObserver;
  102833. private _attachedMesh;
  102834. private _boundingBoxColor;
  102835. private _defaultUtilityLayer;
  102836. private _defaultKeepDepthUtilityLayer;
  102837. /**
  102838. * When bounding box gizmo is enabled, this can be used to track drag/end events
  102839. */
  102840. boundingBoxDragBehavior: SixDofDragBehavior;
  102841. /**
  102842. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  102843. */
  102844. attachableMeshes: Nullable<Array<AbstractMesh>>;
  102845. /**
  102846. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  102847. */
  102848. usePointerToAttachGizmos: boolean;
  102849. /**
  102850. * Instatiates a gizmo manager
  102851. * @param scene the scene to overlay the gizmos on top of
  102852. */
  102853. constructor(scene: Scene);
  102854. /**
  102855. * Attaches a set of gizmos to the specified mesh
  102856. * @param mesh The mesh the gizmo's should be attached to
  102857. */
  102858. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102859. /**
  102860. * If the position gizmo is enabled
  102861. */
  102862. positionGizmoEnabled: boolean;
  102863. /**
  102864. * If the rotation gizmo is enabled
  102865. */
  102866. rotationGizmoEnabled: boolean;
  102867. /**
  102868. * If the scale gizmo is enabled
  102869. */
  102870. scaleGizmoEnabled: boolean;
  102871. /**
  102872. * If the boundingBox gizmo is enabled
  102873. */
  102874. boundingBoxGizmoEnabled: boolean;
  102875. /**
  102876. * Disposes of the gizmo manager
  102877. */
  102878. dispose(): void;
  102879. }
  102880. }
  102881. declare module BABYLON {
  102882. /**
  102883. * A directional light is defined by a direction (what a surprise!).
  102884. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102885. * 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.
  102886. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102887. */
  102888. export class DirectionalLight extends ShadowLight {
  102889. private _shadowFrustumSize;
  102890. /**
  102891. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102892. */
  102893. /**
  102894. * Specifies a fix frustum size for the shadow generation.
  102895. */
  102896. shadowFrustumSize: number;
  102897. private _shadowOrthoScale;
  102898. /**
  102899. * Gets the shadow projection scale against the optimal computed one.
  102900. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102901. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102902. */
  102903. /**
  102904. * Sets the shadow projection scale against the optimal computed one.
  102905. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102906. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102907. */
  102908. shadowOrthoScale: number;
  102909. /**
  102910. * Automatically compute the projection matrix to best fit (including all the casters)
  102911. * on each frame.
  102912. */
  102913. autoUpdateExtends: boolean;
  102914. private _orthoLeft;
  102915. private _orthoRight;
  102916. private _orthoTop;
  102917. private _orthoBottom;
  102918. /**
  102919. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102920. * The directional light is emitted from everywhere in the given direction.
  102921. * It can cast shadows.
  102922. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102923. * @param name The friendly name of the light
  102924. * @param direction The direction of the light
  102925. * @param scene The scene the light belongs to
  102926. */
  102927. constructor(name: string, direction: Vector3, scene: Scene);
  102928. /**
  102929. * Returns the string "DirectionalLight".
  102930. * @return The class name
  102931. */
  102932. getClassName(): string;
  102933. /**
  102934. * Returns the integer 1.
  102935. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102936. */
  102937. getTypeID(): number;
  102938. /**
  102939. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102940. * Returns the DirectionalLight Shadow projection matrix.
  102941. */
  102942. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102943. /**
  102944. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102945. * Returns the DirectionalLight Shadow projection matrix.
  102946. */
  102947. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102948. /**
  102949. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102950. * Returns the DirectionalLight Shadow projection matrix.
  102951. */
  102952. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102953. protected _buildUniformLayout(): void;
  102954. /**
  102955. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102956. * @param effect The effect to update
  102957. * @param lightIndex The index of the light in the effect to update
  102958. * @returns The directional light
  102959. */
  102960. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102961. /**
  102962. * Gets the minZ used for shadow according to both the scene and the light.
  102963. *
  102964. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102965. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102966. * @param activeCamera The camera we are returning the min for
  102967. * @returns the depth min z
  102968. */
  102969. getDepthMinZ(activeCamera: Camera): number;
  102970. /**
  102971. * Gets the maxZ used for shadow according to both the scene and the light.
  102972. *
  102973. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102974. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102975. * @param activeCamera The camera we are returning the max for
  102976. * @returns the depth max z
  102977. */
  102978. getDepthMaxZ(activeCamera: Camera): number;
  102979. /**
  102980. * Prepares the list of defines specific to the light type.
  102981. * @param defines the list of defines
  102982. * @param lightIndex defines the index of the light for the effect
  102983. */
  102984. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102985. }
  102986. }
  102987. declare module BABYLON {
  102988. /**
  102989. * Class containing static functions to help procedurally build meshes
  102990. */
  102991. export class HemisphereBuilder {
  102992. /**
  102993. * Creates a hemisphere mesh
  102994. * @param name defines the name of the mesh
  102995. * @param options defines the options used to create the mesh
  102996. * @param scene defines the hosting scene
  102997. * @returns the hemisphere mesh
  102998. */
  102999. static CreateHemisphere(name: string, options: {
  103000. segments?: number;
  103001. diameter?: number;
  103002. sideOrientation?: number;
  103003. }, scene: any): Mesh;
  103004. }
  103005. }
  103006. declare module BABYLON {
  103007. /**
  103008. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103009. * These values define a cone of light starting from the position, emitting toward the direction.
  103010. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103011. * and the exponent defines the speed of the decay of the light with distance (reach).
  103012. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103013. */
  103014. export class SpotLight extends ShadowLight {
  103015. private _angle;
  103016. private _innerAngle;
  103017. private _cosHalfAngle;
  103018. private _lightAngleScale;
  103019. private _lightAngleOffset;
  103020. /**
  103021. * Gets the cone angle of the spot light in Radians.
  103022. */
  103023. /**
  103024. * Sets the cone angle of the spot light in Radians.
  103025. */
  103026. angle: number;
  103027. /**
  103028. * Only used in gltf falloff mode, this defines the angle where
  103029. * the directional falloff will start before cutting at angle which could be seen
  103030. * as outer angle.
  103031. */
  103032. /**
  103033. * Only used in gltf falloff mode, this defines the angle where
  103034. * the directional falloff will start before cutting at angle which could be seen
  103035. * as outer angle.
  103036. */
  103037. innerAngle: number;
  103038. private _shadowAngleScale;
  103039. /**
  103040. * Allows scaling the angle of the light for shadow generation only.
  103041. */
  103042. /**
  103043. * Allows scaling the angle of the light for shadow generation only.
  103044. */
  103045. shadowAngleScale: number;
  103046. /**
  103047. * The light decay speed with the distance from the emission spot.
  103048. */
  103049. exponent: number;
  103050. private _projectionTextureMatrix;
  103051. /**
  103052. * Allows reading the projecton texture
  103053. */
  103054. readonly projectionTextureMatrix: Matrix;
  103055. protected _projectionTextureLightNear: number;
  103056. /**
  103057. * Gets the near clip of the Spotlight for texture projection.
  103058. */
  103059. /**
  103060. * Sets the near clip of the Spotlight for texture projection.
  103061. */
  103062. projectionTextureLightNear: number;
  103063. protected _projectionTextureLightFar: number;
  103064. /**
  103065. * Gets the far clip of the Spotlight for texture projection.
  103066. */
  103067. /**
  103068. * Sets the far clip of the Spotlight for texture projection.
  103069. */
  103070. projectionTextureLightFar: number;
  103071. protected _projectionTextureUpDirection: Vector3;
  103072. /**
  103073. * Gets the Up vector of the Spotlight for texture projection.
  103074. */
  103075. /**
  103076. * Sets the Up vector of the Spotlight for texture projection.
  103077. */
  103078. projectionTextureUpDirection: Vector3;
  103079. private _projectionTexture;
  103080. /**
  103081. * Gets the projection texture of the light.
  103082. */
  103083. /**
  103084. * Sets the projection texture of the light.
  103085. */
  103086. projectionTexture: Nullable<BaseTexture>;
  103087. private _projectionTextureViewLightDirty;
  103088. private _projectionTextureProjectionLightDirty;
  103089. private _projectionTextureDirty;
  103090. private _projectionTextureViewTargetVector;
  103091. private _projectionTextureViewLightMatrix;
  103092. private _projectionTextureProjectionLightMatrix;
  103093. private _projectionTextureScalingMatrix;
  103094. /**
  103095. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103096. * It can cast shadows.
  103097. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103098. * @param name The light friendly name
  103099. * @param position The position of the spot light in the scene
  103100. * @param direction The direction of the light in the scene
  103101. * @param angle The cone angle of the light in Radians
  103102. * @param exponent The light decay speed with the distance from the emission spot
  103103. * @param scene The scene the lights belongs to
  103104. */
  103105. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103106. /**
  103107. * Returns the string "SpotLight".
  103108. * @returns the class name
  103109. */
  103110. getClassName(): string;
  103111. /**
  103112. * Returns the integer 2.
  103113. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103114. */
  103115. getTypeID(): number;
  103116. /**
  103117. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103118. */
  103119. protected _setDirection(value: Vector3): void;
  103120. /**
  103121. * Overrides the position setter to recompute the projection texture view light Matrix.
  103122. */
  103123. protected _setPosition(value: Vector3): void;
  103124. /**
  103125. * 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.
  103126. * Returns the SpotLight.
  103127. */
  103128. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103129. protected _computeProjectionTextureViewLightMatrix(): void;
  103130. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103131. /**
  103132. * Main function for light texture projection matrix computing.
  103133. */
  103134. protected _computeProjectionTextureMatrix(): void;
  103135. protected _buildUniformLayout(): void;
  103136. private _computeAngleValues;
  103137. /**
  103138. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103139. * @param effect The effect to update
  103140. * @param lightIndex The index of the light in the effect to update
  103141. * @returns The spot light
  103142. */
  103143. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103144. /**
  103145. * Disposes the light and the associated resources.
  103146. */
  103147. dispose(): void;
  103148. /**
  103149. * Prepares the list of defines specific to the light type.
  103150. * @param defines the list of defines
  103151. * @param lightIndex defines the index of the light for the effect
  103152. */
  103153. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103154. }
  103155. }
  103156. declare module BABYLON {
  103157. /**
  103158. * Gizmo that enables viewing a light
  103159. */
  103160. export class LightGizmo extends Gizmo {
  103161. private _lightMesh;
  103162. private _material;
  103163. /**
  103164. * Creates a LightGizmo
  103165. * @param gizmoLayer The utility layer the gizmo will be added to
  103166. */
  103167. constructor(gizmoLayer?: UtilityLayerRenderer);
  103168. private _light;
  103169. /**
  103170. * The light that the gizmo is attached to
  103171. */
  103172. light: Nullable<Light>;
  103173. /**
  103174. * @hidden
  103175. * Updates the gizmo to match the attached mesh's position/rotation
  103176. */
  103177. protected _update(): void;
  103178. private static _Scale;
  103179. /**
  103180. * Creates the lines for a light mesh
  103181. */
  103182. private static _createLightLines;
  103183. private static _CreateHemisphericLightMesh;
  103184. private static _CreatePointLightMesh;
  103185. private static _CreateSpotLightMesh;
  103186. private static _CreateDirectionalLightMesh;
  103187. }
  103188. }
  103189. declare module BABYLON {
  103190. /** @hidden */
  103191. export var backgroundFragmentDeclaration: {
  103192. name: string;
  103193. shader: string;
  103194. };
  103195. }
  103196. declare module BABYLON {
  103197. /** @hidden */
  103198. export var backgroundUboDeclaration: {
  103199. name: string;
  103200. shader: string;
  103201. };
  103202. }
  103203. declare module BABYLON {
  103204. /** @hidden */
  103205. export var backgroundPixelShader: {
  103206. name: string;
  103207. shader: string;
  103208. };
  103209. }
  103210. declare module BABYLON {
  103211. /** @hidden */
  103212. export var backgroundVertexDeclaration: {
  103213. name: string;
  103214. shader: string;
  103215. };
  103216. }
  103217. declare module BABYLON {
  103218. /** @hidden */
  103219. export var backgroundVertexShader: {
  103220. name: string;
  103221. shader: string;
  103222. };
  103223. }
  103224. declare module BABYLON {
  103225. /**
  103226. * Background material used to create an efficient environement around your scene.
  103227. */
  103228. export class BackgroundMaterial extends PushMaterial {
  103229. /**
  103230. * Standard reflectance value at parallel view angle.
  103231. */
  103232. static StandardReflectance0: number;
  103233. /**
  103234. * Standard reflectance value at grazing angle.
  103235. */
  103236. static StandardReflectance90: number;
  103237. protected _primaryColor: Color3;
  103238. /**
  103239. * Key light Color (multiply against the environement texture)
  103240. */
  103241. primaryColor: Color3;
  103242. protected __perceptualColor: Nullable<Color3>;
  103243. /**
  103244. * Experimental Internal Use Only.
  103245. *
  103246. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  103247. * This acts as a helper to set the primary color to a more "human friendly" value.
  103248. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  103249. * output color as close as possible from the chosen value.
  103250. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  103251. * part of lighting setup.)
  103252. */
  103253. _perceptualColor: Nullable<Color3>;
  103254. protected _primaryColorShadowLevel: float;
  103255. /**
  103256. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  103257. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  103258. */
  103259. primaryColorShadowLevel: float;
  103260. protected _primaryColorHighlightLevel: float;
  103261. /**
  103262. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  103263. * The primary color is used at the level chosen to define what the white area would look.
  103264. */
  103265. primaryColorHighlightLevel: float;
  103266. protected _reflectionTexture: Nullable<BaseTexture>;
  103267. /**
  103268. * Reflection Texture used in the material.
  103269. * Should be author in a specific way for the best result (refer to the documentation).
  103270. */
  103271. reflectionTexture: Nullable<BaseTexture>;
  103272. protected _reflectionBlur: float;
  103273. /**
  103274. * Reflection Texture level of blur.
  103275. *
  103276. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  103277. * texture twice.
  103278. */
  103279. reflectionBlur: float;
  103280. protected _diffuseTexture: Nullable<BaseTexture>;
  103281. /**
  103282. * Diffuse Texture used in the material.
  103283. * Should be author in a specific way for the best result (refer to the documentation).
  103284. */
  103285. diffuseTexture: Nullable<BaseTexture>;
  103286. protected _shadowLights: Nullable<IShadowLight[]>;
  103287. /**
  103288. * Specify the list of lights casting shadow on the material.
  103289. * All scene shadow lights will be included if null.
  103290. */
  103291. shadowLights: Nullable<IShadowLight[]>;
  103292. protected _shadowLevel: float;
  103293. /**
  103294. * Helps adjusting the shadow to a softer level if required.
  103295. * 0 means black shadows and 1 means no shadows.
  103296. */
  103297. shadowLevel: float;
  103298. protected _sceneCenter: Vector3;
  103299. /**
  103300. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  103301. * It is usually zero but might be interesting to modify according to your setup.
  103302. */
  103303. sceneCenter: Vector3;
  103304. protected _opacityFresnel: boolean;
  103305. /**
  103306. * This helps specifying that the material is falling off to the sky box at grazing angle.
  103307. * This helps ensuring a nice transition when the camera goes under the ground.
  103308. */
  103309. opacityFresnel: boolean;
  103310. protected _reflectionFresnel: boolean;
  103311. /**
  103312. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  103313. * This helps adding a mirror texture on the ground.
  103314. */
  103315. reflectionFresnel: boolean;
  103316. protected _reflectionFalloffDistance: number;
  103317. /**
  103318. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  103319. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  103320. */
  103321. reflectionFalloffDistance: number;
  103322. protected _reflectionAmount: number;
  103323. /**
  103324. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  103325. */
  103326. reflectionAmount: number;
  103327. protected _reflectionReflectance0: number;
  103328. /**
  103329. * This specifies the weight of the reflection at grazing angle.
  103330. */
  103331. reflectionReflectance0: number;
  103332. protected _reflectionReflectance90: number;
  103333. /**
  103334. * This specifies the weight of the reflection at a perpendicular point of view.
  103335. */
  103336. reflectionReflectance90: number;
  103337. /**
  103338. * Sets the reflection reflectance fresnel values according to the default standard
  103339. * empirically know to work well :-)
  103340. */
  103341. reflectionStandardFresnelWeight: number;
  103342. protected _useRGBColor: boolean;
  103343. /**
  103344. * Helps to directly use the maps channels instead of their level.
  103345. */
  103346. useRGBColor: boolean;
  103347. protected _enableNoise: boolean;
  103348. /**
  103349. * This helps reducing the banding effect that could occur on the background.
  103350. */
  103351. enableNoise: boolean;
  103352. /**
  103353. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103354. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  103355. * Recommended to be keep at 1.0 except for special cases.
  103356. */
  103357. fovMultiplier: number;
  103358. private _fovMultiplier;
  103359. /**
  103360. * Enable the FOV adjustment feature controlled by fovMultiplier.
  103361. */
  103362. useEquirectangularFOV: boolean;
  103363. private _maxSimultaneousLights;
  103364. /**
  103365. * Number of Simultaneous lights allowed on the material.
  103366. */
  103367. maxSimultaneousLights: int;
  103368. /**
  103369. * Default configuration related to image processing available in the Background Material.
  103370. */
  103371. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103372. /**
  103373. * Keep track of the image processing observer to allow dispose and replace.
  103374. */
  103375. private _imageProcessingObserver;
  103376. /**
  103377. * Attaches a new image processing configuration to the PBR Material.
  103378. * @param configuration (if null the scene configuration will be use)
  103379. */
  103380. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103381. /**
  103382. * Gets the image processing configuration used either in this material.
  103383. */
  103384. /**
  103385. * Sets the Default image processing configuration used either in the this material.
  103386. *
  103387. * If sets to null, the scene one is in use.
  103388. */
  103389. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  103390. /**
  103391. * Gets wether the color curves effect is enabled.
  103392. */
  103393. /**
  103394. * Sets wether the color curves effect is enabled.
  103395. */
  103396. cameraColorCurvesEnabled: boolean;
  103397. /**
  103398. * Gets wether the color grading effect is enabled.
  103399. */
  103400. /**
  103401. * Gets wether the color grading effect is enabled.
  103402. */
  103403. cameraColorGradingEnabled: boolean;
  103404. /**
  103405. * Gets wether tonemapping is enabled or not.
  103406. */
  103407. /**
  103408. * Sets wether tonemapping is enabled or not
  103409. */
  103410. cameraToneMappingEnabled: boolean;
  103411. /**
  103412. * The camera exposure used on this material.
  103413. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103414. * This corresponds to a photographic exposure.
  103415. */
  103416. /**
  103417. * The camera exposure used on this material.
  103418. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103419. * This corresponds to a photographic exposure.
  103420. */
  103421. cameraExposure: float;
  103422. /**
  103423. * Gets The camera contrast used on this material.
  103424. */
  103425. /**
  103426. * Sets The camera contrast used on this material.
  103427. */
  103428. cameraContrast: float;
  103429. /**
  103430. * Gets the Color Grading 2D Lookup Texture.
  103431. */
  103432. /**
  103433. * Sets the Color Grading 2D Lookup Texture.
  103434. */
  103435. cameraColorGradingTexture: Nullable<BaseTexture>;
  103436. /**
  103437. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103438. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103439. * 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;
  103440. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103441. */
  103442. /**
  103443. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103444. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103445. * 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;
  103446. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103447. */
  103448. cameraColorCurves: Nullable<ColorCurves>;
  103449. /**
  103450. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  103451. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  103452. */
  103453. switchToBGR: boolean;
  103454. private _renderTargets;
  103455. private _reflectionControls;
  103456. private _white;
  103457. private _primaryShadowColor;
  103458. private _primaryHighlightColor;
  103459. /**
  103460. * Instantiates a Background Material in the given scene
  103461. * @param name The friendly name of the material
  103462. * @param scene The scene to add the material to
  103463. */
  103464. constructor(name: string, scene: Scene);
  103465. /**
  103466. * Gets a boolean indicating that current material needs to register RTT
  103467. */
  103468. readonly hasRenderTargetTextures: boolean;
  103469. /**
  103470. * The entire material has been created in order to prevent overdraw.
  103471. * @returns false
  103472. */
  103473. needAlphaTesting(): boolean;
  103474. /**
  103475. * The entire material has been created in order to prevent overdraw.
  103476. * @returns true if blending is enable
  103477. */
  103478. needAlphaBlending(): boolean;
  103479. /**
  103480. * Checks wether the material is ready to be rendered for a given mesh.
  103481. * @param mesh The mesh to render
  103482. * @param subMesh The submesh to check against
  103483. * @param useInstances Specify wether or not the material is used with instances
  103484. * @returns true if all the dependencies are ready (Textures, Effects...)
  103485. */
  103486. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103487. /**
  103488. * Compute the primary color according to the chosen perceptual color.
  103489. */
  103490. private _computePrimaryColorFromPerceptualColor;
  103491. /**
  103492. * Compute the highlights and shadow colors according to their chosen levels.
  103493. */
  103494. private _computePrimaryColors;
  103495. /**
  103496. * Build the uniform buffer used in the material.
  103497. */
  103498. buildUniformLayout(): void;
  103499. /**
  103500. * Unbind the material.
  103501. */
  103502. unbind(): void;
  103503. /**
  103504. * Bind only the world matrix to the material.
  103505. * @param world The world matrix to bind.
  103506. */
  103507. bindOnlyWorldMatrix(world: Matrix): void;
  103508. /**
  103509. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  103510. * @param world The world matrix to bind.
  103511. * @param subMesh The submesh to bind for.
  103512. */
  103513. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103514. /**
  103515. * Dispose the material.
  103516. * @param forceDisposeEffect Force disposal of the associated effect.
  103517. * @param forceDisposeTextures Force disposal of the associated textures.
  103518. */
  103519. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103520. /**
  103521. * Clones the material.
  103522. * @param name The cloned name.
  103523. * @returns The cloned material.
  103524. */
  103525. clone(name: string): BackgroundMaterial;
  103526. /**
  103527. * Serializes the current material to its JSON representation.
  103528. * @returns The JSON representation.
  103529. */
  103530. serialize(): any;
  103531. /**
  103532. * Gets the class name of the material
  103533. * @returns "BackgroundMaterial"
  103534. */
  103535. getClassName(): string;
  103536. /**
  103537. * Parse a JSON input to create back a background material.
  103538. * @param source The JSON data to parse
  103539. * @param scene The scene to create the parsed material in
  103540. * @param rootUrl The root url of the assets the material depends upon
  103541. * @returns the instantiated BackgroundMaterial.
  103542. */
  103543. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103544. }
  103545. }
  103546. declare module BABYLON {
  103547. /**
  103548. * Represents the different options available during the creation of
  103549. * a Environment helper.
  103550. *
  103551. * This can control the default ground, skybox and image processing setup of your scene.
  103552. */
  103553. export interface IEnvironmentHelperOptions {
  103554. /**
  103555. * Specifies wether or not to create a ground.
  103556. * True by default.
  103557. */
  103558. createGround: boolean;
  103559. /**
  103560. * Specifies the ground size.
  103561. * 15 by default.
  103562. */
  103563. groundSize: number;
  103564. /**
  103565. * The texture used on the ground for the main color.
  103566. * Comes from the BabylonJS CDN by default.
  103567. *
  103568. * Remarks: Can be either a texture or a url.
  103569. */
  103570. groundTexture: string | BaseTexture;
  103571. /**
  103572. * The color mixed in the ground texture by default.
  103573. * BabylonJS clearColor by default.
  103574. */
  103575. groundColor: Color3;
  103576. /**
  103577. * Specifies the ground opacity.
  103578. * 1 by default.
  103579. */
  103580. groundOpacity: number;
  103581. /**
  103582. * Enables the ground to receive shadows.
  103583. * True by default.
  103584. */
  103585. enableGroundShadow: boolean;
  103586. /**
  103587. * Helps preventing the shadow to be fully black on the ground.
  103588. * 0.5 by default.
  103589. */
  103590. groundShadowLevel: number;
  103591. /**
  103592. * Creates a mirror texture attach to the ground.
  103593. * false by default.
  103594. */
  103595. enableGroundMirror: boolean;
  103596. /**
  103597. * Specifies the ground mirror size ratio.
  103598. * 0.3 by default as the default kernel is 64.
  103599. */
  103600. groundMirrorSizeRatio: number;
  103601. /**
  103602. * Specifies the ground mirror blur kernel size.
  103603. * 64 by default.
  103604. */
  103605. groundMirrorBlurKernel: number;
  103606. /**
  103607. * Specifies the ground mirror visibility amount.
  103608. * 1 by default
  103609. */
  103610. groundMirrorAmount: number;
  103611. /**
  103612. * Specifies the ground mirror reflectance weight.
  103613. * This uses the standard weight of the background material to setup the fresnel effect
  103614. * of the mirror.
  103615. * 1 by default.
  103616. */
  103617. groundMirrorFresnelWeight: number;
  103618. /**
  103619. * Specifies the ground mirror Falloff distance.
  103620. * This can helps reducing the size of the reflection.
  103621. * 0 by Default.
  103622. */
  103623. groundMirrorFallOffDistance: number;
  103624. /**
  103625. * Specifies the ground mirror texture type.
  103626. * Unsigned Int by Default.
  103627. */
  103628. groundMirrorTextureType: number;
  103629. /**
  103630. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103631. * the shown objects.
  103632. */
  103633. groundYBias: number;
  103634. /**
  103635. * Specifies wether or not to create a skybox.
  103636. * True by default.
  103637. */
  103638. createSkybox: boolean;
  103639. /**
  103640. * Specifies the skybox size.
  103641. * 20 by default.
  103642. */
  103643. skyboxSize: number;
  103644. /**
  103645. * The texture used on the skybox for the main color.
  103646. * Comes from the BabylonJS CDN by default.
  103647. *
  103648. * Remarks: Can be either a texture or a url.
  103649. */
  103650. skyboxTexture: string | BaseTexture;
  103651. /**
  103652. * The color mixed in the skybox texture by default.
  103653. * BabylonJS clearColor by default.
  103654. */
  103655. skyboxColor: Color3;
  103656. /**
  103657. * The background rotation around the Y axis of the scene.
  103658. * This helps aligning the key lights of your scene with the background.
  103659. * 0 by default.
  103660. */
  103661. backgroundYRotation: number;
  103662. /**
  103663. * Compute automatically the size of the elements to best fit with the scene.
  103664. */
  103665. sizeAuto: boolean;
  103666. /**
  103667. * Default position of the rootMesh if autoSize is not true.
  103668. */
  103669. rootPosition: Vector3;
  103670. /**
  103671. * Sets up the image processing in the scene.
  103672. * true by default.
  103673. */
  103674. setupImageProcessing: boolean;
  103675. /**
  103676. * The texture used as your environment texture in the scene.
  103677. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103678. *
  103679. * Remarks: Can be either a texture or a url.
  103680. */
  103681. environmentTexture: string | BaseTexture;
  103682. /**
  103683. * The value of the exposure to apply to the scene.
  103684. * 0.6 by default if setupImageProcessing is true.
  103685. */
  103686. cameraExposure: number;
  103687. /**
  103688. * The value of the contrast to apply to the scene.
  103689. * 1.6 by default if setupImageProcessing is true.
  103690. */
  103691. cameraContrast: number;
  103692. /**
  103693. * Specifies wether or not tonemapping should be enabled in the scene.
  103694. * true by default if setupImageProcessing is true.
  103695. */
  103696. toneMappingEnabled: boolean;
  103697. }
  103698. /**
  103699. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103700. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103701. * It also helps with the default setup of your imageProcessing configuration.
  103702. */
  103703. export class EnvironmentHelper {
  103704. /**
  103705. * Default ground texture URL.
  103706. */
  103707. private static _groundTextureCDNUrl;
  103708. /**
  103709. * Default skybox texture URL.
  103710. */
  103711. private static _skyboxTextureCDNUrl;
  103712. /**
  103713. * Default environment texture URL.
  103714. */
  103715. private static _environmentTextureCDNUrl;
  103716. /**
  103717. * Creates the default options for the helper.
  103718. */
  103719. private static _getDefaultOptions;
  103720. private _rootMesh;
  103721. /**
  103722. * Gets the root mesh created by the helper.
  103723. */
  103724. readonly rootMesh: Mesh;
  103725. private _skybox;
  103726. /**
  103727. * Gets the skybox created by the helper.
  103728. */
  103729. readonly skybox: Nullable<Mesh>;
  103730. private _skyboxTexture;
  103731. /**
  103732. * Gets the skybox texture created by the helper.
  103733. */
  103734. readonly skyboxTexture: Nullable<BaseTexture>;
  103735. private _skyboxMaterial;
  103736. /**
  103737. * Gets the skybox material created by the helper.
  103738. */
  103739. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103740. private _ground;
  103741. /**
  103742. * Gets the ground mesh created by the helper.
  103743. */
  103744. readonly ground: Nullable<Mesh>;
  103745. private _groundTexture;
  103746. /**
  103747. * Gets the ground texture created by the helper.
  103748. */
  103749. readonly groundTexture: Nullable<BaseTexture>;
  103750. private _groundMirror;
  103751. /**
  103752. * Gets the ground mirror created by the helper.
  103753. */
  103754. readonly groundMirror: Nullable<MirrorTexture>;
  103755. /**
  103756. * Gets the ground mirror render list to helps pushing the meshes
  103757. * you wish in the ground reflection.
  103758. */
  103759. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103760. private _groundMaterial;
  103761. /**
  103762. * Gets the ground material created by the helper.
  103763. */
  103764. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103765. /**
  103766. * Stores the creation options.
  103767. */
  103768. private readonly _scene;
  103769. private _options;
  103770. /**
  103771. * This observable will be notified with any error during the creation of the environment,
  103772. * mainly texture creation errors.
  103773. */
  103774. onErrorObservable: Observable<{
  103775. message?: string;
  103776. exception?: any;
  103777. }>;
  103778. /**
  103779. * constructor
  103780. * @param options Defines the options we want to customize the helper
  103781. * @param scene The scene to add the material to
  103782. */
  103783. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103784. /**
  103785. * Updates the background according to the new options
  103786. * @param options
  103787. */
  103788. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103789. /**
  103790. * Sets the primary color of all the available elements.
  103791. * @param color the main color to affect to the ground and the background
  103792. */
  103793. setMainColor(color: Color3): void;
  103794. /**
  103795. * Setup the image processing according to the specified options.
  103796. */
  103797. private _setupImageProcessing;
  103798. /**
  103799. * Setup the environment texture according to the specified options.
  103800. */
  103801. private _setupEnvironmentTexture;
  103802. /**
  103803. * Setup the background according to the specified options.
  103804. */
  103805. private _setupBackground;
  103806. /**
  103807. * Get the scene sizes according to the setup.
  103808. */
  103809. private _getSceneSize;
  103810. /**
  103811. * Setup the ground according to the specified options.
  103812. */
  103813. private _setupGround;
  103814. /**
  103815. * Setup the ground material according to the specified options.
  103816. */
  103817. private _setupGroundMaterial;
  103818. /**
  103819. * Setup the ground diffuse texture according to the specified options.
  103820. */
  103821. private _setupGroundDiffuseTexture;
  103822. /**
  103823. * Setup the ground mirror texture according to the specified options.
  103824. */
  103825. private _setupGroundMirrorTexture;
  103826. /**
  103827. * Setup the ground to receive the mirror texture.
  103828. */
  103829. private _setupMirrorInGroundMaterial;
  103830. /**
  103831. * Setup the skybox according to the specified options.
  103832. */
  103833. private _setupSkybox;
  103834. /**
  103835. * Setup the skybox material according to the specified options.
  103836. */
  103837. private _setupSkyboxMaterial;
  103838. /**
  103839. * Setup the skybox reflection texture according to the specified options.
  103840. */
  103841. private _setupSkyboxReflectionTexture;
  103842. private _errorHandler;
  103843. /**
  103844. * Dispose all the elements created by the Helper.
  103845. */
  103846. dispose(): void;
  103847. }
  103848. }
  103849. declare module BABYLON {
  103850. /**
  103851. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  103852. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103853. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103854. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103855. */
  103856. export class PhotoDome extends TransformNode {
  103857. private _useDirectMapping;
  103858. /**
  103859. * The texture being displayed on the sphere
  103860. */
  103861. protected _photoTexture: Texture;
  103862. /**
  103863. * Gets or sets the texture being displayed on the sphere
  103864. */
  103865. photoTexture: Texture;
  103866. /**
  103867. * Observable raised when an error occured while loading the 360 image
  103868. */
  103869. onLoadErrorObservable: Observable<string>;
  103870. /**
  103871. * The skybox material
  103872. */
  103873. protected _material: BackgroundMaterial;
  103874. /**
  103875. * The surface used for the skybox
  103876. */
  103877. protected _mesh: Mesh;
  103878. /**
  103879. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103880. * Also see the options.resolution property.
  103881. */
  103882. fovMultiplier: number;
  103883. /**
  103884. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103885. * @param name Element's name, child elements will append suffixes for their own names.
  103886. * @param urlsOfPhoto defines the url of the photo to display
  103887. * @param options defines an object containing optional or exposed sub element properties
  103888. * @param onError defines a callback called when an error occured while loading the texture
  103889. */
  103890. constructor(name: string, urlOfPhoto: string, options: {
  103891. resolution?: number;
  103892. size?: number;
  103893. useDirectMapping?: boolean;
  103894. faceForward?: boolean;
  103895. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103896. /**
  103897. * Releases resources associated with this node.
  103898. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103899. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103900. */
  103901. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103902. }
  103903. }
  103904. declare module BABYLON {
  103905. /** @hidden */
  103906. export var rgbdDecodePixelShader: {
  103907. name: string;
  103908. shader: string;
  103909. };
  103910. }
  103911. declare module BABYLON {
  103912. /**
  103913. * Class used to host texture specific utilities
  103914. */
  103915. export class BRDFTextureTools {
  103916. /**
  103917. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103918. * @param texture the texture to expand.
  103919. */
  103920. private static _ExpandDefaultBRDFTexture;
  103921. /**
  103922. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103923. * @param scene defines the hosting scene
  103924. * @returns the environment BRDF texture
  103925. */
  103926. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103927. private static _environmentBRDFBase64Texture;
  103928. }
  103929. }
  103930. declare module BABYLON {
  103931. /**
  103932. * @hidden
  103933. */
  103934. export interface IMaterialClearCoatDefines {
  103935. CLEARCOAT: boolean;
  103936. CLEARCOAT_DEFAULTIOR: boolean;
  103937. CLEARCOAT_TEXTURE: boolean;
  103938. CLEARCOAT_TEXTUREDIRECTUV: number;
  103939. CLEARCOAT_BUMP: boolean;
  103940. CLEARCOAT_BUMPDIRECTUV: number;
  103941. CLEARCOAT_TINT: boolean;
  103942. CLEARCOAT_TINT_TEXTURE: boolean;
  103943. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103944. /** @hidden */
  103945. _areTexturesDirty: boolean;
  103946. }
  103947. /**
  103948. * Define the code related to the clear coat parameters of the pbr material.
  103949. */
  103950. export class PBRClearCoatConfiguration {
  103951. /**
  103952. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103953. * The default fits with a polyurethane material.
  103954. */
  103955. private static readonly _DefaultIndiceOfRefraction;
  103956. private _isEnabled;
  103957. /**
  103958. * Defines if the clear coat is enabled in the material.
  103959. */
  103960. isEnabled: boolean;
  103961. /**
  103962. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103963. */
  103964. intensity: number;
  103965. /**
  103966. * Defines the clear coat layer roughness.
  103967. */
  103968. roughness: number;
  103969. private _indiceOfRefraction;
  103970. /**
  103971. * Defines the indice of refraction of the clear coat.
  103972. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103973. * The default fits with a polyurethane material.
  103974. * Changing the default value is more performance intensive.
  103975. */
  103976. indiceOfRefraction: number;
  103977. private _texture;
  103978. /**
  103979. * Stores the clear coat values in a texture.
  103980. */
  103981. texture: Nullable<BaseTexture>;
  103982. private _bumpTexture;
  103983. /**
  103984. * Define the clear coat specific bump texture.
  103985. */
  103986. bumpTexture: Nullable<BaseTexture>;
  103987. private _isTintEnabled;
  103988. /**
  103989. * Defines if the clear coat tint is enabled in the material.
  103990. */
  103991. isTintEnabled: boolean;
  103992. /**
  103993. * Defines the clear coat tint of the material.
  103994. * This is only use if tint is enabled
  103995. */
  103996. tintColor: Color3;
  103997. /**
  103998. * Defines the distance at which the tint color should be found in the
  103999. * clear coat media.
  104000. * This is only use if tint is enabled
  104001. */
  104002. tintColorAtDistance: number;
  104003. /**
  104004. * Defines the clear coat layer thickness.
  104005. * This is only use if tint is enabled
  104006. */
  104007. tintThickness: number;
  104008. private _tintTexture;
  104009. /**
  104010. * Stores the clear tint values in a texture.
  104011. * rgb is tint
  104012. * a is a thickness factor
  104013. */
  104014. tintTexture: Nullable<BaseTexture>;
  104015. /** @hidden */
  104016. private _internalMarkAllSubMeshesAsTexturesDirty;
  104017. /** @hidden */
  104018. _markAllSubMeshesAsTexturesDirty(): void;
  104019. /**
  104020. * Instantiate a new istance of clear coat configuration.
  104021. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104022. */
  104023. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104024. /**
  104025. * Gets wehter the submesh is ready to be used or not.
  104026. * @param defines the list of "defines" to update.
  104027. * @param scene defines the scene the material belongs to.
  104028. * @param engine defines the engine the material belongs to.
  104029. * @param disableBumpMap defines wether the material disables bump or not.
  104030. * @returns - boolean indicating that the submesh is ready or not.
  104031. */
  104032. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  104033. /**
  104034. * Checks to see if a texture is used in the material.
  104035. * @param defines the list of "defines" to update.
  104036. * @param scene defines the scene to the material belongs to.
  104037. */
  104038. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  104039. /**
  104040. * Binds the material data.
  104041. * @param uniformBuffer defines the Uniform buffer to fill in.
  104042. * @param scene defines the scene the material belongs to.
  104043. * @param engine defines the engine the material belongs to.
  104044. * @param disableBumpMap defines wether the material disables bump or not.
  104045. * @param isFrozen defines wether the material is frozen or not.
  104046. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104047. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104048. */
  104049. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  104050. /**
  104051. * Checks to see if a texture is used in the material.
  104052. * @param texture - Base texture to use.
  104053. * @returns - Boolean specifying if a texture is used in the material.
  104054. */
  104055. hasTexture(texture: BaseTexture): boolean;
  104056. /**
  104057. * Returns an array of the actively used textures.
  104058. * @param activeTextures Array of BaseTextures
  104059. */
  104060. getActiveTextures(activeTextures: BaseTexture[]): void;
  104061. /**
  104062. * Returns the animatable textures.
  104063. * @param animatables Array of animatable textures.
  104064. */
  104065. getAnimatables(animatables: IAnimatable[]): void;
  104066. /**
  104067. * Disposes the resources of the material.
  104068. * @param forceDisposeTextures - Forces the disposal of all textures.
  104069. */
  104070. dispose(forceDisposeTextures?: boolean): void;
  104071. /**
  104072. * Get the current class name of the texture useful for serialization or dynamic coding.
  104073. * @returns "PBRClearCoatConfiguration"
  104074. */
  104075. getClassName(): string;
  104076. /**
  104077. * Add fallbacks to the effect fallbacks list.
  104078. * @param defines defines the Base texture to use.
  104079. * @param fallbacks defines the current fallback list.
  104080. * @param currentRank defines the current fallback rank.
  104081. * @returns the new fallback rank.
  104082. */
  104083. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104084. /**
  104085. * Add the required uniforms to the current list.
  104086. * @param uniforms defines the current uniform list.
  104087. */
  104088. static AddUniforms(uniforms: string[]): void;
  104089. /**
  104090. * Add the required samplers to the current list.
  104091. * @param samplers defines the current sampler list.
  104092. */
  104093. static AddSamplers(samplers: string[]): void;
  104094. /**
  104095. * Add the required uniforms to the current buffer.
  104096. * @param uniformBuffer defines the current uniform buffer.
  104097. */
  104098. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104099. /**
  104100. * Makes a duplicate of the current configuration into another one.
  104101. * @param clearCoatConfiguration define the config where to copy the info
  104102. */
  104103. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104104. /**
  104105. * Serializes this clear coat configuration.
  104106. * @returns - An object with the serialized config.
  104107. */
  104108. serialize(): any;
  104109. /**
  104110. * Parses a Clear Coat Configuration from a serialized object.
  104111. * @param source - Serialized object.
  104112. */
  104113. parse(source: any): void;
  104114. }
  104115. }
  104116. declare module BABYLON {
  104117. /**
  104118. * @hidden
  104119. */
  104120. export interface IMaterialAnisotropicDefines {
  104121. ANISOTROPIC: boolean;
  104122. ANISOTROPIC_TEXTURE: boolean;
  104123. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104124. MAINUV1: boolean;
  104125. _areTexturesDirty: boolean;
  104126. _needUVs: boolean;
  104127. }
  104128. /**
  104129. * Define the code related to the anisotropic parameters of the pbr material.
  104130. */
  104131. export class PBRAnisotropicConfiguration {
  104132. private _isEnabled;
  104133. /**
  104134. * Defines if the anisotropy is enabled in the material.
  104135. */
  104136. isEnabled: boolean;
  104137. /**
  104138. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104139. */
  104140. intensity: number;
  104141. /**
  104142. * Defines if the effect is along the tangents, bitangents or in between.
  104143. * By default, the effect is "strectching" the highlights along the tangents.
  104144. */
  104145. direction: Vector2;
  104146. private _texture;
  104147. /**
  104148. * Stores the anisotropy values in a texture.
  104149. * rg is direction (like normal from -1 to 1)
  104150. * b is a intensity
  104151. */
  104152. texture: Nullable<BaseTexture>;
  104153. /** @hidden */
  104154. private _internalMarkAllSubMeshesAsTexturesDirty;
  104155. /** @hidden */
  104156. _markAllSubMeshesAsTexturesDirty(): void;
  104157. /**
  104158. * Instantiate a new istance of anisotropy configuration.
  104159. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104160. */
  104161. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104162. /**
  104163. * Specifies that the submesh is ready to be used.
  104164. * @param defines the list of "defines" to update.
  104165. * @param scene defines the scene the material belongs to.
  104166. * @returns - boolean indicating that the submesh is ready or not.
  104167. */
  104168. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104169. /**
  104170. * Checks to see if a texture is used in the material.
  104171. * @param defines the list of "defines" to update.
  104172. * @param mesh the mesh we are preparing the defines for.
  104173. * @param scene defines the scene the material belongs to.
  104174. */
  104175. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104176. /**
  104177. * Binds the material data.
  104178. * @param uniformBuffer defines the Uniform buffer to fill in.
  104179. * @param scene defines the scene the material belongs to.
  104180. * @param isFrozen defines wether the material is frozen or not.
  104181. */
  104182. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104183. /**
  104184. * Checks to see if a texture is used in the material.
  104185. * @param texture - Base texture to use.
  104186. * @returns - Boolean specifying if a texture is used in the material.
  104187. */
  104188. hasTexture(texture: BaseTexture): boolean;
  104189. /**
  104190. * Returns an array of the actively used textures.
  104191. * @param activeTextures Array of BaseTextures
  104192. */
  104193. getActiveTextures(activeTextures: BaseTexture[]): void;
  104194. /**
  104195. * Returns the animatable textures.
  104196. * @param animatables Array of animatable textures.
  104197. */
  104198. getAnimatables(animatables: IAnimatable[]): void;
  104199. /**
  104200. * Disposes the resources of the material.
  104201. * @param forceDisposeTextures - Forces the disposal of all textures.
  104202. */
  104203. dispose(forceDisposeTextures?: boolean): void;
  104204. /**
  104205. * Get the current class name of the texture useful for serialization or dynamic coding.
  104206. * @returns "PBRAnisotropicConfiguration"
  104207. */
  104208. getClassName(): string;
  104209. /**
  104210. * Add fallbacks to the effect fallbacks list.
  104211. * @param defines defines the Base texture to use.
  104212. * @param fallbacks defines the current fallback list.
  104213. * @param currentRank defines the current fallback rank.
  104214. * @returns the new fallback rank.
  104215. */
  104216. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104217. /**
  104218. * Add the required uniforms to the current list.
  104219. * @param uniforms defines the current uniform list.
  104220. */
  104221. static AddUniforms(uniforms: string[]): void;
  104222. /**
  104223. * Add the required uniforms to the current buffer.
  104224. * @param uniformBuffer defines the current uniform buffer.
  104225. */
  104226. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104227. /**
  104228. * Add the required samplers to the current list.
  104229. * @param samplers defines the current sampler list.
  104230. */
  104231. static AddSamplers(samplers: string[]): void;
  104232. /**
  104233. * Makes a duplicate of the current configuration into another one.
  104234. * @param anisotropicConfiguration define the config where to copy the info
  104235. */
  104236. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104237. /**
  104238. * Serializes this anisotropy configuration.
  104239. * @returns - An object with the serialized config.
  104240. */
  104241. serialize(): any;
  104242. /**
  104243. * Parses a anisotropy Configuration from a serialized object.
  104244. * @param source - Serialized object.
  104245. */
  104246. parse(source: any): void;
  104247. }
  104248. }
  104249. declare module BABYLON {
  104250. /**
  104251. * @hidden
  104252. */
  104253. export interface IMaterialBRDFDefines {
  104254. BRDF_V_HEIGHT_CORRELATED: boolean;
  104255. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104256. SPHERICAL_HARMONICS: boolean;
  104257. /** @hidden */
  104258. _areMiscDirty: boolean;
  104259. }
  104260. /**
  104261. * Define the code related to the BRDF parameters of the pbr material.
  104262. */
  104263. export class PBRBRDFConfiguration {
  104264. /**
  104265. * Default value used for the energy conservation.
  104266. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104267. */
  104268. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104269. /**
  104270. * Default value used for the Smith Visibility Height Correlated mode.
  104271. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104272. */
  104273. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104274. /**
  104275. * Default value used for the IBL diffuse part.
  104276. * This can help switching back to the polynomials mode globally which is a tiny bit
  104277. * less GPU intensive at the drawback of a lower quality.
  104278. */
  104279. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  104280. private _useEnergyConservation;
  104281. /**
  104282. * Defines if the material uses energy conservation.
  104283. */
  104284. useEnergyConservation: boolean;
  104285. private _useSmithVisibilityHeightCorrelated;
  104286. /**
  104287. * LEGACY Mode set to false
  104288. * Defines if the material uses height smith correlated visibility term.
  104289. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104290. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104291. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104292. * Not relying on height correlated will also disable energy conservation.
  104293. */
  104294. useSmithVisibilityHeightCorrelated: boolean;
  104295. private _useSphericalHarmonics;
  104296. /**
  104297. * LEGACY Mode set to false
  104298. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  104299. * diffuse part of the IBL.
  104300. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  104301. * to the ground truth.
  104302. */
  104303. useSphericalHarmonics: boolean;
  104304. /** @hidden */
  104305. private _internalMarkAllSubMeshesAsMiscDirty;
  104306. /** @hidden */
  104307. _markAllSubMeshesAsMiscDirty(): void;
  104308. /**
  104309. * Instantiate a new istance of clear coat configuration.
  104310. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104311. */
  104312. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104313. /**
  104314. * Checks to see if a texture is used in the material.
  104315. * @param defines the list of "defines" to update.
  104316. */
  104317. prepareDefines(defines: IMaterialBRDFDefines): void;
  104318. /**
  104319. * Get the current class name of the texture useful for serialization or dynamic coding.
  104320. * @returns "PBRClearCoatConfiguration"
  104321. */
  104322. getClassName(): string;
  104323. /**
  104324. * Makes a duplicate of the current configuration into another one.
  104325. * @param brdfConfiguration define the config where to copy the info
  104326. */
  104327. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104328. /**
  104329. * Serializes this BRDF configuration.
  104330. * @returns - An object with the serialized config.
  104331. */
  104332. serialize(): any;
  104333. /**
  104334. * Parses a BRDF Configuration from a serialized object.
  104335. * @param source - Serialized object.
  104336. */
  104337. parse(source: any): void;
  104338. }
  104339. }
  104340. declare module BABYLON {
  104341. /**
  104342. * @hidden
  104343. */
  104344. export interface IMaterialSheenDefines {
  104345. SHEEN: boolean;
  104346. SHEEN_TEXTURE: boolean;
  104347. SHEEN_TEXTUREDIRECTUV: number;
  104348. SHEEN_LINKWITHALBEDO: boolean;
  104349. /** @hidden */
  104350. _areTexturesDirty: boolean;
  104351. }
  104352. /**
  104353. * Define the code related to the Sheen parameters of the pbr material.
  104354. */
  104355. export class PBRSheenConfiguration {
  104356. private _isEnabled;
  104357. /**
  104358. * Defines if the material uses sheen.
  104359. */
  104360. isEnabled: boolean;
  104361. private _linkSheenWithAlbedo;
  104362. /**
  104363. * Defines if the sheen is linked to the sheen color.
  104364. */
  104365. linkSheenWithAlbedo: boolean;
  104366. /**
  104367. * Defines the sheen intensity.
  104368. */
  104369. intensity: number;
  104370. /**
  104371. * Defines the sheen color.
  104372. */
  104373. color: Color3;
  104374. private _texture;
  104375. /**
  104376. * Stores the sheen tint values in a texture.
  104377. * rgb is tint
  104378. * a is a intensity
  104379. */
  104380. texture: Nullable<BaseTexture>;
  104381. /** @hidden */
  104382. private _internalMarkAllSubMeshesAsTexturesDirty;
  104383. /** @hidden */
  104384. _markAllSubMeshesAsTexturesDirty(): void;
  104385. /**
  104386. * Instantiate a new istance of clear coat configuration.
  104387. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104388. */
  104389. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104390. /**
  104391. * Specifies that the submesh is ready to be used.
  104392. * @param defines the list of "defines" to update.
  104393. * @param scene defines the scene the material belongs to.
  104394. * @returns - boolean indicating that the submesh is ready or not.
  104395. */
  104396. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  104397. /**
  104398. * Checks to see if a texture is used in the material.
  104399. * @param defines the list of "defines" to update.
  104400. * @param scene defines the scene the material belongs to.
  104401. */
  104402. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  104403. /**
  104404. * Binds the material data.
  104405. * @param uniformBuffer defines the Uniform buffer to fill in.
  104406. * @param scene defines the scene the material belongs to.
  104407. * @param isFrozen defines wether the material is frozen or not.
  104408. */
  104409. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104410. /**
  104411. * Checks to see if a texture is used in the material.
  104412. * @param texture - Base texture to use.
  104413. * @returns - Boolean specifying if a texture is used in the material.
  104414. */
  104415. hasTexture(texture: BaseTexture): boolean;
  104416. /**
  104417. * Returns an array of the actively used textures.
  104418. * @param activeTextures Array of BaseTextures
  104419. */
  104420. getActiveTextures(activeTextures: BaseTexture[]): void;
  104421. /**
  104422. * Returns the animatable textures.
  104423. * @param animatables Array of animatable textures.
  104424. */
  104425. getAnimatables(animatables: IAnimatable[]): void;
  104426. /**
  104427. * Disposes the resources of the material.
  104428. * @param forceDisposeTextures - Forces the disposal of all textures.
  104429. */
  104430. dispose(forceDisposeTextures?: boolean): void;
  104431. /**
  104432. * Get the current class name of the texture useful for serialization or dynamic coding.
  104433. * @returns "PBRSheenConfiguration"
  104434. */
  104435. getClassName(): string;
  104436. /**
  104437. * Add fallbacks to the effect fallbacks list.
  104438. * @param defines defines the Base texture to use.
  104439. * @param fallbacks defines the current fallback list.
  104440. * @param currentRank defines the current fallback rank.
  104441. * @returns the new fallback rank.
  104442. */
  104443. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104444. /**
  104445. * Add the required uniforms to the current list.
  104446. * @param uniforms defines the current uniform list.
  104447. */
  104448. static AddUniforms(uniforms: string[]): void;
  104449. /**
  104450. * Add the required uniforms to the current buffer.
  104451. * @param uniformBuffer defines the current uniform buffer.
  104452. */
  104453. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104454. /**
  104455. * Add the required samplers to the current list.
  104456. * @param samplers defines the current sampler list.
  104457. */
  104458. static AddSamplers(samplers: string[]): void;
  104459. /**
  104460. * Makes a duplicate of the current configuration into another one.
  104461. * @param sheenConfiguration define the config where to copy the info
  104462. */
  104463. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  104464. /**
  104465. * Serializes this BRDF configuration.
  104466. * @returns - An object with the serialized config.
  104467. */
  104468. serialize(): any;
  104469. /**
  104470. * Parses a Sheen Configuration from a serialized object.
  104471. * @param source - Serialized object.
  104472. */
  104473. parse(source: any): void;
  104474. }
  104475. }
  104476. declare module BABYLON {
  104477. /**
  104478. * @hidden
  104479. */
  104480. export interface IMaterialSubSurfaceDefines {
  104481. SUBSURFACE: boolean;
  104482. SS_REFRACTION: boolean;
  104483. SS_TRANSLUCENCY: boolean;
  104484. SS_SCATERRING: boolean;
  104485. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104486. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104487. SS_REFRACTIONMAP_3D: boolean;
  104488. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104489. SS_LODINREFRACTIONALPHA: boolean;
  104490. SS_GAMMAREFRACTION: boolean;
  104491. SS_RGBDREFRACTION: boolean;
  104492. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104493. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104494. /** @hidden */
  104495. _areTexturesDirty: boolean;
  104496. }
  104497. /**
  104498. * Define the code related to the sub surface parameters of the pbr material.
  104499. */
  104500. export class PBRSubSurfaceConfiguration {
  104501. private _isRefractionEnabled;
  104502. /**
  104503. * Defines if the refraction is enabled in the material.
  104504. */
  104505. isRefractionEnabled: boolean;
  104506. private _isTranslucencyEnabled;
  104507. /**
  104508. * Defines if the translucency is enabled in the material.
  104509. */
  104510. isTranslucencyEnabled: boolean;
  104511. private _isScatteringEnabled;
  104512. /**
  104513. * Defines the refraction intensity of the material.
  104514. * The refraction when enabled replaces the Diffuse part of the material.
  104515. * The intensity helps transitionning between diffuse and refraction.
  104516. */
  104517. refractionIntensity: number;
  104518. /**
  104519. * Defines the translucency intensity of the material.
  104520. * When translucency has been enabled, this defines how much of the "translucency"
  104521. * is addded to the diffuse part of the material.
  104522. */
  104523. translucencyIntensity: number;
  104524. /**
  104525. * Defines the scattering intensity of the material.
  104526. * When scattering has been enabled, this defines how much of the "scattered light"
  104527. * is addded to the diffuse part of the material.
  104528. */
  104529. scatteringIntensity: number;
  104530. private _thicknessTexture;
  104531. /**
  104532. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  104533. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  104534. * 0 would mean minimumThickness
  104535. * 1 would mean maximumThickness
  104536. * The other channels might be use as a mask to vary the different effects intensity.
  104537. */
  104538. thicknessTexture: Nullable<BaseTexture>;
  104539. private _refractionTexture;
  104540. /**
  104541. * Defines the texture to use for refraction.
  104542. */
  104543. refractionTexture: Nullable<BaseTexture>;
  104544. private _indexOfRefraction;
  104545. /**
  104546. * Defines the indice of refraction used in the material.
  104547. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104548. */
  104549. indexOfRefraction: number;
  104550. private _invertRefractionY;
  104551. /**
  104552. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104553. */
  104554. invertRefractionY: boolean;
  104555. private _linkRefractionWithTransparency;
  104556. /**
  104557. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104558. * Materials half opaque for instance using refraction could benefit from this control.
  104559. */
  104560. linkRefractionWithTransparency: boolean;
  104561. /**
  104562. * Defines the minimum thickness stored in the thickness map.
  104563. * If no thickness map is defined, this value will be used to simulate thickness.
  104564. */
  104565. minimumThickness: number;
  104566. /**
  104567. * Defines the maximum thickness stored in the thickness map.
  104568. */
  104569. maximumThickness: number;
  104570. /**
  104571. * Defines the volume tint of the material.
  104572. * This is used for both translucency and scattering.
  104573. */
  104574. tintColor: Color3;
  104575. /**
  104576. * Defines the distance at which the tint color should be found in the media.
  104577. * This is used for refraction only.
  104578. */
  104579. tintColorAtDistance: number;
  104580. /**
  104581. * Defines how far each channel transmit through the media.
  104582. * It is defined as a color to simplify it selection.
  104583. */
  104584. diffusionDistance: Color3;
  104585. private _useMaskFromThicknessTexture;
  104586. /**
  104587. * Stores the intensity of the different subsurface effects in the thickness texture.
  104588. * * the green channel is the translucency intensity.
  104589. * * the blue channel is the scattering intensity.
  104590. * * the alpha channel is the refraction intensity.
  104591. */
  104592. useMaskFromThicknessTexture: boolean;
  104593. /** @hidden */
  104594. private _internalMarkAllSubMeshesAsTexturesDirty;
  104595. /** @hidden */
  104596. _markAllSubMeshesAsTexturesDirty(): void;
  104597. /**
  104598. * Instantiate a new istance of sub surface configuration.
  104599. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104600. */
  104601. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104602. /**
  104603. * Gets wehter the submesh is ready to be used or not.
  104604. * @param defines the list of "defines" to update.
  104605. * @param scene defines the scene the material belongs to.
  104606. * @returns - boolean indicating that the submesh is ready or not.
  104607. */
  104608. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104609. /**
  104610. * Checks to see if a texture is used in the material.
  104611. * @param defines the list of "defines" to update.
  104612. * @param scene defines the scene to the material belongs to.
  104613. */
  104614. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104615. /**
  104616. * Binds the material data.
  104617. * @param uniformBuffer defines the Uniform buffer to fill in.
  104618. * @param scene defines the scene the material belongs to.
  104619. * @param engine defines the engine the material belongs to.
  104620. * @param isFrozen defines wether the material is frozen or not.
  104621. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104622. */
  104623. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104624. /**
  104625. * Unbinds the material from the mesh.
  104626. * @param activeEffect defines the effect that should be unbound from.
  104627. * @returns true if unbound, otherwise false
  104628. */
  104629. unbind(activeEffect: Effect): boolean;
  104630. /**
  104631. * Returns the texture used for refraction or null if none is used.
  104632. * @param scene defines the scene the material belongs to.
  104633. * @returns - Refraction texture if present. If no refraction texture and refraction
  104634. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104635. */
  104636. private _getRefractionTexture;
  104637. /**
  104638. * Returns true if alpha blending should be disabled.
  104639. */
  104640. readonly disableAlphaBlending: boolean;
  104641. /**
  104642. * Fills the list of render target textures.
  104643. * @param renderTargets the list of render targets to update
  104644. */
  104645. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104646. /**
  104647. * Checks to see if a texture is used in the material.
  104648. * @param texture - Base texture to use.
  104649. * @returns - Boolean specifying if a texture is used in the material.
  104650. */
  104651. hasTexture(texture: BaseTexture): boolean;
  104652. /**
  104653. * Gets a boolean indicating that current material needs to register RTT
  104654. * @returns true if this uses a render target otherwise false.
  104655. */
  104656. hasRenderTargetTextures(): boolean;
  104657. /**
  104658. * Returns an array of the actively used textures.
  104659. * @param activeTextures Array of BaseTextures
  104660. */
  104661. getActiveTextures(activeTextures: BaseTexture[]): void;
  104662. /**
  104663. * Returns the animatable textures.
  104664. * @param animatables Array of animatable textures.
  104665. */
  104666. getAnimatables(animatables: IAnimatable[]): void;
  104667. /**
  104668. * Disposes the resources of the material.
  104669. * @param forceDisposeTextures - Forces the disposal of all textures.
  104670. */
  104671. dispose(forceDisposeTextures?: boolean): void;
  104672. /**
  104673. * Get the current class name of the texture useful for serialization or dynamic coding.
  104674. * @returns "PBRSubSurfaceConfiguration"
  104675. */
  104676. getClassName(): string;
  104677. /**
  104678. * Add fallbacks to the effect fallbacks list.
  104679. * @param defines defines the Base texture to use.
  104680. * @param fallbacks defines the current fallback list.
  104681. * @param currentRank defines the current fallback rank.
  104682. * @returns the new fallback rank.
  104683. */
  104684. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104685. /**
  104686. * Add the required uniforms to the current list.
  104687. * @param uniforms defines the current uniform list.
  104688. */
  104689. static AddUniforms(uniforms: string[]): void;
  104690. /**
  104691. * Add the required samplers to the current list.
  104692. * @param samplers defines the current sampler list.
  104693. */
  104694. static AddSamplers(samplers: string[]): void;
  104695. /**
  104696. * Add the required uniforms to the current buffer.
  104697. * @param uniformBuffer defines the current uniform buffer.
  104698. */
  104699. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104700. /**
  104701. * Makes a duplicate of the current configuration into another one.
  104702. * @param configuration define the config where to copy the info
  104703. */
  104704. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104705. /**
  104706. * Serializes this Sub Surface configuration.
  104707. * @returns - An object with the serialized config.
  104708. */
  104709. serialize(): any;
  104710. /**
  104711. * Parses a Sub Surface Configuration from a serialized object.
  104712. * @param source - Serialized object.
  104713. */
  104714. parse(source: any): void;
  104715. }
  104716. }
  104717. declare module BABYLON {
  104718. /** @hidden */
  104719. export var pbrFragmentDeclaration: {
  104720. name: string;
  104721. shader: string;
  104722. };
  104723. }
  104724. declare module BABYLON {
  104725. /** @hidden */
  104726. export var pbrUboDeclaration: {
  104727. name: string;
  104728. shader: string;
  104729. };
  104730. }
  104731. declare module BABYLON {
  104732. /** @hidden */
  104733. export var pbrFragmentExtraDeclaration: {
  104734. name: string;
  104735. shader: string;
  104736. };
  104737. }
  104738. declare module BABYLON {
  104739. /** @hidden */
  104740. export var pbrFragmentSamplersDeclaration: {
  104741. name: string;
  104742. shader: string;
  104743. };
  104744. }
  104745. declare module BABYLON {
  104746. /** @hidden */
  104747. export var pbrHelperFunctions: {
  104748. name: string;
  104749. shader: string;
  104750. };
  104751. }
  104752. declare module BABYLON {
  104753. /** @hidden */
  104754. export var harmonicsFunctions: {
  104755. name: string;
  104756. shader: string;
  104757. };
  104758. }
  104759. declare module BABYLON {
  104760. /** @hidden */
  104761. export var pbrDirectLightingSetupFunctions: {
  104762. name: string;
  104763. shader: string;
  104764. };
  104765. }
  104766. declare module BABYLON {
  104767. /** @hidden */
  104768. export var pbrDirectLightingFalloffFunctions: {
  104769. name: string;
  104770. shader: string;
  104771. };
  104772. }
  104773. declare module BABYLON {
  104774. /** @hidden */
  104775. export var pbrBRDFFunctions: {
  104776. name: string;
  104777. shader: string;
  104778. };
  104779. }
  104780. declare module BABYLON {
  104781. /** @hidden */
  104782. export var pbrDirectLightingFunctions: {
  104783. name: string;
  104784. shader: string;
  104785. };
  104786. }
  104787. declare module BABYLON {
  104788. /** @hidden */
  104789. export var pbrIBLFunctions: {
  104790. name: string;
  104791. shader: string;
  104792. };
  104793. }
  104794. declare module BABYLON {
  104795. /** @hidden */
  104796. export var pbrDebug: {
  104797. name: string;
  104798. shader: string;
  104799. };
  104800. }
  104801. declare module BABYLON {
  104802. /** @hidden */
  104803. export var pbrPixelShader: {
  104804. name: string;
  104805. shader: string;
  104806. };
  104807. }
  104808. declare module BABYLON {
  104809. /** @hidden */
  104810. export var pbrVertexDeclaration: {
  104811. name: string;
  104812. shader: string;
  104813. };
  104814. }
  104815. declare module BABYLON {
  104816. /** @hidden */
  104817. export var pbrVertexShader: {
  104818. name: string;
  104819. shader: string;
  104820. };
  104821. }
  104822. declare module BABYLON {
  104823. /**
  104824. * Manages the defines for the PBR Material.
  104825. * @hidden
  104826. */
  104827. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  104828. PBR: boolean;
  104829. MAINUV1: boolean;
  104830. MAINUV2: boolean;
  104831. UV1: boolean;
  104832. UV2: boolean;
  104833. ALBEDO: boolean;
  104834. ALBEDODIRECTUV: number;
  104835. VERTEXCOLOR: boolean;
  104836. AMBIENT: boolean;
  104837. AMBIENTDIRECTUV: number;
  104838. AMBIENTINGRAYSCALE: boolean;
  104839. OPACITY: boolean;
  104840. VERTEXALPHA: boolean;
  104841. OPACITYDIRECTUV: number;
  104842. OPACITYRGB: boolean;
  104843. ALPHATEST: boolean;
  104844. DEPTHPREPASS: boolean;
  104845. ALPHABLEND: boolean;
  104846. ALPHAFROMALBEDO: boolean;
  104847. ALPHATESTVALUE: string;
  104848. SPECULAROVERALPHA: boolean;
  104849. RADIANCEOVERALPHA: boolean;
  104850. ALPHAFRESNEL: boolean;
  104851. LINEARALPHAFRESNEL: boolean;
  104852. PREMULTIPLYALPHA: boolean;
  104853. EMISSIVE: boolean;
  104854. EMISSIVEDIRECTUV: number;
  104855. REFLECTIVITY: boolean;
  104856. REFLECTIVITYDIRECTUV: number;
  104857. SPECULARTERM: boolean;
  104858. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  104859. MICROSURFACEAUTOMATIC: boolean;
  104860. LODBASEDMICROSFURACE: boolean;
  104861. MICROSURFACEMAP: boolean;
  104862. MICROSURFACEMAPDIRECTUV: number;
  104863. METALLICWORKFLOW: boolean;
  104864. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  104865. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  104866. METALLNESSSTOREINMETALMAPBLUE: boolean;
  104867. AOSTOREINMETALMAPRED: boolean;
  104868. ENVIRONMENTBRDF: boolean;
  104869. ENVIRONMENTBRDF_RGBD: boolean;
  104870. NORMAL: boolean;
  104871. TANGENT: boolean;
  104872. BUMP: boolean;
  104873. BUMPDIRECTUV: number;
  104874. OBJECTSPACE_NORMALMAP: boolean;
  104875. PARALLAX: boolean;
  104876. PARALLAXOCCLUSION: boolean;
  104877. NORMALXYSCALE: boolean;
  104878. LIGHTMAP: boolean;
  104879. LIGHTMAPDIRECTUV: number;
  104880. USELIGHTMAPASSHADOWMAP: boolean;
  104881. GAMMALIGHTMAP: boolean;
  104882. REFLECTION: boolean;
  104883. REFLECTIONMAP_3D: boolean;
  104884. REFLECTIONMAP_SPHERICAL: boolean;
  104885. REFLECTIONMAP_PLANAR: boolean;
  104886. REFLECTIONMAP_CUBIC: boolean;
  104887. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104888. REFLECTIONMAP_PROJECTION: boolean;
  104889. REFLECTIONMAP_SKYBOX: boolean;
  104890. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104891. REFLECTIONMAP_EXPLICIT: boolean;
  104892. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104893. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104894. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104895. INVERTCUBICMAP: boolean;
  104896. USESPHERICALFROMREFLECTIONMAP: boolean;
  104897. SPHERICAL_HARMONICS: boolean;
  104898. USESPHERICALINVERTEX: boolean;
  104899. REFLECTIONMAP_OPPOSITEZ: boolean;
  104900. LODINREFLECTIONALPHA: boolean;
  104901. GAMMAREFLECTION: boolean;
  104902. RGBDREFLECTION: boolean;
  104903. RADIANCEOCCLUSION: boolean;
  104904. HORIZONOCCLUSION: boolean;
  104905. INSTANCES: boolean;
  104906. NUM_BONE_INFLUENCERS: number;
  104907. BonesPerMesh: number;
  104908. BONETEXTURE: boolean;
  104909. NONUNIFORMSCALING: boolean;
  104910. MORPHTARGETS: boolean;
  104911. MORPHTARGETS_NORMAL: boolean;
  104912. MORPHTARGETS_TANGENT: boolean;
  104913. NUM_MORPH_INFLUENCERS: number;
  104914. IMAGEPROCESSING: boolean;
  104915. VIGNETTE: boolean;
  104916. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104917. VIGNETTEBLENDMODEOPAQUE: boolean;
  104918. TONEMAPPING: boolean;
  104919. TONEMAPPING_ACES: boolean;
  104920. CONTRAST: boolean;
  104921. COLORCURVES: boolean;
  104922. COLORGRADING: boolean;
  104923. COLORGRADING3D: boolean;
  104924. SAMPLER3DGREENDEPTH: boolean;
  104925. SAMPLER3DBGRMAP: boolean;
  104926. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104927. EXPOSURE: boolean;
  104928. MULTIVIEW: boolean;
  104929. USEPHYSICALLIGHTFALLOFF: boolean;
  104930. USEGLTFLIGHTFALLOFF: boolean;
  104931. TWOSIDEDLIGHTING: boolean;
  104932. SHADOWFLOAT: boolean;
  104933. CLIPPLANE: boolean;
  104934. CLIPPLANE2: boolean;
  104935. CLIPPLANE3: boolean;
  104936. CLIPPLANE4: boolean;
  104937. POINTSIZE: boolean;
  104938. FOG: boolean;
  104939. LOGARITHMICDEPTH: boolean;
  104940. FORCENORMALFORWARD: boolean;
  104941. SPECULARAA: boolean;
  104942. CLEARCOAT: boolean;
  104943. CLEARCOAT_DEFAULTIOR: boolean;
  104944. CLEARCOAT_TEXTURE: boolean;
  104945. CLEARCOAT_TEXTUREDIRECTUV: number;
  104946. CLEARCOAT_BUMP: boolean;
  104947. CLEARCOAT_BUMPDIRECTUV: number;
  104948. CLEARCOAT_TINT: boolean;
  104949. CLEARCOAT_TINT_TEXTURE: boolean;
  104950. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104951. ANISOTROPIC: boolean;
  104952. ANISOTROPIC_TEXTURE: boolean;
  104953. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104954. BRDF_V_HEIGHT_CORRELATED: boolean;
  104955. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104956. SHEEN: boolean;
  104957. SHEEN_TEXTURE: boolean;
  104958. SHEEN_TEXTUREDIRECTUV: number;
  104959. SHEEN_LINKWITHALBEDO: boolean;
  104960. SUBSURFACE: boolean;
  104961. SS_REFRACTION: boolean;
  104962. SS_TRANSLUCENCY: boolean;
  104963. SS_SCATERRING: boolean;
  104964. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104965. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104966. SS_REFRACTIONMAP_3D: boolean;
  104967. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104968. SS_LODINREFRACTIONALPHA: boolean;
  104969. SS_GAMMAREFRACTION: boolean;
  104970. SS_RGBDREFRACTION: boolean;
  104971. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104972. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104973. UNLIT: boolean;
  104974. DEBUGMODE: number;
  104975. /**
  104976. * Initializes the PBR Material defines.
  104977. */
  104978. constructor();
  104979. /**
  104980. * Resets the PBR Material defines.
  104981. */
  104982. reset(): void;
  104983. }
  104984. /**
  104985. * The Physically based material base class of BJS.
  104986. *
  104987. * This offers the main features of a standard PBR material.
  104988. * For more information, please refer to the documentation :
  104989. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104990. */
  104991. export abstract class PBRBaseMaterial extends PushMaterial {
  104992. /**
  104993. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104994. */
  104995. static readonly PBRMATERIAL_OPAQUE: number;
  104996. /**
  104997. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104998. */
  104999. static readonly PBRMATERIAL_ALPHATEST: number;
  105000. /**
  105001. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105002. */
  105003. static readonly PBRMATERIAL_ALPHABLEND: number;
  105004. /**
  105005. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105006. * They are also discarded below the alpha cutoff threshold to improve performances.
  105007. */
  105008. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105009. /**
  105010. * Defines the default value of how much AO map is occluding the analytical lights
  105011. * (point spot...).
  105012. */
  105013. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105014. /**
  105015. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  105016. */
  105017. static readonly LIGHTFALLOFF_PHYSICAL: number;
  105018. /**
  105019. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  105020. * to enhance interoperability with other engines.
  105021. */
  105022. static readonly LIGHTFALLOFF_GLTF: number;
  105023. /**
  105024. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  105025. * to enhance interoperability with other materials.
  105026. */
  105027. static readonly LIGHTFALLOFF_STANDARD: number;
  105028. /**
  105029. * Intensity of the direct lights e.g. the four lights available in your scene.
  105030. * This impacts both the direct diffuse and specular highlights.
  105031. */
  105032. protected _directIntensity: number;
  105033. /**
  105034. * Intensity of the emissive part of the material.
  105035. * This helps controlling the emissive effect without modifying the emissive color.
  105036. */
  105037. protected _emissiveIntensity: number;
  105038. /**
  105039. * Intensity of the environment e.g. how much the environment will light the object
  105040. * either through harmonics for rough material or through the refelction for shiny ones.
  105041. */
  105042. protected _environmentIntensity: number;
  105043. /**
  105044. * This is a special control allowing the reduction of the specular highlights coming from the
  105045. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105046. */
  105047. protected _specularIntensity: number;
  105048. /**
  105049. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  105050. */
  105051. private _lightingInfos;
  105052. /**
  105053. * Debug Control allowing disabling the bump map on this material.
  105054. */
  105055. protected _disableBumpMap: boolean;
  105056. /**
  105057. * AKA Diffuse Texture in standard nomenclature.
  105058. */
  105059. protected _albedoTexture: Nullable<BaseTexture>;
  105060. /**
  105061. * AKA Occlusion Texture in other nomenclature.
  105062. */
  105063. protected _ambientTexture: Nullable<BaseTexture>;
  105064. /**
  105065. * AKA Occlusion Texture Intensity in other nomenclature.
  105066. */
  105067. protected _ambientTextureStrength: number;
  105068. /**
  105069. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105070. * 1 means it completely occludes it
  105071. * 0 mean it has no impact
  105072. */
  105073. protected _ambientTextureImpactOnAnalyticalLights: number;
  105074. /**
  105075. * Stores the alpha values in a texture.
  105076. */
  105077. protected _opacityTexture: Nullable<BaseTexture>;
  105078. /**
  105079. * Stores the reflection values in a texture.
  105080. */
  105081. protected _reflectionTexture: Nullable<BaseTexture>;
  105082. /**
  105083. * Stores the emissive values in a texture.
  105084. */
  105085. protected _emissiveTexture: Nullable<BaseTexture>;
  105086. /**
  105087. * AKA Specular texture in other nomenclature.
  105088. */
  105089. protected _reflectivityTexture: Nullable<BaseTexture>;
  105090. /**
  105091. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105092. */
  105093. protected _metallicTexture: Nullable<BaseTexture>;
  105094. /**
  105095. * Specifies the metallic scalar of the metallic/roughness workflow.
  105096. * Can also be used to scale the metalness values of the metallic texture.
  105097. */
  105098. protected _metallic: Nullable<number>;
  105099. /**
  105100. * Specifies the roughness scalar of the metallic/roughness workflow.
  105101. * Can also be used to scale the roughness values of the metallic texture.
  105102. */
  105103. protected _roughness: Nullable<number>;
  105104. /**
  105105. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105106. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105107. */
  105108. protected _microSurfaceTexture: Nullable<BaseTexture>;
  105109. /**
  105110. * Stores surface normal data used to displace a mesh in a texture.
  105111. */
  105112. protected _bumpTexture: Nullable<BaseTexture>;
  105113. /**
  105114. * Stores the pre-calculated light information of a mesh in a texture.
  105115. */
  105116. protected _lightmapTexture: Nullable<BaseTexture>;
  105117. /**
  105118. * The color of a material in ambient lighting.
  105119. */
  105120. protected _ambientColor: Color3;
  105121. /**
  105122. * AKA Diffuse Color in other nomenclature.
  105123. */
  105124. protected _albedoColor: Color3;
  105125. /**
  105126. * AKA Specular Color in other nomenclature.
  105127. */
  105128. protected _reflectivityColor: Color3;
  105129. /**
  105130. * The color applied when light is reflected from a material.
  105131. */
  105132. protected _reflectionColor: Color3;
  105133. /**
  105134. * The color applied when light is emitted from a material.
  105135. */
  105136. protected _emissiveColor: Color3;
  105137. /**
  105138. * AKA Glossiness in other nomenclature.
  105139. */
  105140. protected _microSurface: number;
  105141. /**
  105142. * Specifies that the material will use the light map as a show map.
  105143. */
  105144. protected _useLightmapAsShadowmap: boolean;
  105145. /**
  105146. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105147. * makes the reflect vector face the model (under horizon).
  105148. */
  105149. protected _useHorizonOcclusion: boolean;
  105150. /**
  105151. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105152. * too much the area relying on ambient texture to define their ambient occlusion.
  105153. */
  105154. protected _useRadianceOcclusion: boolean;
  105155. /**
  105156. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105157. */
  105158. protected _useAlphaFromAlbedoTexture: boolean;
  105159. /**
  105160. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  105161. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105162. */
  105163. protected _useSpecularOverAlpha: boolean;
  105164. /**
  105165. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105166. */
  105167. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105168. /**
  105169. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105170. */
  105171. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  105172. /**
  105173. * Specifies if the metallic texture contains the roughness information in its green channel.
  105174. */
  105175. protected _useRoughnessFromMetallicTextureGreen: boolean;
  105176. /**
  105177. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105178. */
  105179. protected _useMetallnessFromMetallicTextureBlue: boolean;
  105180. /**
  105181. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105182. */
  105183. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  105184. /**
  105185. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105186. */
  105187. protected _useAmbientInGrayScale: boolean;
  105188. /**
  105189. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105190. * The material will try to infer what glossiness each pixel should be.
  105191. */
  105192. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  105193. /**
  105194. * Defines the falloff type used in this material.
  105195. * It by default is Physical.
  105196. */
  105197. protected _lightFalloff: number;
  105198. /**
  105199. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105200. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105201. */
  105202. protected _useRadianceOverAlpha: boolean;
  105203. /**
  105204. * Allows using an object space normal map (instead of tangent space).
  105205. */
  105206. protected _useObjectSpaceNormalMap: boolean;
  105207. /**
  105208. * Allows using the bump map in parallax mode.
  105209. */
  105210. protected _useParallax: boolean;
  105211. /**
  105212. * Allows using the bump map in parallax occlusion mode.
  105213. */
  105214. protected _useParallaxOcclusion: boolean;
  105215. /**
  105216. * Controls the scale bias of the parallax mode.
  105217. */
  105218. protected _parallaxScaleBias: number;
  105219. /**
  105220. * If sets to true, disables all the lights affecting the material.
  105221. */
  105222. protected _disableLighting: boolean;
  105223. /**
  105224. * Number of Simultaneous lights allowed on the material.
  105225. */
  105226. protected _maxSimultaneousLights: number;
  105227. /**
  105228. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105229. */
  105230. protected _invertNormalMapX: boolean;
  105231. /**
  105232. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105233. */
  105234. protected _invertNormalMapY: boolean;
  105235. /**
  105236. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105237. */
  105238. protected _twoSidedLighting: boolean;
  105239. /**
  105240. * Defines the alpha limits in alpha test mode.
  105241. */
  105242. protected _alphaCutOff: number;
  105243. /**
  105244. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105245. */
  105246. protected _forceAlphaTest: boolean;
  105247. /**
  105248. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105249. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105250. */
  105251. protected _useAlphaFresnel: boolean;
  105252. /**
  105253. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105254. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105255. */
  105256. protected _useLinearAlphaFresnel: boolean;
  105257. /**
  105258. * The transparency mode of the material.
  105259. */
  105260. protected _transparencyMode: Nullable<number>;
  105261. /**
  105262. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  105263. * from cos thetav and roughness:
  105264. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  105265. */
  105266. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  105267. /**
  105268. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105269. */
  105270. protected _forceIrradianceInFragment: boolean;
  105271. /**
  105272. * Force normal to face away from face.
  105273. */
  105274. protected _forceNormalForward: boolean;
  105275. /**
  105276. * Enables specular anti aliasing in the PBR shader.
  105277. * It will both interacts on the Geometry for analytical and IBL lighting.
  105278. * It also prefilter the roughness map based on the bump values.
  105279. */
  105280. protected _enableSpecularAntiAliasing: boolean;
  105281. /**
  105282. * Default configuration related to image processing available in the PBR Material.
  105283. */
  105284. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105285. /**
  105286. * Keep track of the image processing observer to allow dispose and replace.
  105287. */
  105288. private _imageProcessingObserver;
  105289. /**
  105290. * Attaches a new image processing configuration to the PBR Material.
  105291. * @param configuration
  105292. */
  105293. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105294. /**
  105295. * Stores the available render targets.
  105296. */
  105297. private _renderTargets;
  105298. /**
  105299. * Sets the global ambient color for the material used in lighting calculations.
  105300. */
  105301. private _globalAmbientColor;
  105302. /**
  105303. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  105304. */
  105305. private _useLogarithmicDepth;
  105306. /**
  105307. * If set to true, no lighting calculations will be applied.
  105308. */
  105309. private _unlit;
  105310. private _debugMode;
  105311. /**
  105312. * @hidden
  105313. * This is reserved for the inspector.
  105314. * Defines the material debug mode.
  105315. * It helps seeing only some components of the material while troubleshooting.
  105316. */
  105317. debugMode: number;
  105318. /**
  105319. * @hidden
  105320. * This is reserved for the inspector.
  105321. * Specify from where on screen the debug mode should start.
  105322. * The value goes from -1 (full screen) to 1 (not visible)
  105323. * It helps with side by side comparison against the final render
  105324. * This defaults to -1
  105325. */
  105326. private debugLimit;
  105327. /**
  105328. * @hidden
  105329. * This is reserved for the inspector.
  105330. * As the default viewing range might not be enough (if the ambient is really small for instance)
  105331. * You can use the factor to better multiply the final value.
  105332. */
  105333. private debugFactor;
  105334. /**
  105335. * Defines the clear coat layer parameters for the material.
  105336. */
  105337. readonly clearCoat: PBRClearCoatConfiguration;
  105338. /**
  105339. * Defines the anisotropic parameters for the material.
  105340. */
  105341. readonly anisotropy: PBRAnisotropicConfiguration;
  105342. /**
  105343. * Defines the BRDF parameters for the material.
  105344. */
  105345. readonly brdf: PBRBRDFConfiguration;
  105346. /**
  105347. * Defines the Sheen parameters for the material.
  105348. */
  105349. readonly sheen: PBRSheenConfiguration;
  105350. /**
  105351. * Defines the SubSurface parameters for the material.
  105352. */
  105353. readonly subSurface: PBRSubSurfaceConfiguration;
  105354. /**
  105355. * Custom callback helping to override the default shader used in the material.
  105356. */
  105357. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  105358. /**
  105359. * Instantiates a new PBRMaterial instance.
  105360. *
  105361. * @param name The material name
  105362. * @param scene The scene the material will be use in.
  105363. */
  105364. constructor(name: string, scene: Scene);
  105365. /**
  105366. * Gets a boolean indicating that current material needs to register RTT
  105367. */
  105368. readonly hasRenderTargetTextures: boolean;
  105369. /**
  105370. * Gets the name of the material class.
  105371. */
  105372. getClassName(): string;
  105373. /**
  105374. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105375. */
  105376. /**
  105377. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105378. */
  105379. useLogarithmicDepth: boolean;
  105380. /**
  105381. * Gets the current transparency mode.
  105382. */
  105383. /**
  105384. * Sets the transparency mode of the material.
  105385. *
  105386. * | Value | Type | Description |
  105387. * | ----- | ----------------------------------- | ----------- |
  105388. * | 0 | OPAQUE | |
  105389. * | 1 | ALPHATEST | |
  105390. * | 2 | ALPHABLEND | |
  105391. * | 3 | ALPHATESTANDBLEND | |
  105392. *
  105393. */
  105394. transparencyMode: Nullable<number>;
  105395. /**
  105396. * Returns true if alpha blending should be disabled.
  105397. */
  105398. private readonly _disableAlphaBlending;
  105399. /**
  105400. * Specifies whether or not this material should be rendered in alpha blend mode.
  105401. */
  105402. needAlphaBlending(): boolean;
  105403. /**
  105404. * Specifies if the mesh will require alpha blending.
  105405. * @param mesh - BJS mesh.
  105406. */
  105407. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105408. /**
  105409. * Specifies whether or not this material should be rendered in alpha test mode.
  105410. */
  105411. needAlphaTesting(): boolean;
  105412. /**
  105413. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  105414. */
  105415. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  105416. /**
  105417. * Gets the texture used for the alpha test.
  105418. */
  105419. getAlphaTestTexture(): Nullable<BaseTexture>;
  105420. /**
  105421. * Specifies that the submesh is ready to be used.
  105422. * @param mesh - BJS mesh.
  105423. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  105424. * @param useInstances - Specifies that instances should be used.
  105425. * @returns - boolean indicating that the submesh is ready or not.
  105426. */
  105427. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105428. /**
  105429. * Specifies if the material uses metallic roughness workflow.
  105430. * @returns boolean specifiying if the material uses metallic roughness workflow.
  105431. */
  105432. isMetallicWorkflow(): boolean;
  105433. private _prepareEffect;
  105434. private _prepareDefines;
  105435. /**
  105436. * Force shader compilation
  105437. */
  105438. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  105439. clipPlane: boolean;
  105440. }>): void;
  105441. /**
  105442. * Initializes the uniform buffer layout for the shader.
  105443. */
  105444. buildUniformLayout(): void;
  105445. /**
  105446. * Unbinds the material from the mesh
  105447. */
  105448. unbind(): void;
  105449. /**
  105450. * Binds the submesh data.
  105451. * @param world - The world matrix.
  105452. * @param mesh - The BJS mesh.
  105453. * @param subMesh - A submesh of the BJS mesh.
  105454. */
  105455. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105456. /**
  105457. * Returns the animatable textures.
  105458. * @returns - Array of animatable textures.
  105459. */
  105460. getAnimatables(): IAnimatable[];
  105461. /**
  105462. * Returns the texture used for reflections.
  105463. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  105464. */
  105465. private _getReflectionTexture;
  105466. /**
  105467. * Returns an array of the actively used textures.
  105468. * @returns - Array of BaseTextures
  105469. */
  105470. getActiveTextures(): BaseTexture[];
  105471. /**
  105472. * Checks to see if a texture is used in the material.
  105473. * @param texture - Base texture to use.
  105474. * @returns - Boolean specifying if a texture is used in the material.
  105475. */
  105476. hasTexture(texture: BaseTexture): boolean;
  105477. /**
  105478. * Disposes the resources of the material.
  105479. * @param forceDisposeEffect - Forces the disposal of effects.
  105480. * @param forceDisposeTextures - Forces the disposal of all textures.
  105481. */
  105482. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105483. }
  105484. }
  105485. declare module BABYLON {
  105486. /**
  105487. * The Physically based material of BJS.
  105488. *
  105489. * This offers the main features of a standard PBR material.
  105490. * For more information, please refer to the documentation :
  105491. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105492. */
  105493. export class PBRMaterial extends PBRBaseMaterial {
  105494. /**
  105495. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105496. */
  105497. static readonly PBRMATERIAL_OPAQUE: number;
  105498. /**
  105499. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105500. */
  105501. static readonly PBRMATERIAL_ALPHATEST: number;
  105502. /**
  105503. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105504. */
  105505. static readonly PBRMATERIAL_ALPHABLEND: number;
  105506. /**
  105507. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105508. * They are also discarded below the alpha cutoff threshold to improve performances.
  105509. */
  105510. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105511. /**
  105512. * Defines the default value of how much AO map is occluding the analytical lights
  105513. * (point spot...).
  105514. */
  105515. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105516. /**
  105517. * Intensity of the direct lights e.g. the four lights available in your scene.
  105518. * This impacts both the direct diffuse and specular highlights.
  105519. */
  105520. directIntensity: number;
  105521. /**
  105522. * Intensity of the emissive part of the material.
  105523. * This helps controlling the emissive effect without modifying the emissive color.
  105524. */
  105525. emissiveIntensity: number;
  105526. /**
  105527. * Intensity of the environment e.g. how much the environment will light the object
  105528. * either through harmonics for rough material or through the refelction for shiny ones.
  105529. */
  105530. environmentIntensity: number;
  105531. /**
  105532. * This is a special control allowing the reduction of the specular highlights coming from the
  105533. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105534. */
  105535. specularIntensity: number;
  105536. /**
  105537. * Debug Control allowing disabling the bump map on this material.
  105538. */
  105539. disableBumpMap: boolean;
  105540. /**
  105541. * AKA Diffuse Texture in standard nomenclature.
  105542. */
  105543. albedoTexture: BaseTexture;
  105544. /**
  105545. * AKA Occlusion Texture in other nomenclature.
  105546. */
  105547. ambientTexture: BaseTexture;
  105548. /**
  105549. * AKA Occlusion Texture Intensity in other nomenclature.
  105550. */
  105551. ambientTextureStrength: number;
  105552. /**
  105553. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105554. * 1 means it completely occludes it
  105555. * 0 mean it has no impact
  105556. */
  105557. ambientTextureImpactOnAnalyticalLights: number;
  105558. /**
  105559. * Stores the alpha values in a texture.
  105560. */
  105561. opacityTexture: BaseTexture;
  105562. /**
  105563. * Stores the reflection values in a texture.
  105564. */
  105565. reflectionTexture: Nullable<BaseTexture>;
  105566. /**
  105567. * Stores the emissive values in a texture.
  105568. */
  105569. emissiveTexture: BaseTexture;
  105570. /**
  105571. * AKA Specular texture in other nomenclature.
  105572. */
  105573. reflectivityTexture: BaseTexture;
  105574. /**
  105575. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105576. */
  105577. metallicTexture: BaseTexture;
  105578. /**
  105579. * Specifies the metallic scalar of the metallic/roughness workflow.
  105580. * Can also be used to scale the metalness values of the metallic texture.
  105581. */
  105582. metallic: Nullable<number>;
  105583. /**
  105584. * Specifies the roughness scalar of the metallic/roughness workflow.
  105585. * Can also be used to scale the roughness values of the metallic texture.
  105586. */
  105587. roughness: Nullable<number>;
  105588. /**
  105589. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105590. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105591. */
  105592. microSurfaceTexture: BaseTexture;
  105593. /**
  105594. * Stores surface normal data used to displace a mesh in a texture.
  105595. */
  105596. bumpTexture: BaseTexture;
  105597. /**
  105598. * Stores the pre-calculated light information of a mesh in a texture.
  105599. */
  105600. lightmapTexture: BaseTexture;
  105601. /**
  105602. * Stores the refracted light information in a texture.
  105603. */
  105604. refractionTexture: Nullable<BaseTexture>;
  105605. /**
  105606. * The color of a material in ambient lighting.
  105607. */
  105608. ambientColor: Color3;
  105609. /**
  105610. * AKA Diffuse Color in other nomenclature.
  105611. */
  105612. albedoColor: Color3;
  105613. /**
  105614. * AKA Specular Color in other nomenclature.
  105615. */
  105616. reflectivityColor: Color3;
  105617. /**
  105618. * The color reflected from the material.
  105619. */
  105620. reflectionColor: Color3;
  105621. /**
  105622. * The color emitted from the material.
  105623. */
  105624. emissiveColor: Color3;
  105625. /**
  105626. * AKA Glossiness in other nomenclature.
  105627. */
  105628. microSurface: number;
  105629. /**
  105630. * source material index of refraction (IOR)' / 'destination material IOR.
  105631. */
  105632. indexOfRefraction: number;
  105633. /**
  105634. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105635. */
  105636. invertRefractionY: boolean;
  105637. /**
  105638. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105639. * Materials half opaque for instance using refraction could benefit from this control.
  105640. */
  105641. linkRefractionWithTransparency: boolean;
  105642. /**
  105643. * If true, the light map contains occlusion information instead of lighting info.
  105644. */
  105645. useLightmapAsShadowmap: boolean;
  105646. /**
  105647. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105648. */
  105649. useAlphaFromAlbedoTexture: boolean;
  105650. /**
  105651. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105652. */
  105653. forceAlphaTest: boolean;
  105654. /**
  105655. * Defines the alpha limits in alpha test mode.
  105656. */
  105657. alphaCutOff: number;
  105658. /**
  105659. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105660. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105661. */
  105662. useSpecularOverAlpha: boolean;
  105663. /**
  105664. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105665. */
  105666. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105667. /**
  105668. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105669. */
  105670. useRoughnessFromMetallicTextureAlpha: boolean;
  105671. /**
  105672. * Specifies if the metallic texture contains the roughness information in its green channel.
  105673. */
  105674. useRoughnessFromMetallicTextureGreen: boolean;
  105675. /**
  105676. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105677. */
  105678. useMetallnessFromMetallicTextureBlue: boolean;
  105679. /**
  105680. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105681. */
  105682. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105683. /**
  105684. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105685. */
  105686. useAmbientInGrayScale: boolean;
  105687. /**
  105688. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105689. * The material will try to infer what glossiness each pixel should be.
  105690. */
  105691. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105692. /**
  105693. * BJS is using an harcoded light falloff based on a manually sets up range.
  105694. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105695. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105696. */
  105697. /**
  105698. * BJS is using an harcoded light falloff based on a manually sets up range.
  105699. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105700. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105701. */
  105702. usePhysicalLightFalloff: boolean;
  105703. /**
  105704. * In order to support the falloff compatibility with gltf, a special mode has been added
  105705. * to reproduce the gltf light falloff.
  105706. */
  105707. /**
  105708. * In order to support the falloff compatibility with gltf, a special mode has been added
  105709. * to reproduce the gltf light falloff.
  105710. */
  105711. useGLTFLightFalloff: boolean;
  105712. /**
  105713. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105714. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105715. */
  105716. useRadianceOverAlpha: boolean;
  105717. /**
  105718. * Allows using an object space normal map (instead of tangent space).
  105719. */
  105720. useObjectSpaceNormalMap: boolean;
  105721. /**
  105722. * Allows using the bump map in parallax mode.
  105723. */
  105724. useParallax: boolean;
  105725. /**
  105726. * Allows using the bump map in parallax occlusion mode.
  105727. */
  105728. useParallaxOcclusion: boolean;
  105729. /**
  105730. * Controls the scale bias of the parallax mode.
  105731. */
  105732. parallaxScaleBias: number;
  105733. /**
  105734. * If sets to true, disables all the lights affecting the material.
  105735. */
  105736. disableLighting: boolean;
  105737. /**
  105738. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105739. */
  105740. forceIrradianceInFragment: boolean;
  105741. /**
  105742. * Number of Simultaneous lights allowed on the material.
  105743. */
  105744. maxSimultaneousLights: number;
  105745. /**
  105746. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105747. */
  105748. invertNormalMapX: boolean;
  105749. /**
  105750. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105751. */
  105752. invertNormalMapY: boolean;
  105753. /**
  105754. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105755. */
  105756. twoSidedLighting: boolean;
  105757. /**
  105758. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105759. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105760. */
  105761. useAlphaFresnel: boolean;
  105762. /**
  105763. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105764. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105765. */
  105766. useLinearAlphaFresnel: boolean;
  105767. /**
  105768. * Let user defines the brdf lookup texture used for IBL.
  105769. * A default 8bit version is embedded but you could point at :
  105770. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105771. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105772. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105773. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105774. */
  105775. environmentBRDFTexture: Nullable<BaseTexture>;
  105776. /**
  105777. * Force normal to face away from face.
  105778. */
  105779. forceNormalForward: boolean;
  105780. /**
  105781. * Enables specular anti aliasing in the PBR shader.
  105782. * It will both interacts on the Geometry for analytical and IBL lighting.
  105783. * It also prefilter the roughness map based on the bump values.
  105784. */
  105785. enableSpecularAntiAliasing: boolean;
  105786. /**
  105787. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105788. * makes the reflect vector face the model (under horizon).
  105789. */
  105790. useHorizonOcclusion: boolean;
  105791. /**
  105792. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105793. * too much the area relying on ambient texture to define their ambient occlusion.
  105794. */
  105795. useRadianceOcclusion: boolean;
  105796. /**
  105797. * If set to true, no lighting calculations will be applied.
  105798. */
  105799. unlit: boolean;
  105800. /**
  105801. * Gets the image processing configuration used either in this material.
  105802. */
  105803. /**
  105804. * Sets the Default image processing configuration used either in the this material.
  105805. *
  105806. * If sets to null, the scene one is in use.
  105807. */
  105808. imageProcessingConfiguration: ImageProcessingConfiguration;
  105809. /**
  105810. * Gets wether the color curves effect is enabled.
  105811. */
  105812. /**
  105813. * Sets wether the color curves effect is enabled.
  105814. */
  105815. cameraColorCurvesEnabled: boolean;
  105816. /**
  105817. * Gets wether the color grading effect is enabled.
  105818. */
  105819. /**
  105820. * Gets wether the color grading effect is enabled.
  105821. */
  105822. cameraColorGradingEnabled: boolean;
  105823. /**
  105824. * Gets wether tonemapping is enabled or not.
  105825. */
  105826. /**
  105827. * Sets wether tonemapping is enabled or not
  105828. */
  105829. cameraToneMappingEnabled: boolean;
  105830. /**
  105831. * The camera exposure used on this material.
  105832. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105833. * This corresponds to a photographic exposure.
  105834. */
  105835. /**
  105836. * The camera exposure used on this material.
  105837. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105838. * This corresponds to a photographic exposure.
  105839. */
  105840. cameraExposure: number;
  105841. /**
  105842. * Gets The camera contrast used on this material.
  105843. */
  105844. /**
  105845. * Sets The camera contrast used on this material.
  105846. */
  105847. cameraContrast: number;
  105848. /**
  105849. * Gets the Color Grading 2D Lookup Texture.
  105850. */
  105851. /**
  105852. * Sets the Color Grading 2D Lookup Texture.
  105853. */
  105854. cameraColorGradingTexture: Nullable<BaseTexture>;
  105855. /**
  105856. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105857. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105858. * 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;
  105859. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105860. */
  105861. /**
  105862. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105863. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105864. * 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;
  105865. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105866. */
  105867. cameraColorCurves: Nullable<ColorCurves>;
  105868. /**
  105869. * Instantiates a new PBRMaterial instance.
  105870. *
  105871. * @param name The material name
  105872. * @param scene The scene the material will be use in.
  105873. */
  105874. constructor(name: string, scene: Scene);
  105875. /**
  105876. * Returns the name of this material class.
  105877. */
  105878. getClassName(): string;
  105879. /**
  105880. * Makes a duplicate of the current material.
  105881. * @param name - name to use for the new material.
  105882. */
  105883. clone(name: string): PBRMaterial;
  105884. /**
  105885. * Serializes this PBR Material.
  105886. * @returns - An object with the serialized material.
  105887. */
  105888. serialize(): any;
  105889. /**
  105890. * Parses a PBR Material from a serialized object.
  105891. * @param source - Serialized object.
  105892. * @param scene - BJS scene instance.
  105893. * @param rootUrl - url for the scene object
  105894. * @returns - PBRMaterial
  105895. */
  105896. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105897. }
  105898. }
  105899. declare module BABYLON {
  105900. /**
  105901. * Direct draw surface info
  105902. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105903. */
  105904. export interface DDSInfo {
  105905. /**
  105906. * Width of the texture
  105907. */
  105908. width: number;
  105909. /**
  105910. * Width of the texture
  105911. */
  105912. height: number;
  105913. /**
  105914. * Number of Mipmaps for the texture
  105915. * @see https://en.wikipedia.org/wiki/Mipmap
  105916. */
  105917. mipmapCount: number;
  105918. /**
  105919. * If the textures format is a known fourCC format
  105920. * @see https://www.fourcc.org/
  105921. */
  105922. isFourCC: boolean;
  105923. /**
  105924. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105925. */
  105926. isRGB: boolean;
  105927. /**
  105928. * If the texture is a lumincance format
  105929. */
  105930. isLuminance: boolean;
  105931. /**
  105932. * If this is a cube texture
  105933. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105934. */
  105935. isCube: boolean;
  105936. /**
  105937. * If the texture is a compressed format eg. FOURCC_DXT1
  105938. */
  105939. isCompressed: boolean;
  105940. /**
  105941. * The dxgiFormat of the texture
  105942. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105943. */
  105944. dxgiFormat: number;
  105945. /**
  105946. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105947. */
  105948. textureType: number;
  105949. /**
  105950. * Sphericle polynomial created for the dds texture
  105951. */
  105952. sphericalPolynomial?: SphericalPolynomial;
  105953. }
  105954. /**
  105955. * Class used to provide DDS decompression tools
  105956. */
  105957. export class DDSTools {
  105958. /**
  105959. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105960. */
  105961. static StoreLODInAlphaChannel: boolean;
  105962. /**
  105963. * Gets DDS information from an array buffer
  105964. * @param arrayBuffer defines the array buffer to read data from
  105965. * @returns the DDS information
  105966. */
  105967. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105968. private static _FloatView;
  105969. private static _Int32View;
  105970. private static _ToHalfFloat;
  105971. private static _FromHalfFloat;
  105972. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105973. private static _GetHalfFloatRGBAArrayBuffer;
  105974. private static _GetFloatRGBAArrayBuffer;
  105975. private static _GetFloatAsUIntRGBAArrayBuffer;
  105976. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105977. private static _GetRGBAArrayBuffer;
  105978. private static _ExtractLongWordOrder;
  105979. private static _GetRGBArrayBuffer;
  105980. private static _GetLuminanceArrayBuffer;
  105981. /**
  105982. * Uploads DDS Levels to a Babylon Texture
  105983. * @hidden
  105984. */
  105985. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105986. }
  105987. interface Engine {
  105988. /**
  105989. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105990. * @param rootUrl defines the url where the file to load is located
  105991. * @param scene defines the current scene
  105992. * @param lodScale defines scale to apply to the mip map selection
  105993. * @param lodOffset defines offset to apply to the mip map selection
  105994. * @param onLoad defines an optional callback raised when the texture is loaded
  105995. * @param onError defines an optional callback raised if there is an issue to load the texture
  105996. * @param format defines the format of the data
  105997. * @param forcedExtension defines the extension to use to pick the right loader
  105998. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105999. * @returns the cube texture as an InternalTexture
  106000. */
  106001. 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;
  106002. }
  106003. }
  106004. declare module BABYLON {
  106005. /**
  106006. * Implementation of the DDS Texture Loader.
  106007. * @hidden
  106008. */
  106009. export class _DDSTextureLoader implements IInternalTextureLoader {
  106010. /**
  106011. * Defines wether the loader supports cascade loading the different faces.
  106012. */
  106013. readonly supportCascades: boolean;
  106014. /**
  106015. * This returns if the loader support the current file information.
  106016. * @param extension defines the file extension of the file being loaded
  106017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106018. * @param fallback defines the fallback internal texture if any
  106019. * @param isBase64 defines whether the texture is encoded as a base64
  106020. * @param isBuffer defines whether the texture data are stored as a buffer
  106021. * @returns true if the loader can load the specified file
  106022. */
  106023. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106024. /**
  106025. * Transform the url before loading if required.
  106026. * @param rootUrl the url of the texture
  106027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106028. * @returns the transformed texture
  106029. */
  106030. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106031. /**
  106032. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106033. * @param rootUrl the url of the texture
  106034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106035. * @returns the fallback texture
  106036. */
  106037. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106038. /**
  106039. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106040. * @param data contains the texture data
  106041. * @param texture defines the BabylonJS internal texture
  106042. * @param createPolynomials will be true if polynomials have been requested
  106043. * @param onLoad defines the callback to trigger once the texture is ready
  106044. * @param onError defines the callback to trigger in case of error
  106045. */
  106046. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106047. /**
  106048. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106049. * @param data contains the texture data
  106050. * @param texture defines the BabylonJS internal texture
  106051. * @param callback defines the method to call once ready to upload
  106052. */
  106053. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106054. }
  106055. }
  106056. declare module BABYLON {
  106057. /** @hidden */
  106058. export var rgbdEncodePixelShader: {
  106059. name: string;
  106060. shader: string;
  106061. };
  106062. }
  106063. declare module BABYLON {
  106064. /**
  106065. * Raw texture data and descriptor sufficient for WebGL texture upload
  106066. */
  106067. export interface EnvironmentTextureInfo {
  106068. /**
  106069. * Version of the environment map
  106070. */
  106071. version: number;
  106072. /**
  106073. * Width of image
  106074. */
  106075. width: number;
  106076. /**
  106077. * Irradiance information stored in the file.
  106078. */
  106079. irradiance: any;
  106080. /**
  106081. * Specular information stored in the file.
  106082. */
  106083. specular: any;
  106084. }
  106085. /**
  106086. * Sets of helpers addressing the serialization and deserialization of environment texture
  106087. * stored in a BabylonJS env file.
  106088. * Those files are usually stored as .env files.
  106089. */
  106090. export class EnvironmentTextureTools {
  106091. /**
  106092. * Magic number identifying the env file.
  106093. */
  106094. private static _MagicBytes;
  106095. /**
  106096. * Gets the environment info from an env file.
  106097. * @param data The array buffer containing the .env bytes.
  106098. * @returns the environment file info (the json header) if successfully parsed.
  106099. */
  106100. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  106101. /**
  106102. * Creates an environment texture from a loaded cube texture.
  106103. * @param texture defines the cube texture to convert in env file
  106104. * @return a promise containing the environment data if succesfull.
  106105. */
  106106. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  106107. /**
  106108. * Creates a JSON representation of the spherical data.
  106109. * @param texture defines the texture containing the polynomials
  106110. * @return the JSON representation of the spherical info
  106111. */
  106112. private static _CreateEnvTextureIrradiance;
  106113. /**
  106114. * Uploads the texture info contained in the env file to the GPU.
  106115. * @param texture defines the internal texture to upload to
  106116. * @param arrayBuffer defines the buffer cotaining the data to load
  106117. * @param info defines the texture info retrieved through the GetEnvInfo method
  106118. * @returns a promise
  106119. */
  106120. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  106121. /**
  106122. * Uploads the levels of image data to the GPU.
  106123. * @param texture defines the internal texture to upload to
  106124. * @param imageData defines the array buffer views of image data [mipmap][face]
  106125. * @returns a promise
  106126. */
  106127. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  106128. /**
  106129. * Uploads spherical polynomials information to the texture.
  106130. * @param texture defines the texture we are trying to upload the information to
  106131. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  106132. */
  106133. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  106134. /** @hidden */
  106135. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106136. }
  106137. }
  106138. declare module BABYLON {
  106139. /**
  106140. * Implementation of the ENV Texture Loader.
  106141. * @hidden
  106142. */
  106143. export class _ENVTextureLoader implements IInternalTextureLoader {
  106144. /**
  106145. * Defines wether the loader supports cascade loading the different faces.
  106146. */
  106147. readonly supportCascades: boolean;
  106148. /**
  106149. * This returns if the loader support the current file information.
  106150. * @param extension defines the file extension of the file being loaded
  106151. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106152. * @param fallback defines the fallback internal texture if any
  106153. * @param isBase64 defines whether the texture is encoded as a base64
  106154. * @param isBuffer defines whether the texture data are stored as a buffer
  106155. * @returns true if the loader can load the specified file
  106156. */
  106157. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106158. /**
  106159. * Transform the url before loading if required.
  106160. * @param rootUrl the url of the texture
  106161. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106162. * @returns the transformed texture
  106163. */
  106164. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106165. /**
  106166. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106167. * @param rootUrl the url of the texture
  106168. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106169. * @returns the fallback texture
  106170. */
  106171. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106172. /**
  106173. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106174. * @param data contains the texture data
  106175. * @param texture defines the BabylonJS internal texture
  106176. * @param createPolynomials will be true if polynomials have been requested
  106177. * @param onLoad defines the callback to trigger once the texture is ready
  106178. * @param onError defines the callback to trigger in case of error
  106179. */
  106180. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106181. /**
  106182. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106183. * @param data contains the texture data
  106184. * @param texture defines the BabylonJS internal texture
  106185. * @param callback defines the method to call once ready to upload
  106186. */
  106187. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106188. }
  106189. }
  106190. declare module BABYLON {
  106191. /**
  106192. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106193. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106194. */
  106195. export class KhronosTextureContainer {
  106196. /** contents of the KTX container file */
  106197. arrayBuffer: any;
  106198. private static HEADER_LEN;
  106199. private static COMPRESSED_2D;
  106200. private static COMPRESSED_3D;
  106201. private static TEX_2D;
  106202. private static TEX_3D;
  106203. /**
  106204. * Gets the openGL type
  106205. */
  106206. glType: number;
  106207. /**
  106208. * Gets the openGL type size
  106209. */
  106210. glTypeSize: number;
  106211. /**
  106212. * Gets the openGL format
  106213. */
  106214. glFormat: number;
  106215. /**
  106216. * Gets the openGL internal format
  106217. */
  106218. glInternalFormat: number;
  106219. /**
  106220. * Gets the base internal format
  106221. */
  106222. glBaseInternalFormat: number;
  106223. /**
  106224. * Gets image width in pixel
  106225. */
  106226. pixelWidth: number;
  106227. /**
  106228. * Gets image height in pixel
  106229. */
  106230. pixelHeight: number;
  106231. /**
  106232. * Gets image depth in pixels
  106233. */
  106234. pixelDepth: number;
  106235. /**
  106236. * Gets the number of array elements
  106237. */
  106238. numberOfArrayElements: number;
  106239. /**
  106240. * Gets the number of faces
  106241. */
  106242. numberOfFaces: number;
  106243. /**
  106244. * Gets the number of mipmap levels
  106245. */
  106246. numberOfMipmapLevels: number;
  106247. /**
  106248. * Gets the bytes of key value data
  106249. */
  106250. bytesOfKeyValueData: number;
  106251. /**
  106252. * Gets the load type
  106253. */
  106254. loadType: number;
  106255. /**
  106256. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  106257. */
  106258. isInvalid: boolean;
  106259. /**
  106260. * Creates a new KhronosTextureContainer
  106261. * @param arrayBuffer contents of the KTX container file
  106262. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  106263. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  106264. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  106265. */
  106266. constructor(
  106267. /** contents of the KTX container file */
  106268. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  106269. /**
  106270. * Uploads KTX content to a Babylon Texture.
  106271. * It is assumed that the texture has already been created & is currently bound
  106272. * @hidden
  106273. */
  106274. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  106275. private _upload2DCompressedLevels;
  106276. }
  106277. }
  106278. declare module BABYLON {
  106279. /**
  106280. * Implementation of the KTX Texture Loader.
  106281. * @hidden
  106282. */
  106283. export class _KTXTextureLoader implements IInternalTextureLoader {
  106284. /**
  106285. * Defines wether the loader supports cascade loading the different faces.
  106286. */
  106287. readonly supportCascades: boolean;
  106288. /**
  106289. * This returns if the loader support the current file information.
  106290. * @param extension defines the file extension of the file being loaded
  106291. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106292. * @param fallback defines the fallback internal texture if any
  106293. * @param isBase64 defines whether the texture is encoded as a base64
  106294. * @param isBuffer defines whether the texture data are stored as a buffer
  106295. * @returns true if the loader can load the specified file
  106296. */
  106297. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106298. /**
  106299. * Transform the url before loading if required.
  106300. * @param rootUrl the url of the texture
  106301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106302. * @returns the transformed texture
  106303. */
  106304. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106305. /**
  106306. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106307. * @param rootUrl the url of the texture
  106308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106309. * @returns the fallback texture
  106310. */
  106311. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106312. /**
  106313. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106314. * @param data contains the texture data
  106315. * @param texture defines the BabylonJS internal texture
  106316. * @param createPolynomials will be true if polynomials have been requested
  106317. * @param onLoad defines the callback to trigger once the texture is ready
  106318. * @param onError defines the callback to trigger in case of error
  106319. */
  106320. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106321. /**
  106322. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106323. * @param data contains the texture data
  106324. * @param texture defines the BabylonJS internal texture
  106325. * @param callback defines the method to call once ready to upload
  106326. */
  106327. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  106328. }
  106329. }
  106330. declare module BABYLON {
  106331. /** @hidden */
  106332. export var _forceSceneHelpersToBundle: boolean;
  106333. interface Scene {
  106334. /**
  106335. * Creates a default light for the scene.
  106336. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  106337. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  106338. */
  106339. createDefaultLight(replace?: boolean): void;
  106340. /**
  106341. * Creates a default camera for the scene.
  106342. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  106343. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106344. * @param replace has default false, when true replaces the active camera in the scene
  106345. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  106346. */
  106347. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106348. /**
  106349. * Creates a default camera and a default light.
  106350. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  106351. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106352. * @param replace has the default false, when true replaces the active camera/light in the scene
  106353. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  106354. */
  106355. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106356. /**
  106357. * Creates a new sky box
  106358. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  106359. * @param environmentTexture defines the texture to use as environment texture
  106360. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  106361. * @param scale defines the overall scale of the skybox
  106362. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  106363. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  106364. * @returns a new mesh holding the sky box
  106365. */
  106366. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  106367. /**
  106368. * Creates a new environment
  106369. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  106370. * @param options defines the options you can use to configure the environment
  106371. * @returns the new EnvironmentHelper
  106372. */
  106373. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  106374. /**
  106375. * Creates a new VREXperienceHelper
  106376. * @see http://doc.babylonjs.com/how_to/webvr_helper
  106377. * @param webVROptions defines the options used to create the new VREXperienceHelper
  106378. * @returns a new VREXperienceHelper
  106379. */
  106380. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  106381. /**
  106382. * Creates a new XREXperienceHelper
  106383. * @see http://doc.babylonjs.com/how_to/webxr
  106384. * @returns a promise for a new XREXperienceHelper
  106385. */
  106386. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  106387. }
  106388. }
  106389. declare module BABYLON {
  106390. /**
  106391. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  106392. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  106393. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  106394. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106395. */
  106396. export class VideoDome extends TransformNode {
  106397. /**
  106398. * Define the video source as a Monoscopic panoramic 360 video.
  106399. */
  106400. static readonly MODE_MONOSCOPIC: number;
  106401. /**
  106402. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106403. */
  106404. static readonly MODE_TOPBOTTOM: number;
  106405. /**
  106406. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106407. */
  106408. static readonly MODE_SIDEBYSIDE: number;
  106409. private _useDirectMapping;
  106410. /**
  106411. * The video texture being displayed on the sphere
  106412. */
  106413. protected _videoTexture: VideoTexture;
  106414. /**
  106415. * Gets the video texture being displayed on the sphere
  106416. */
  106417. readonly videoTexture: VideoTexture;
  106418. /**
  106419. * The skybox material
  106420. */
  106421. protected _material: BackgroundMaterial;
  106422. /**
  106423. * The surface used for the skybox
  106424. */
  106425. protected _mesh: Mesh;
  106426. /**
  106427. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106428. * Also see the options.resolution property.
  106429. */
  106430. fovMultiplier: number;
  106431. private _videoMode;
  106432. /**
  106433. * Gets or set the current video mode for the video. It can be:
  106434. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  106435. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106436. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106437. */
  106438. videoMode: number;
  106439. /**
  106440. * Oberserver used in Stereoscopic VR Mode.
  106441. */
  106442. private _onBeforeCameraRenderObserver;
  106443. /**
  106444. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  106445. * @param name Element's name, child elements will append suffixes for their own names.
  106446. * @param urlsOrVideo defines the url(s) or the video element to use
  106447. * @param options An object containing optional or exposed sub element properties
  106448. */
  106449. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  106450. resolution?: number;
  106451. clickToPlay?: boolean;
  106452. autoPlay?: boolean;
  106453. loop?: boolean;
  106454. size?: number;
  106455. poster?: string;
  106456. faceForward?: boolean;
  106457. useDirectMapping?: boolean;
  106458. }, scene: Scene);
  106459. private _changeVideoMode;
  106460. /**
  106461. * Releases resources associated with this node.
  106462. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106463. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106464. */
  106465. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106466. }
  106467. }
  106468. declare module BABYLON {
  106469. /**
  106470. * This class can be used to get instrumentation data from a Babylon engine
  106471. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106472. */
  106473. export class EngineInstrumentation implements IDisposable {
  106474. /**
  106475. * Define the instrumented engine.
  106476. */
  106477. engine: Engine;
  106478. private _captureGPUFrameTime;
  106479. private _gpuFrameTimeToken;
  106480. private _gpuFrameTime;
  106481. private _captureShaderCompilationTime;
  106482. private _shaderCompilationTime;
  106483. private _onBeginFrameObserver;
  106484. private _onEndFrameObserver;
  106485. private _onBeforeShaderCompilationObserver;
  106486. private _onAfterShaderCompilationObserver;
  106487. /**
  106488. * Gets the perf counter used for GPU frame time
  106489. */
  106490. readonly gpuFrameTimeCounter: PerfCounter;
  106491. /**
  106492. * Gets the GPU frame time capture status
  106493. */
  106494. /**
  106495. * Enable or disable the GPU frame time capture
  106496. */
  106497. captureGPUFrameTime: boolean;
  106498. /**
  106499. * Gets the perf counter used for shader compilation time
  106500. */
  106501. readonly shaderCompilationTimeCounter: PerfCounter;
  106502. /**
  106503. * Gets the shader compilation time capture status
  106504. */
  106505. /**
  106506. * Enable or disable the shader compilation time capture
  106507. */
  106508. captureShaderCompilationTime: boolean;
  106509. /**
  106510. * Instantiates a new engine instrumentation.
  106511. * This class can be used to get instrumentation data from a Babylon engine
  106512. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106513. * @param engine Defines the engine to instrument
  106514. */
  106515. constructor(
  106516. /**
  106517. * Define the instrumented engine.
  106518. */
  106519. engine: Engine);
  106520. /**
  106521. * Dispose and release associated resources.
  106522. */
  106523. dispose(): void;
  106524. }
  106525. }
  106526. declare module BABYLON {
  106527. /**
  106528. * This class can be used to get instrumentation data from a Babylon engine
  106529. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106530. */
  106531. export class SceneInstrumentation implements IDisposable {
  106532. /**
  106533. * Defines the scene to instrument
  106534. */
  106535. scene: Scene;
  106536. private _captureActiveMeshesEvaluationTime;
  106537. private _activeMeshesEvaluationTime;
  106538. private _captureRenderTargetsRenderTime;
  106539. private _renderTargetsRenderTime;
  106540. private _captureFrameTime;
  106541. private _frameTime;
  106542. private _captureRenderTime;
  106543. private _renderTime;
  106544. private _captureInterFrameTime;
  106545. private _interFrameTime;
  106546. private _captureParticlesRenderTime;
  106547. private _particlesRenderTime;
  106548. private _captureSpritesRenderTime;
  106549. private _spritesRenderTime;
  106550. private _capturePhysicsTime;
  106551. private _physicsTime;
  106552. private _captureAnimationsTime;
  106553. private _animationsTime;
  106554. private _captureCameraRenderTime;
  106555. private _cameraRenderTime;
  106556. private _onBeforeActiveMeshesEvaluationObserver;
  106557. private _onAfterActiveMeshesEvaluationObserver;
  106558. private _onBeforeRenderTargetsRenderObserver;
  106559. private _onAfterRenderTargetsRenderObserver;
  106560. private _onAfterRenderObserver;
  106561. private _onBeforeDrawPhaseObserver;
  106562. private _onAfterDrawPhaseObserver;
  106563. private _onBeforeAnimationsObserver;
  106564. private _onBeforeParticlesRenderingObserver;
  106565. private _onAfterParticlesRenderingObserver;
  106566. private _onBeforeSpritesRenderingObserver;
  106567. private _onAfterSpritesRenderingObserver;
  106568. private _onBeforePhysicsObserver;
  106569. private _onAfterPhysicsObserver;
  106570. private _onAfterAnimationsObserver;
  106571. private _onBeforeCameraRenderObserver;
  106572. private _onAfterCameraRenderObserver;
  106573. /**
  106574. * Gets the perf counter used for active meshes evaluation time
  106575. */
  106576. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106577. /**
  106578. * Gets the active meshes evaluation time capture status
  106579. */
  106580. /**
  106581. * Enable or disable the active meshes evaluation time capture
  106582. */
  106583. captureActiveMeshesEvaluationTime: boolean;
  106584. /**
  106585. * Gets the perf counter used for render targets render time
  106586. */
  106587. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106588. /**
  106589. * Gets the render targets render time capture status
  106590. */
  106591. /**
  106592. * Enable or disable the render targets render time capture
  106593. */
  106594. captureRenderTargetsRenderTime: boolean;
  106595. /**
  106596. * Gets the perf counter used for particles render time
  106597. */
  106598. readonly particlesRenderTimeCounter: PerfCounter;
  106599. /**
  106600. * Gets the particles render time capture status
  106601. */
  106602. /**
  106603. * Enable or disable the particles render time capture
  106604. */
  106605. captureParticlesRenderTime: boolean;
  106606. /**
  106607. * Gets the perf counter used for sprites render time
  106608. */
  106609. readonly spritesRenderTimeCounter: PerfCounter;
  106610. /**
  106611. * Gets the sprites render time capture status
  106612. */
  106613. /**
  106614. * Enable or disable the sprites render time capture
  106615. */
  106616. captureSpritesRenderTime: boolean;
  106617. /**
  106618. * Gets the perf counter used for physics time
  106619. */
  106620. readonly physicsTimeCounter: PerfCounter;
  106621. /**
  106622. * Gets the physics time capture status
  106623. */
  106624. /**
  106625. * Enable or disable the physics time capture
  106626. */
  106627. capturePhysicsTime: boolean;
  106628. /**
  106629. * Gets the perf counter used for animations time
  106630. */
  106631. readonly animationsTimeCounter: PerfCounter;
  106632. /**
  106633. * Gets the animations time capture status
  106634. */
  106635. /**
  106636. * Enable or disable the animations time capture
  106637. */
  106638. captureAnimationsTime: boolean;
  106639. /**
  106640. * Gets the perf counter used for frame time capture
  106641. */
  106642. readonly frameTimeCounter: PerfCounter;
  106643. /**
  106644. * Gets the frame time capture status
  106645. */
  106646. /**
  106647. * Enable or disable the frame time capture
  106648. */
  106649. captureFrameTime: boolean;
  106650. /**
  106651. * Gets the perf counter used for inter-frames time capture
  106652. */
  106653. readonly interFrameTimeCounter: PerfCounter;
  106654. /**
  106655. * Gets the inter-frames time capture status
  106656. */
  106657. /**
  106658. * Enable or disable the inter-frames time capture
  106659. */
  106660. captureInterFrameTime: boolean;
  106661. /**
  106662. * Gets the perf counter used for render time capture
  106663. */
  106664. readonly renderTimeCounter: PerfCounter;
  106665. /**
  106666. * Gets the render time capture status
  106667. */
  106668. /**
  106669. * Enable or disable the render time capture
  106670. */
  106671. captureRenderTime: boolean;
  106672. /**
  106673. * Gets the perf counter used for camera render time capture
  106674. */
  106675. readonly cameraRenderTimeCounter: PerfCounter;
  106676. /**
  106677. * Gets the camera render time capture status
  106678. */
  106679. /**
  106680. * Enable or disable the camera render time capture
  106681. */
  106682. captureCameraRenderTime: boolean;
  106683. /**
  106684. * Gets the perf counter used for draw calls
  106685. */
  106686. readonly drawCallsCounter: PerfCounter;
  106687. /**
  106688. * Instantiates a new scene instrumentation.
  106689. * This class can be used to get instrumentation data from a Babylon engine
  106690. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106691. * @param scene Defines the scene to instrument
  106692. */
  106693. constructor(
  106694. /**
  106695. * Defines the scene to instrument
  106696. */
  106697. scene: Scene);
  106698. /**
  106699. * Dispose and release associated resources.
  106700. */
  106701. dispose(): void;
  106702. }
  106703. }
  106704. declare module BABYLON {
  106705. /** @hidden */
  106706. export var glowMapGenerationPixelShader: {
  106707. name: string;
  106708. shader: string;
  106709. };
  106710. }
  106711. declare module BABYLON {
  106712. /** @hidden */
  106713. export var glowMapGenerationVertexShader: {
  106714. name: string;
  106715. shader: string;
  106716. };
  106717. }
  106718. declare module BABYLON {
  106719. /**
  106720. * Effect layer options. This helps customizing the behaviour
  106721. * of the effect layer.
  106722. */
  106723. export interface IEffectLayerOptions {
  106724. /**
  106725. * Multiplication factor apply to the canvas size to compute the render target size
  106726. * used to generated the objects (the smaller the faster).
  106727. */
  106728. mainTextureRatio: number;
  106729. /**
  106730. * Enforces a fixed size texture to ensure effect stability across devices.
  106731. */
  106732. mainTextureFixedSize?: number;
  106733. /**
  106734. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106735. */
  106736. alphaBlendingMode: number;
  106737. /**
  106738. * The camera attached to the layer.
  106739. */
  106740. camera: Nullable<Camera>;
  106741. /**
  106742. * The rendering group to draw the layer in.
  106743. */
  106744. renderingGroupId: number;
  106745. }
  106746. /**
  106747. * The effect layer Helps adding post process effect blended with the main pass.
  106748. *
  106749. * This can be for instance use to generate glow or higlight effects on the scene.
  106750. *
  106751. * The effect layer class can not be used directly and is intented to inherited from to be
  106752. * customized per effects.
  106753. */
  106754. export abstract class EffectLayer {
  106755. private _vertexBuffers;
  106756. private _indexBuffer;
  106757. private _cachedDefines;
  106758. private _effectLayerMapGenerationEffect;
  106759. private _effectLayerOptions;
  106760. private _mergeEffect;
  106761. protected _scene: Scene;
  106762. protected _engine: Engine;
  106763. protected _maxSize: number;
  106764. protected _mainTextureDesiredSize: ISize;
  106765. protected _mainTexture: RenderTargetTexture;
  106766. protected _shouldRender: boolean;
  106767. protected _postProcesses: PostProcess[];
  106768. protected _textures: BaseTexture[];
  106769. protected _emissiveTextureAndColor: {
  106770. texture: Nullable<BaseTexture>;
  106771. color: Color4;
  106772. };
  106773. /**
  106774. * The name of the layer
  106775. */
  106776. name: string;
  106777. /**
  106778. * The clear color of the texture used to generate the glow map.
  106779. */
  106780. neutralColor: Color4;
  106781. /**
  106782. * Specifies wether the highlight layer is enabled or not.
  106783. */
  106784. isEnabled: boolean;
  106785. /**
  106786. * Gets the camera attached to the layer.
  106787. */
  106788. readonly camera: Nullable<Camera>;
  106789. /**
  106790. * Gets the rendering group id the layer should render in.
  106791. */
  106792. readonly renderingGroupId: number;
  106793. /**
  106794. * An event triggered when the effect layer has been disposed.
  106795. */
  106796. onDisposeObservable: Observable<EffectLayer>;
  106797. /**
  106798. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106799. */
  106800. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106801. /**
  106802. * An event triggered when the generated texture is being merged in the scene.
  106803. */
  106804. onBeforeComposeObservable: Observable<EffectLayer>;
  106805. /**
  106806. * An event triggered when the generated texture has been merged in the scene.
  106807. */
  106808. onAfterComposeObservable: Observable<EffectLayer>;
  106809. /**
  106810. * An event triggered when the efffect layer changes its size.
  106811. */
  106812. onSizeChangedObservable: Observable<EffectLayer>;
  106813. /** @hidden */
  106814. static _SceneComponentInitialization: (scene: Scene) => void;
  106815. /**
  106816. * Instantiates a new effect Layer and references it in the scene.
  106817. * @param name The name of the layer
  106818. * @param scene The scene to use the layer in
  106819. */
  106820. constructor(
  106821. /** The Friendly of the effect in the scene */
  106822. name: string, scene: Scene);
  106823. /**
  106824. * Get the effect name of the layer.
  106825. * @return The effect name
  106826. */
  106827. abstract getEffectName(): string;
  106828. /**
  106829. * Checks for the readiness of the element composing the layer.
  106830. * @param subMesh the mesh to check for
  106831. * @param useInstances specify wether or not to use instances to render the mesh
  106832. * @return true if ready otherwise, false
  106833. */
  106834. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106835. /**
  106836. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106837. * @returns true if the effect requires stencil during the main canvas render pass.
  106838. */
  106839. abstract needStencil(): boolean;
  106840. /**
  106841. * Create the merge effect. This is the shader use to blit the information back
  106842. * to the main canvas at the end of the scene rendering.
  106843. * @returns The effect containing the shader used to merge the effect on the main canvas
  106844. */
  106845. protected abstract _createMergeEffect(): Effect;
  106846. /**
  106847. * Creates the render target textures and post processes used in the effect layer.
  106848. */
  106849. protected abstract _createTextureAndPostProcesses(): void;
  106850. /**
  106851. * Implementation specific of rendering the generating effect on the main canvas.
  106852. * @param effect The effect used to render through
  106853. */
  106854. protected abstract _internalRender(effect: Effect): void;
  106855. /**
  106856. * Sets the required values for both the emissive texture and and the main color.
  106857. */
  106858. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106859. /**
  106860. * Free any resources and references associated to a mesh.
  106861. * Internal use
  106862. * @param mesh The mesh to free.
  106863. */
  106864. abstract _disposeMesh(mesh: Mesh): void;
  106865. /**
  106866. * Serializes this layer (Glow or Highlight for example)
  106867. * @returns a serialized layer object
  106868. */
  106869. abstract serialize?(): any;
  106870. /**
  106871. * Initializes the effect layer with the required options.
  106872. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106873. */
  106874. protected _init(options: Partial<IEffectLayerOptions>): void;
  106875. /**
  106876. * Generates the index buffer of the full screen quad blending to the main canvas.
  106877. */
  106878. private _generateIndexBuffer;
  106879. /**
  106880. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106881. */
  106882. private _generateVertexBuffer;
  106883. /**
  106884. * Sets the main texture desired size which is the closest power of two
  106885. * of the engine canvas size.
  106886. */
  106887. private _setMainTextureSize;
  106888. /**
  106889. * Creates the main texture for the effect layer.
  106890. */
  106891. protected _createMainTexture(): void;
  106892. /**
  106893. * Adds specific effects defines.
  106894. * @param defines The defines to add specifics to.
  106895. */
  106896. protected _addCustomEffectDefines(defines: string[]): void;
  106897. /**
  106898. * Checks for the readiness of the element composing the layer.
  106899. * @param subMesh the mesh to check for
  106900. * @param useInstances specify wether or not to use instances to render the mesh
  106901. * @param emissiveTexture the associated emissive texture used to generate the glow
  106902. * @return true if ready otherwise, false
  106903. */
  106904. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106905. /**
  106906. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106907. */
  106908. render(): void;
  106909. /**
  106910. * Determine if a given mesh will be used in the current effect.
  106911. * @param mesh mesh to test
  106912. * @returns true if the mesh will be used
  106913. */
  106914. hasMesh(mesh: AbstractMesh): boolean;
  106915. /**
  106916. * Returns true if the layer contains information to display, otherwise false.
  106917. * @returns true if the glow layer should be rendered
  106918. */
  106919. shouldRender(): boolean;
  106920. /**
  106921. * Returns true if the mesh should render, otherwise false.
  106922. * @param mesh The mesh to render
  106923. * @returns true if it should render otherwise false
  106924. */
  106925. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106926. /**
  106927. * Returns true if the mesh can be rendered, otherwise false.
  106928. * @param mesh The mesh to render
  106929. * @param material The material used on the mesh
  106930. * @returns true if it can be rendered otherwise false
  106931. */
  106932. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106933. /**
  106934. * Returns true if the mesh should render, otherwise false.
  106935. * @param mesh The mesh to render
  106936. * @returns true if it should render otherwise false
  106937. */
  106938. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106939. /**
  106940. * Renders the submesh passed in parameter to the generation map.
  106941. */
  106942. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  106943. /**
  106944. * Rebuild the required buffers.
  106945. * @hidden Internal use only.
  106946. */
  106947. _rebuild(): void;
  106948. /**
  106949. * Dispose only the render target textures and post process.
  106950. */
  106951. private _disposeTextureAndPostProcesses;
  106952. /**
  106953. * Dispose the highlight layer and free resources.
  106954. */
  106955. dispose(): void;
  106956. /**
  106957. * Gets the class name of the effect layer
  106958. * @returns the string with the class name of the effect layer
  106959. */
  106960. getClassName(): string;
  106961. /**
  106962. * Creates an effect layer from parsed effect layer data
  106963. * @param parsedEffectLayer defines effect layer data
  106964. * @param scene defines the current scene
  106965. * @param rootUrl defines the root URL containing the effect layer information
  106966. * @returns a parsed effect Layer
  106967. */
  106968. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106969. }
  106970. }
  106971. declare module BABYLON {
  106972. interface AbstractScene {
  106973. /**
  106974. * The list of effect layers (highlights/glow) added to the scene
  106975. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106976. * @see http://doc.babylonjs.com/how_to/glow_layer
  106977. */
  106978. effectLayers: Array<EffectLayer>;
  106979. /**
  106980. * Removes the given effect layer from this scene.
  106981. * @param toRemove defines the effect layer to remove
  106982. * @returns the index of the removed effect layer
  106983. */
  106984. removeEffectLayer(toRemove: EffectLayer): number;
  106985. /**
  106986. * Adds the given effect layer to this scene
  106987. * @param newEffectLayer defines the effect layer to add
  106988. */
  106989. addEffectLayer(newEffectLayer: EffectLayer): void;
  106990. }
  106991. /**
  106992. * Defines the layer scene component responsible to manage any effect layers
  106993. * in a given scene.
  106994. */
  106995. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106996. /**
  106997. * The component name helpfull to identify the component in the list of scene components.
  106998. */
  106999. readonly name: string;
  107000. /**
  107001. * The scene the component belongs to.
  107002. */
  107003. scene: Scene;
  107004. private _engine;
  107005. private _renderEffects;
  107006. private _needStencil;
  107007. private _previousStencilState;
  107008. /**
  107009. * Creates a new instance of the component for the given scene
  107010. * @param scene Defines the scene to register the component in
  107011. */
  107012. constructor(scene: Scene);
  107013. /**
  107014. * Registers the component in a given scene
  107015. */
  107016. register(): void;
  107017. /**
  107018. * Rebuilds the elements related to this component in case of
  107019. * context lost for instance.
  107020. */
  107021. rebuild(): void;
  107022. /**
  107023. * Serializes the component data to the specified json object
  107024. * @param serializationObject The object to serialize to
  107025. */
  107026. serialize(serializationObject: any): void;
  107027. /**
  107028. * Adds all the element from the container to the scene
  107029. * @param container the container holding the elements
  107030. */
  107031. addFromContainer(container: AbstractScene): void;
  107032. /**
  107033. * Removes all the elements in the container from the scene
  107034. * @param container contains the elements to remove
  107035. * @param dispose if the removed element should be disposed (default: false)
  107036. */
  107037. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107038. /**
  107039. * Disposes the component and the associated ressources.
  107040. */
  107041. dispose(): void;
  107042. private _isReadyForMesh;
  107043. private _renderMainTexture;
  107044. private _setStencil;
  107045. private _setStencilBack;
  107046. private _draw;
  107047. private _drawCamera;
  107048. private _drawRenderingGroup;
  107049. }
  107050. }
  107051. declare module BABYLON {
  107052. /** @hidden */
  107053. export var glowMapMergePixelShader: {
  107054. name: string;
  107055. shader: string;
  107056. };
  107057. }
  107058. declare module BABYLON {
  107059. /** @hidden */
  107060. export var glowMapMergeVertexShader: {
  107061. name: string;
  107062. shader: string;
  107063. };
  107064. }
  107065. declare module BABYLON {
  107066. interface AbstractScene {
  107067. /**
  107068. * Return a the first highlight layer of the scene with a given name.
  107069. * @param name The name of the highlight layer to look for.
  107070. * @return The highlight layer if found otherwise null.
  107071. */
  107072. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  107073. }
  107074. /**
  107075. * Glow layer options. This helps customizing the behaviour
  107076. * of the glow layer.
  107077. */
  107078. export interface IGlowLayerOptions {
  107079. /**
  107080. * Multiplication factor apply to the canvas size to compute the render target size
  107081. * used to generated the glowing objects (the smaller the faster).
  107082. */
  107083. mainTextureRatio: number;
  107084. /**
  107085. * Enforces a fixed size texture to ensure resize independant blur.
  107086. */
  107087. mainTextureFixedSize?: number;
  107088. /**
  107089. * How big is the kernel of the blur texture.
  107090. */
  107091. blurKernelSize: number;
  107092. /**
  107093. * The camera attached to the layer.
  107094. */
  107095. camera: Nullable<Camera>;
  107096. /**
  107097. * Enable MSAA by chosing the number of samples.
  107098. */
  107099. mainTextureSamples?: number;
  107100. /**
  107101. * The rendering group to draw the layer in.
  107102. */
  107103. renderingGroupId: number;
  107104. }
  107105. /**
  107106. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  107107. *
  107108. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107109. * glowy meshes to your scene.
  107110. *
  107111. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  107112. */
  107113. export class GlowLayer extends EffectLayer {
  107114. /**
  107115. * Effect Name of the layer.
  107116. */
  107117. static readonly EffectName: string;
  107118. /**
  107119. * The default blur kernel size used for the glow.
  107120. */
  107121. static DefaultBlurKernelSize: number;
  107122. /**
  107123. * The default texture size ratio used for the glow.
  107124. */
  107125. static DefaultTextureRatio: number;
  107126. /**
  107127. * Sets the kernel size of the blur.
  107128. */
  107129. /**
  107130. * Gets the kernel size of the blur.
  107131. */
  107132. blurKernelSize: number;
  107133. /**
  107134. * Sets the glow intensity.
  107135. */
  107136. /**
  107137. * Gets the glow intensity.
  107138. */
  107139. intensity: number;
  107140. private _options;
  107141. private _intensity;
  107142. private _horizontalBlurPostprocess1;
  107143. private _verticalBlurPostprocess1;
  107144. private _horizontalBlurPostprocess2;
  107145. private _verticalBlurPostprocess2;
  107146. private _blurTexture1;
  107147. private _blurTexture2;
  107148. private _postProcesses1;
  107149. private _postProcesses2;
  107150. private _includedOnlyMeshes;
  107151. private _excludedMeshes;
  107152. /**
  107153. * Callback used to let the user override the color selection on a per mesh basis
  107154. */
  107155. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  107156. /**
  107157. * Callback used to let the user override the texture selection on a per mesh basis
  107158. */
  107159. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  107160. /**
  107161. * Instantiates a new glow Layer and references it to the scene.
  107162. * @param name The name of the layer
  107163. * @param scene The scene to use the layer in
  107164. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  107165. */
  107166. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  107167. /**
  107168. * Get the effect name of the layer.
  107169. * @return The effect name
  107170. */
  107171. getEffectName(): string;
  107172. /**
  107173. * Create the merge effect. This is the shader use to blit the information back
  107174. * to the main canvas at the end of the scene rendering.
  107175. */
  107176. protected _createMergeEffect(): Effect;
  107177. /**
  107178. * Creates the render target textures and post processes used in the glow layer.
  107179. */
  107180. protected _createTextureAndPostProcesses(): void;
  107181. /**
  107182. * Checks for the readiness of the element composing the layer.
  107183. * @param subMesh the mesh to check for
  107184. * @param useInstances specify wether or not to use instances to render the mesh
  107185. * @param emissiveTexture the associated emissive texture used to generate the glow
  107186. * @return true if ready otherwise, false
  107187. */
  107188. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107189. /**
  107190. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107191. */
  107192. needStencil(): boolean;
  107193. /**
  107194. * Returns true if the mesh can be rendered, otherwise false.
  107195. * @param mesh The mesh to render
  107196. * @param material The material used on the mesh
  107197. * @returns true if it can be rendered otherwise false
  107198. */
  107199. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107200. /**
  107201. * Implementation specific of rendering the generating effect on the main canvas.
  107202. * @param effect The effect used to render through
  107203. */
  107204. protected _internalRender(effect: Effect): void;
  107205. /**
  107206. * Sets the required values for both the emissive texture and and the main color.
  107207. */
  107208. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107209. /**
  107210. * Returns true if the mesh should render, otherwise false.
  107211. * @param mesh The mesh to render
  107212. * @returns true if it should render otherwise false
  107213. */
  107214. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107215. /**
  107216. * Adds specific effects defines.
  107217. * @param defines The defines to add specifics to.
  107218. */
  107219. protected _addCustomEffectDefines(defines: string[]): void;
  107220. /**
  107221. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  107222. * @param mesh The mesh to exclude from the glow layer
  107223. */
  107224. addExcludedMesh(mesh: Mesh): void;
  107225. /**
  107226. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  107227. * @param mesh The mesh to remove
  107228. */
  107229. removeExcludedMesh(mesh: Mesh): void;
  107230. /**
  107231. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  107232. * @param mesh The mesh to include in the glow layer
  107233. */
  107234. addIncludedOnlyMesh(mesh: Mesh): void;
  107235. /**
  107236. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  107237. * @param mesh The mesh to remove
  107238. */
  107239. removeIncludedOnlyMesh(mesh: Mesh): void;
  107240. /**
  107241. * Determine if a given mesh will be used in the glow layer
  107242. * @param mesh The mesh to test
  107243. * @returns true if the mesh will be highlighted by the current glow layer
  107244. */
  107245. hasMesh(mesh: AbstractMesh): boolean;
  107246. /**
  107247. * Free any resources and references associated to a mesh.
  107248. * Internal use
  107249. * @param mesh The mesh to free.
  107250. * @hidden
  107251. */
  107252. _disposeMesh(mesh: Mesh): void;
  107253. /**
  107254. * Gets the class name of the effect layer
  107255. * @returns the string with the class name of the effect layer
  107256. */
  107257. getClassName(): string;
  107258. /**
  107259. * Serializes this glow layer
  107260. * @returns a serialized glow layer object
  107261. */
  107262. serialize(): any;
  107263. /**
  107264. * Creates a Glow Layer from parsed glow layer data
  107265. * @param parsedGlowLayer defines glow layer data
  107266. * @param scene defines the current scene
  107267. * @param rootUrl defines the root URL containing the glow layer information
  107268. * @returns a parsed Glow Layer
  107269. */
  107270. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  107271. }
  107272. }
  107273. declare module BABYLON {
  107274. /** @hidden */
  107275. export var glowBlurPostProcessPixelShader: {
  107276. name: string;
  107277. shader: string;
  107278. };
  107279. }
  107280. declare module BABYLON {
  107281. interface AbstractScene {
  107282. /**
  107283. * Return a the first highlight layer of the scene with a given name.
  107284. * @param name The name of the highlight layer to look for.
  107285. * @return The highlight layer if found otherwise null.
  107286. */
  107287. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  107288. }
  107289. /**
  107290. * Highlight layer options. This helps customizing the behaviour
  107291. * of the highlight layer.
  107292. */
  107293. export interface IHighlightLayerOptions {
  107294. /**
  107295. * Multiplication factor apply to the canvas size to compute the render target size
  107296. * used to generated the glowing objects (the smaller the faster).
  107297. */
  107298. mainTextureRatio: number;
  107299. /**
  107300. * Enforces a fixed size texture to ensure resize independant blur.
  107301. */
  107302. mainTextureFixedSize?: number;
  107303. /**
  107304. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  107305. * of the picture to blur (the smaller the faster).
  107306. */
  107307. blurTextureSizeRatio: number;
  107308. /**
  107309. * How big in texel of the blur texture is the vertical blur.
  107310. */
  107311. blurVerticalSize: number;
  107312. /**
  107313. * How big in texel of the blur texture is the horizontal blur.
  107314. */
  107315. blurHorizontalSize: number;
  107316. /**
  107317. * Alpha blending mode used to apply the blur. Default is combine.
  107318. */
  107319. alphaBlendingMode: number;
  107320. /**
  107321. * The camera attached to the layer.
  107322. */
  107323. camera: Nullable<Camera>;
  107324. /**
  107325. * Should we display highlight as a solid stroke?
  107326. */
  107327. isStroke?: boolean;
  107328. /**
  107329. * The rendering group to draw the layer in.
  107330. */
  107331. renderingGroupId: number;
  107332. }
  107333. /**
  107334. * The highlight layer Helps adding a glow effect around a mesh.
  107335. *
  107336. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107337. * glowy meshes to your scene.
  107338. *
  107339. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  107340. */
  107341. export class HighlightLayer extends EffectLayer {
  107342. name: string;
  107343. /**
  107344. * Effect Name of the highlight layer.
  107345. */
  107346. static readonly EffectName: string;
  107347. /**
  107348. * The neutral color used during the preparation of the glow effect.
  107349. * This is black by default as the blend operation is a blend operation.
  107350. */
  107351. static NeutralColor: Color4;
  107352. /**
  107353. * Stencil value used for glowing meshes.
  107354. */
  107355. static GlowingMeshStencilReference: number;
  107356. /**
  107357. * Stencil value used for the other meshes in the scene.
  107358. */
  107359. static NormalMeshStencilReference: number;
  107360. /**
  107361. * Specifies whether or not the inner glow is ACTIVE in the layer.
  107362. */
  107363. innerGlow: boolean;
  107364. /**
  107365. * Specifies whether or not the outer glow is ACTIVE in the layer.
  107366. */
  107367. outerGlow: boolean;
  107368. /**
  107369. * Specifies the horizontal size of the blur.
  107370. */
  107371. /**
  107372. * Gets the horizontal size of the blur.
  107373. */
  107374. blurHorizontalSize: number;
  107375. /**
  107376. * Specifies the vertical size of the blur.
  107377. */
  107378. /**
  107379. * Gets the vertical size of the blur.
  107380. */
  107381. blurVerticalSize: number;
  107382. /**
  107383. * An event triggered when the highlight layer is being blurred.
  107384. */
  107385. onBeforeBlurObservable: Observable<HighlightLayer>;
  107386. /**
  107387. * An event triggered when the highlight layer has been blurred.
  107388. */
  107389. onAfterBlurObservable: Observable<HighlightLayer>;
  107390. private _instanceGlowingMeshStencilReference;
  107391. private _options;
  107392. private _downSamplePostprocess;
  107393. private _horizontalBlurPostprocess;
  107394. private _verticalBlurPostprocess;
  107395. private _blurTexture;
  107396. private _meshes;
  107397. private _excludedMeshes;
  107398. /**
  107399. * Instantiates a new highlight Layer and references it to the scene..
  107400. * @param name The name of the layer
  107401. * @param scene The scene to use the layer in
  107402. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  107403. */
  107404. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  107405. /**
  107406. * Get the effect name of the layer.
  107407. * @return The effect name
  107408. */
  107409. getEffectName(): string;
  107410. /**
  107411. * Create the merge effect. This is the shader use to blit the information back
  107412. * to the main canvas at the end of the scene rendering.
  107413. */
  107414. protected _createMergeEffect(): Effect;
  107415. /**
  107416. * Creates the render target textures and post processes used in the highlight layer.
  107417. */
  107418. protected _createTextureAndPostProcesses(): void;
  107419. /**
  107420. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107421. */
  107422. needStencil(): boolean;
  107423. /**
  107424. * Checks for the readiness of the element composing the layer.
  107425. * @param subMesh the mesh to check for
  107426. * @param useInstances specify wether or not to use instances to render the mesh
  107427. * @param emissiveTexture the associated emissive texture used to generate the glow
  107428. * @return true if ready otherwise, false
  107429. */
  107430. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107431. /**
  107432. * Implementation specific of rendering the generating effect on the main canvas.
  107433. * @param effect The effect used to render through
  107434. */
  107435. protected _internalRender(effect: Effect): void;
  107436. /**
  107437. * Returns true if the layer contains information to display, otherwise false.
  107438. */
  107439. shouldRender(): boolean;
  107440. /**
  107441. * Returns true if the mesh should render, otherwise false.
  107442. * @param mesh The mesh to render
  107443. * @returns true if it should render otherwise false
  107444. */
  107445. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107446. /**
  107447. * Sets the required values for both the emissive texture and and the main color.
  107448. */
  107449. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107450. /**
  107451. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  107452. * @param mesh The mesh to exclude from the highlight layer
  107453. */
  107454. addExcludedMesh(mesh: Mesh): void;
  107455. /**
  107456. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  107457. * @param mesh The mesh to highlight
  107458. */
  107459. removeExcludedMesh(mesh: Mesh): void;
  107460. /**
  107461. * Determine if a given mesh will be highlighted by the current HighlightLayer
  107462. * @param mesh mesh to test
  107463. * @returns true if the mesh will be highlighted by the current HighlightLayer
  107464. */
  107465. hasMesh(mesh: AbstractMesh): boolean;
  107466. /**
  107467. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  107468. * @param mesh The mesh to highlight
  107469. * @param color The color of the highlight
  107470. * @param glowEmissiveOnly Extract the glow from the emissive texture
  107471. */
  107472. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  107473. /**
  107474. * Remove a mesh from the highlight layer in order to make it stop glowing.
  107475. * @param mesh The mesh to highlight
  107476. */
  107477. removeMesh(mesh: Mesh): void;
  107478. /**
  107479. * Force the stencil to the normal expected value for none glowing parts
  107480. */
  107481. private _defaultStencilReference;
  107482. /**
  107483. * Free any resources and references associated to a mesh.
  107484. * Internal use
  107485. * @param mesh The mesh to free.
  107486. * @hidden
  107487. */
  107488. _disposeMesh(mesh: Mesh): void;
  107489. /**
  107490. * Dispose the highlight layer and free resources.
  107491. */
  107492. dispose(): void;
  107493. /**
  107494. * Gets the class name of the effect layer
  107495. * @returns the string with the class name of the effect layer
  107496. */
  107497. getClassName(): string;
  107498. /**
  107499. * Serializes this Highlight layer
  107500. * @returns a serialized Highlight layer object
  107501. */
  107502. serialize(): any;
  107503. /**
  107504. * Creates a Highlight layer from parsed Highlight layer data
  107505. * @param parsedHightlightLayer defines the Highlight layer data
  107506. * @param scene defines the current scene
  107507. * @param rootUrl defines the root URL containing the Highlight layer information
  107508. * @returns a parsed Highlight layer
  107509. */
  107510. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  107511. }
  107512. }
  107513. declare module BABYLON {
  107514. /** @hidden */
  107515. export var lensFlarePixelShader: {
  107516. name: string;
  107517. shader: string;
  107518. };
  107519. }
  107520. declare module BABYLON {
  107521. /** @hidden */
  107522. export var lensFlareVertexShader: {
  107523. name: string;
  107524. shader: string;
  107525. };
  107526. }
  107527. declare module BABYLON {
  107528. /**
  107529. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107530. * It is usually composed of several `lensFlare`.
  107531. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107532. */
  107533. export class LensFlareSystem {
  107534. /**
  107535. * Define the name of the lens flare system
  107536. */
  107537. name: string;
  107538. /**
  107539. * List of lens flares used in this system.
  107540. */
  107541. lensFlares: LensFlare[];
  107542. /**
  107543. * Define a limit from the border the lens flare can be visible.
  107544. */
  107545. borderLimit: number;
  107546. /**
  107547. * Define a viewport border we do not want to see the lens flare in.
  107548. */
  107549. viewportBorder: number;
  107550. /**
  107551. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107552. */
  107553. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107554. /**
  107555. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107556. */
  107557. layerMask: number;
  107558. /**
  107559. * Define the id of the lens flare system in the scene.
  107560. * (equal to name by default)
  107561. */
  107562. id: string;
  107563. private _scene;
  107564. private _emitter;
  107565. private _vertexBuffers;
  107566. private _indexBuffer;
  107567. private _effect;
  107568. private _positionX;
  107569. private _positionY;
  107570. private _isEnabled;
  107571. /** @hidden */
  107572. static _SceneComponentInitialization: (scene: Scene) => void;
  107573. /**
  107574. * Instantiates a lens flare system.
  107575. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107576. * It is usually composed of several `lensFlare`.
  107577. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107578. * @param name Define the name of the lens flare system in the scene
  107579. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107580. * @param scene Define the scene the lens flare system belongs to
  107581. */
  107582. constructor(
  107583. /**
  107584. * Define the name of the lens flare system
  107585. */
  107586. name: string, emitter: any, scene: Scene);
  107587. /**
  107588. * Define if the lens flare system is enabled.
  107589. */
  107590. isEnabled: boolean;
  107591. /**
  107592. * Get the scene the effects belongs to.
  107593. * @returns the scene holding the lens flare system
  107594. */
  107595. getScene(): Scene;
  107596. /**
  107597. * Get the emitter of the lens flare system.
  107598. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107599. * @returns the emitter of the lens flare system
  107600. */
  107601. getEmitter(): any;
  107602. /**
  107603. * Set the emitter of the lens flare system.
  107604. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107605. * @param newEmitter Define the new emitter of the system
  107606. */
  107607. setEmitter(newEmitter: any): void;
  107608. /**
  107609. * Get the lens flare system emitter position.
  107610. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107611. * @returns the position
  107612. */
  107613. getEmitterPosition(): Vector3;
  107614. /**
  107615. * @hidden
  107616. */
  107617. computeEffectivePosition(globalViewport: Viewport): boolean;
  107618. /** @hidden */
  107619. _isVisible(): boolean;
  107620. /**
  107621. * @hidden
  107622. */
  107623. render(): boolean;
  107624. /**
  107625. * Dispose and release the lens flare with its associated resources.
  107626. */
  107627. dispose(): void;
  107628. /**
  107629. * Parse a lens flare system from a JSON repressentation
  107630. * @param parsedLensFlareSystem Define the JSON to parse
  107631. * @param scene Define the scene the parsed system should be instantiated in
  107632. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107633. * @returns the parsed system
  107634. */
  107635. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107636. /**
  107637. * Serialize the current Lens Flare System into a JSON representation.
  107638. * @returns the serialized JSON
  107639. */
  107640. serialize(): any;
  107641. }
  107642. }
  107643. declare module BABYLON {
  107644. /**
  107645. * This represents one of the lens effect in a `lensFlareSystem`.
  107646. * It controls one of the indiviual texture used in the effect.
  107647. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107648. */
  107649. export class LensFlare {
  107650. /**
  107651. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107652. */
  107653. size: number;
  107654. /**
  107655. * 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.
  107656. */
  107657. position: number;
  107658. /**
  107659. * Define the lens color.
  107660. */
  107661. color: Color3;
  107662. /**
  107663. * Define the lens texture.
  107664. */
  107665. texture: Nullable<Texture>;
  107666. /**
  107667. * Define the alpha mode to render this particular lens.
  107668. */
  107669. alphaMode: number;
  107670. private _system;
  107671. /**
  107672. * Creates a new Lens Flare.
  107673. * This represents one of the lens effect in a `lensFlareSystem`.
  107674. * It controls one of the indiviual texture used in the effect.
  107675. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107676. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107677. * @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.
  107678. * @param color Define the lens color
  107679. * @param imgUrl Define the lens texture url
  107680. * @param system Define the `lensFlareSystem` this flare is part of
  107681. * @returns The newly created Lens Flare
  107682. */
  107683. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107684. /**
  107685. * Instantiates a new Lens Flare.
  107686. * This represents one of the lens effect in a `lensFlareSystem`.
  107687. * It controls one of the indiviual texture used in the effect.
  107688. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107689. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107690. * @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.
  107691. * @param color Define the lens color
  107692. * @param imgUrl Define the lens texture url
  107693. * @param system Define the `lensFlareSystem` this flare is part of
  107694. */
  107695. constructor(
  107696. /**
  107697. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107698. */
  107699. size: number,
  107700. /**
  107701. * 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.
  107702. */
  107703. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107704. /**
  107705. * Dispose and release the lens flare with its associated resources.
  107706. */
  107707. dispose(): void;
  107708. }
  107709. }
  107710. declare module BABYLON {
  107711. interface AbstractScene {
  107712. /**
  107713. * The list of lens flare system added to the scene
  107714. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107715. */
  107716. lensFlareSystems: Array<LensFlareSystem>;
  107717. /**
  107718. * Removes the given lens flare system from this scene.
  107719. * @param toRemove The lens flare system to remove
  107720. * @returns The index of the removed lens flare system
  107721. */
  107722. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107723. /**
  107724. * Adds the given lens flare system to this scene
  107725. * @param newLensFlareSystem The lens flare system to add
  107726. */
  107727. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107728. /**
  107729. * Gets a lens flare system using its name
  107730. * @param name defines the name to look for
  107731. * @returns the lens flare system or null if not found
  107732. */
  107733. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107734. /**
  107735. * Gets a lens flare system using its id
  107736. * @param id defines the id to look for
  107737. * @returns the lens flare system or null if not found
  107738. */
  107739. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107740. }
  107741. /**
  107742. * Defines the lens flare scene component responsible to manage any lens flares
  107743. * in a given scene.
  107744. */
  107745. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107746. /**
  107747. * The component name helpfull to identify the component in the list of scene components.
  107748. */
  107749. readonly name: string;
  107750. /**
  107751. * The scene the component belongs to.
  107752. */
  107753. scene: Scene;
  107754. /**
  107755. * Creates a new instance of the component for the given scene
  107756. * @param scene Defines the scene to register the component in
  107757. */
  107758. constructor(scene: Scene);
  107759. /**
  107760. * Registers the component in a given scene
  107761. */
  107762. register(): void;
  107763. /**
  107764. * Rebuilds the elements related to this component in case of
  107765. * context lost for instance.
  107766. */
  107767. rebuild(): void;
  107768. /**
  107769. * Adds all the element from the container to the scene
  107770. * @param container the container holding the elements
  107771. */
  107772. addFromContainer(container: AbstractScene): void;
  107773. /**
  107774. * Removes all the elements in the container from the scene
  107775. * @param container contains the elements to remove
  107776. * @param dispose if the removed element should be disposed (default: false)
  107777. */
  107778. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107779. /**
  107780. * Serializes the component data to the specified json object
  107781. * @param serializationObject The object to serialize to
  107782. */
  107783. serialize(serializationObject: any): void;
  107784. /**
  107785. * Disposes the component and the associated ressources.
  107786. */
  107787. dispose(): void;
  107788. private _draw;
  107789. }
  107790. }
  107791. declare module BABYLON {
  107792. /**
  107793. * Defines the shadow generator component responsible to manage any shadow generators
  107794. * in a given scene.
  107795. */
  107796. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107797. /**
  107798. * The component name helpfull to identify the component in the list of scene components.
  107799. */
  107800. readonly name: string;
  107801. /**
  107802. * The scene the component belongs to.
  107803. */
  107804. scene: Scene;
  107805. /**
  107806. * Creates a new instance of the component for the given scene
  107807. * @param scene Defines the scene to register the component in
  107808. */
  107809. constructor(scene: Scene);
  107810. /**
  107811. * Registers the component in a given scene
  107812. */
  107813. register(): void;
  107814. /**
  107815. * Rebuilds the elements related to this component in case of
  107816. * context lost for instance.
  107817. */
  107818. rebuild(): void;
  107819. /**
  107820. * Serializes the component data to the specified json object
  107821. * @param serializationObject The object to serialize to
  107822. */
  107823. serialize(serializationObject: any): void;
  107824. /**
  107825. * Adds all the element from the container to the scene
  107826. * @param container the container holding the elements
  107827. */
  107828. addFromContainer(container: AbstractScene): void;
  107829. /**
  107830. * Removes all the elements in the container from the scene
  107831. * @param container contains the elements to remove
  107832. * @param dispose if the removed element should be disposed (default: false)
  107833. */
  107834. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107835. /**
  107836. * Rebuilds the elements related to this component in case of
  107837. * context lost for instance.
  107838. */
  107839. dispose(): void;
  107840. private _gatherRenderTargets;
  107841. }
  107842. }
  107843. declare module BABYLON {
  107844. /**
  107845. * A point light is a light defined by an unique point in world space.
  107846. * The light is emitted in every direction from this point.
  107847. * A good example of a point light is a standard light bulb.
  107848. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107849. */
  107850. export class PointLight extends ShadowLight {
  107851. private _shadowAngle;
  107852. /**
  107853. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107854. * This specifies what angle the shadow will use to be created.
  107855. *
  107856. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107857. */
  107858. /**
  107859. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107860. * This specifies what angle the shadow will use to be created.
  107861. *
  107862. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107863. */
  107864. shadowAngle: number;
  107865. /**
  107866. * Gets the direction if it has been set.
  107867. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107868. */
  107869. /**
  107870. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107871. */
  107872. direction: Vector3;
  107873. /**
  107874. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107875. * A PointLight emits the light in every direction.
  107876. * It can cast shadows.
  107877. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107878. * ```javascript
  107879. * var pointLight = new PointLight("pl", camera.position, scene);
  107880. * ```
  107881. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107882. * @param name The light friendly name
  107883. * @param position The position of the point light in the scene
  107884. * @param scene The scene the lights belongs to
  107885. */
  107886. constructor(name: string, position: Vector3, scene: Scene);
  107887. /**
  107888. * Returns the string "PointLight"
  107889. * @returns the class name
  107890. */
  107891. getClassName(): string;
  107892. /**
  107893. * Returns the integer 0.
  107894. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107895. */
  107896. getTypeID(): number;
  107897. /**
  107898. * Specifies wether or not the shadowmap should be a cube texture.
  107899. * @returns true if the shadowmap needs to be a cube texture.
  107900. */
  107901. needCube(): boolean;
  107902. /**
  107903. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107904. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107905. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107906. */
  107907. getShadowDirection(faceIndex?: number): Vector3;
  107908. /**
  107909. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107910. * - fov = PI / 2
  107911. * - aspect ratio : 1.0
  107912. * - z-near and far equal to the active camera minZ and maxZ.
  107913. * Returns the PointLight.
  107914. */
  107915. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107916. protected _buildUniformLayout(): void;
  107917. /**
  107918. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107919. * @param effect The effect to update
  107920. * @param lightIndex The index of the light in the effect to update
  107921. * @returns The point light
  107922. */
  107923. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107924. /**
  107925. * Prepares the list of defines specific to the light type.
  107926. * @param defines the list of defines
  107927. * @param lightIndex defines the index of the light for the effect
  107928. */
  107929. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107930. }
  107931. }
  107932. declare module BABYLON {
  107933. /**
  107934. * Header information of HDR texture files.
  107935. */
  107936. export interface HDRInfo {
  107937. /**
  107938. * The height of the texture in pixels.
  107939. */
  107940. height: number;
  107941. /**
  107942. * The width of the texture in pixels.
  107943. */
  107944. width: number;
  107945. /**
  107946. * The index of the beginning of the data in the binary file.
  107947. */
  107948. dataPosition: number;
  107949. }
  107950. /**
  107951. * This groups tools to convert HDR texture to native colors array.
  107952. */
  107953. export class HDRTools {
  107954. private static Ldexp;
  107955. private static Rgbe2float;
  107956. private static readStringLine;
  107957. /**
  107958. * Reads header information from an RGBE texture stored in a native array.
  107959. * More information on this format are available here:
  107960. * https://en.wikipedia.org/wiki/RGBE_image_format
  107961. *
  107962. * @param uint8array The binary file stored in native array.
  107963. * @return The header information.
  107964. */
  107965. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107966. /**
  107967. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107968. * This RGBE texture needs to store the information as a panorama.
  107969. *
  107970. * More information on this format are available here:
  107971. * https://en.wikipedia.org/wiki/RGBE_image_format
  107972. *
  107973. * @param buffer The binary file stored in an array buffer.
  107974. * @param size The expected size of the extracted cubemap.
  107975. * @return The Cube Map information.
  107976. */
  107977. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107978. /**
  107979. * Returns the pixels data extracted from an RGBE texture.
  107980. * This pixels will be stored left to right up to down in the R G B order in one array.
  107981. *
  107982. * More information on this format are available here:
  107983. * https://en.wikipedia.org/wiki/RGBE_image_format
  107984. *
  107985. * @param uint8array The binary file stored in an array buffer.
  107986. * @param hdrInfo The header information of the file.
  107987. * @return The pixels data in RGB right to left up to down order.
  107988. */
  107989. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107990. private static RGBE_ReadPixels_RLE;
  107991. }
  107992. }
  107993. declare module BABYLON {
  107994. /**
  107995. * This represents a texture coming from an HDR input.
  107996. *
  107997. * The only supported format is currently panorama picture stored in RGBE format.
  107998. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107999. */
  108000. export class HDRCubeTexture extends BaseTexture {
  108001. private static _facesMapping;
  108002. private _generateHarmonics;
  108003. private _noMipmap;
  108004. private _textureMatrix;
  108005. private _size;
  108006. private _onLoad;
  108007. private _onError;
  108008. /**
  108009. * The texture URL.
  108010. */
  108011. url: string;
  108012. /**
  108013. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  108014. */
  108015. coordinatesMode: number;
  108016. protected _isBlocking: boolean;
  108017. /**
  108018. * Sets wether or not the texture is blocking during loading.
  108019. */
  108020. /**
  108021. * Gets wether or not the texture is blocking during loading.
  108022. */
  108023. isBlocking: boolean;
  108024. protected _rotationY: number;
  108025. /**
  108026. * Sets texture matrix rotation angle around Y axis in radians.
  108027. */
  108028. /**
  108029. * Gets texture matrix rotation angle around Y axis radians.
  108030. */
  108031. rotationY: number;
  108032. /**
  108033. * Gets or sets the center of the bounding box associated with the cube texture
  108034. * It must define where the camera used to render the texture was set
  108035. */
  108036. boundingBoxPosition: Vector3;
  108037. private _boundingBoxSize;
  108038. /**
  108039. * Gets or sets the size of the bounding box associated with the cube texture
  108040. * When defined, the cubemap will switch to local mode
  108041. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  108042. * @example https://www.babylonjs-playground.com/#RNASML
  108043. */
  108044. boundingBoxSize: Vector3;
  108045. /**
  108046. * Instantiates an HDRTexture from the following parameters.
  108047. *
  108048. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  108049. * @param scene The scene the texture will be used in
  108050. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108051. * @param noMipmap Forces to not generate the mipmap if true
  108052. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  108053. * @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)
  108054. * @param reserved Reserved flag for internal use.
  108055. */
  108056. 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>);
  108057. /**
  108058. * Get the current class name of the texture useful for serialization or dynamic coding.
  108059. * @returns "HDRCubeTexture"
  108060. */
  108061. getClassName(): string;
  108062. /**
  108063. * Occurs when the file is raw .hdr file.
  108064. */
  108065. private loadTexture;
  108066. clone(): HDRCubeTexture;
  108067. delayLoad(): void;
  108068. /**
  108069. * Get the texture reflection matrix used to rotate/transform the reflection.
  108070. * @returns the reflection matrix
  108071. */
  108072. getReflectionTextureMatrix(): Matrix;
  108073. /**
  108074. * Set the texture reflection matrix used to rotate/transform the reflection.
  108075. * @param value Define the reflection matrix to set
  108076. */
  108077. setReflectionTextureMatrix(value: Matrix): void;
  108078. /**
  108079. * Parses a JSON representation of an HDR Texture in order to create the texture
  108080. * @param parsedTexture Define the JSON representation
  108081. * @param scene Define the scene the texture should be created in
  108082. * @param rootUrl Define the root url in case we need to load relative dependencies
  108083. * @returns the newly created texture after parsing
  108084. */
  108085. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  108086. serialize(): any;
  108087. }
  108088. }
  108089. declare module BABYLON {
  108090. /**
  108091. * Class used to control physics engine
  108092. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108093. */
  108094. export class PhysicsEngine implements IPhysicsEngine {
  108095. private _physicsPlugin;
  108096. /**
  108097. * Global value used to control the smallest number supported by the simulation
  108098. */
  108099. static Epsilon: number;
  108100. private _impostors;
  108101. private _joints;
  108102. /**
  108103. * Gets the gravity vector used by the simulation
  108104. */
  108105. gravity: Vector3;
  108106. /**
  108107. * Factory used to create the default physics plugin.
  108108. * @returns The default physics plugin
  108109. */
  108110. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  108111. /**
  108112. * Creates a new Physics Engine
  108113. * @param gravity defines the gravity vector used by the simulation
  108114. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  108115. */
  108116. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  108117. /**
  108118. * Sets the gravity vector used by the simulation
  108119. * @param gravity defines the gravity vector to use
  108120. */
  108121. setGravity(gravity: Vector3): void;
  108122. /**
  108123. * Set the time step of the physics engine.
  108124. * Default is 1/60.
  108125. * To slow it down, enter 1/600 for example.
  108126. * To speed it up, 1/30
  108127. * @param newTimeStep defines the new timestep to apply to this world.
  108128. */
  108129. setTimeStep(newTimeStep?: number): void;
  108130. /**
  108131. * Get the time step of the physics engine.
  108132. * @returns the current time step
  108133. */
  108134. getTimeStep(): number;
  108135. /**
  108136. * Release all resources
  108137. */
  108138. dispose(): void;
  108139. /**
  108140. * Gets the name of the current physics plugin
  108141. * @returns the name of the plugin
  108142. */
  108143. getPhysicsPluginName(): string;
  108144. /**
  108145. * Adding a new impostor for the impostor tracking.
  108146. * This will be done by the impostor itself.
  108147. * @param impostor the impostor to add
  108148. */
  108149. addImpostor(impostor: PhysicsImpostor): void;
  108150. /**
  108151. * Remove an impostor from the engine.
  108152. * This impostor and its mesh will not longer be updated by the physics engine.
  108153. * @param impostor the impostor to remove
  108154. */
  108155. removeImpostor(impostor: PhysicsImpostor): void;
  108156. /**
  108157. * Add a joint to the physics engine
  108158. * @param mainImpostor defines the main impostor to which the joint is added.
  108159. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108160. * @param joint defines the joint that will connect both impostors.
  108161. */
  108162. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108163. /**
  108164. * Removes a joint from the simulation
  108165. * @param mainImpostor defines the impostor used with the joint
  108166. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108167. * @param joint defines the joint to remove
  108168. */
  108169. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108170. /**
  108171. * Called by the scene. No need to call it.
  108172. * @param delta defines the timespam between frames
  108173. */
  108174. _step(delta: number): void;
  108175. /**
  108176. * Gets the current plugin used to run the simulation
  108177. * @returns current plugin
  108178. */
  108179. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108180. /**
  108181. * Gets the list of physic impostors
  108182. * @returns an array of PhysicsImpostor
  108183. */
  108184. getImpostors(): Array<PhysicsImpostor>;
  108185. /**
  108186. * Gets the impostor for a physics enabled object
  108187. * @param object defines the object impersonated by the impostor
  108188. * @returns the PhysicsImpostor or null if not found
  108189. */
  108190. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108191. /**
  108192. * Gets the impostor for a physics body object
  108193. * @param body defines physics body used by the impostor
  108194. * @returns the PhysicsImpostor or null if not found
  108195. */
  108196. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108197. /**
  108198. * Does a raycast in the physics world
  108199. * @param from when should the ray start?
  108200. * @param to when should the ray end?
  108201. * @returns PhysicsRaycastResult
  108202. */
  108203. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108204. }
  108205. }
  108206. declare module BABYLON {
  108207. /** @hidden */
  108208. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  108209. private _useDeltaForWorldStep;
  108210. world: any;
  108211. name: string;
  108212. private _physicsMaterials;
  108213. private _fixedTimeStep;
  108214. private _cannonRaycastResult;
  108215. private _raycastResult;
  108216. private _removeAfterStep;
  108217. BJSCANNON: any;
  108218. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  108219. setGravity(gravity: Vector3): void;
  108220. setTimeStep(timeStep: number): void;
  108221. getTimeStep(): number;
  108222. executeStep(delta: number): void;
  108223. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108224. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108225. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108226. private _processChildMeshes;
  108227. removePhysicsBody(impostor: PhysicsImpostor): void;
  108228. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108229. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108230. private _addMaterial;
  108231. private _checkWithEpsilon;
  108232. private _createShape;
  108233. private _createHeightmap;
  108234. private _minus90X;
  108235. private _plus90X;
  108236. private _tmpPosition;
  108237. private _tmpDeltaPosition;
  108238. private _tmpUnityRotation;
  108239. private _updatePhysicsBodyTransformation;
  108240. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108241. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108242. isSupported(): boolean;
  108243. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108244. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108245. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108246. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108247. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108248. getBodyMass(impostor: PhysicsImpostor): number;
  108249. getBodyFriction(impostor: PhysicsImpostor): number;
  108250. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108251. getBodyRestitution(impostor: PhysicsImpostor): number;
  108252. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108253. sleepBody(impostor: PhysicsImpostor): void;
  108254. wakeUpBody(impostor: PhysicsImpostor): void;
  108255. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  108256. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108257. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108258. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108259. getRadius(impostor: PhysicsImpostor): number;
  108260. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108261. dispose(): void;
  108262. private _extendNamespace;
  108263. /**
  108264. * Does a raycast in the physics world
  108265. * @param from when should the ray start?
  108266. * @param to when should the ray end?
  108267. * @returns PhysicsRaycastResult
  108268. */
  108269. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108270. }
  108271. }
  108272. declare module BABYLON {
  108273. /** @hidden */
  108274. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  108275. world: any;
  108276. name: string;
  108277. BJSOIMO: any;
  108278. private _raycastResult;
  108279. constructor(iterations?: number, oimoInjection?: any);
  108280. setGravity(gravity: Vector3): void;
  108281. setTimeStep(timeStep: number): void;
  108282. getTimeStep(): number;
  108283. private _tmpImpostorsArray;
  108284. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108285. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108286. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108287. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108288. private _tmpPositionVector;
  108289. removePhysicsBody(impostor: PhysicsImpostor): void;
  108290. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108291. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108292. isSupported(): boolean;
  108293. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108294. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108295. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108296. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108297. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108298. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108299. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108300. getBodyMass(impostor: PhysicsImpostor): number;
  108301. getBodyFriction(impostor: PhysicsImpostor): number;
  108302. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108303. getBodyRestitution(impostor: PhysicsImpostor): number;
  108304. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108305. sleepBody(impostor: PhysicsImpostor): void;
  108306. wakeUpBody(impostor: PhysicsImpostor): void;
  108307. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108308. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  108309. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  108310. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108311. getRadius(impostor: PhysicsImpostor): number;
  108312. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108313. dispose(): void;
  108314. /**
  108315. * Does a raycast in the physics world
  108316. * @param from when should the ray start?
  108317. * @param to when should the ray end?
  108318. * @returns PhysicsRaycastResult
  108319. */
  108320. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108321. }
  108322. }
  108323. declare module BABYLON {
  108324. /**
  108325. * Class containing static functions to help procedurally build meshes
  108326. */
  108327. export class RibbonBuilder {
  108328. /**
  108329. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108330. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108331. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108332. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108333. * * 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
  108334. * * 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
  108335. * * 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
  108336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108337. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108338. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108339. * * 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
  108340. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108341. * * 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
  108342. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108344. * @param name defines the name of the mesh
  108345. * @param options defines the options used to create the mesh
  108346. * @param scene defines the hosting scene
  108347. * @returns the ribbon mesh
  108348. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108349. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108350. */
  108351. static CreateRibbon(name: string, options: {
  108352. pathArray: Vector3[][];
  108353. closeArray?: boolean;
  108354. closePath?: boolean;
  108355. offset?: number;
  108356. updatable?: boolean;
  108357. sideOrientation?: number;
  108358. frontUVs?: Vector4;
  108359. backUVs?: Vector4;
  108360. instance?: Mesh;
  108361. invertUV?: boolean;
  108362. uvs?: Vector2[];
  108363. colors?: Color4[];
  108364. }, scene?: Nullable<Scene>): Mesh;
  108365. }
  108366. }
  108367. declare module BABYLON {
  108368. /**
  108369. * Class containing static functions to help procedurally build meshes
  108370. */
  108371. export class ShapeBuilder {
  108372. /**
  108373. * 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.
  108374. * * 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.
  108375. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108376. * * 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.
  108377. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  108378. * * 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
  108379. * * 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
  108380. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  108381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108383. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108385. * @param name defines the name of the mesh
  108386. * @param options defines the options used to create the mesh
  108387. * @param scene defines the hosting scene
  108388. * @returns the extruded shape mesh
  108389. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108391. */
  108392. static ExtrudeShape(name: string, options: {
  108393. shape: Vector3[];
  108394. path: Vector3[];
  108395. scale?: number;
  108396. rotation?: number;
  108397. cap?: number;
  108398. updatable?: boolean;
  108399. sideOrientation?: number;
  108400. frontUVs?: Vector4;
  108401. backUVs?: Vector4;
  108402. instance?: Mesh;
  108403. invertUV?: boolean;
  108404. }, scene?: Nullable<Scene>): Mesh;
  108405. /**
  108406. * Creates an custom extruded shape mesh.
  108407. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  108408. * * 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.
  108409. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108410. * * 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
  108411. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  108412. * * 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
  108413. * * It must returns a float value that will be the scale value applied to the shape on each path point
  108414. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108415. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  108416. * * 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
  108417. * * 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
  108418. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  108419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108421. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108423. * @param name defines the name of the mesh
  108424. * @param options defines the options used to create the mesh
  108425. * @param scene defines the hosting scene
  108426. * @returns the custom extruded shape mesh
  108427. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  108428. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108430. */
  108431. static ExtrudeShapeCustom(name: string, options: {
  108432. shape: Vector3[];
  108433. path: Vector3[];
  108434. scaleFunction?: any;
  108435. rotationFunction?: any;
  108436. ribbonCloseArray?: boolean;
  108437. ribbonClosePath?: boolean;
  108438. cap?: number;
  108439. updatable?: boolean;
  108440. sideOrientation?: number;
  108441. frontUVs?: Vector4;
  108442. backUVs?: Vector4;
  108443. instance?: Mesh;
  108444. invertUV?: boolean;
  108445. }, scene?: Nullable<Scene>): Mesh;
  108446. private static _ExtrudeShapeGeneric;
  108447. }
  108448. }
  108449. declare module BABYLON {
  108450. /**
  108451. * AmmoJS Physics plugin
  108452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108453. * @see https://github.com/kripken/ammo.js/
  108454. */
  108455. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108456. private _useDeltaForWorldStep;
  108457. /**
  108458. * Reference to the Ammo library
  108459. */
  108460. bjsAMMO: any;
  108461. /**
  108462. * Created ammoJS world which physics bodies are added to
  108463. */
  108464. world: any;
  108465. /**
  108466. * Name of the plugin
  108467. */
  108468. name: string;
  108469. private _timeStep;
  108470. private _fixedTimeStep;
  108471. private _maxSteps;
  108472. private _tmpQuaternion;
  108473. private _tmpAmmoTransform;
  108474. private _tmpAmmoQuaternion;
  108475. private _tmpAmmoConcreteContactResultCallback;
  108476. private _collisionConfiguration;
  108477. private _dispatcher;
  108478. private _overlappingPairCache;
  108479. private _solver;
  108480. private _softBodySolver;
  108481. private _tmpAmmoVectorA;
  108482. private _tmpAmmoVectorB;
  108483. private _tmpAmmoVectorC;
  108484. private _tmpAmmoVectorD;
  108485. private _tmpContactCallbackResult;
  108486. private _tmpAmmoVectorRCA;
  108487. private _tmpAmmoVectorRCB;
  108488. private _raycastResult;
  108489. private static readonly DISABLE_COLLISION_FLAG;
  108490. private static readonly KINEMATIC_FLAG;
  108491. private static readonly DISABLE_DEACTIVATION_FLAG;
  108492. /**
  108493. * Initializes the ammoJS plugin
  108494. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108495. * @param ammoInjection can be used to inject your own ammo reference
  108496. */
  108497. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108498. /**
  108499. * Sets the gravity of the physics world (m/(s^2))
  108500. * @param gravity Gravity to set
  108501. */
  108502. setGravity(gravity: Vector3): void;
  108503. /**
  108504. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108505. * @param timeStep timestep to use in seconds
  108506. */
  108507. setTimeStep(timeStep: number): void;
  108508. /**
  108509. * 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)
  108510. * @param fixedTimeStep fixedTimeStep to use in seconds
  108511. */
  108512. setFixedTimeStep(fixedTimeStep: number): void;
  108513. /**
  108514. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108515. * @param maxSteps the maximum number of steps by the physics engine per frame
  108516. */
  108517. setMaxSteps(maxSteps: number): void;
  108518. /**
  108519. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108520. * @returns the current timestep in seconds
  108521. */
  108522. getTimeStep(): number;
  108523. private _isImpostorInContact;
  108524. private _isImpostorPairInContact;
  108525. private _stepSimulation;
  108526. /**
  108527. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108528. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108529. * After the step the babylon meshes are set to the position of the physics imposters
  108530. * @param delta amount of time to step forward
  108531. * @param impostors array of imposters to update before/after the step
  108532. */
  108533. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108534. /**
  108535. * Update babylon mesh to match physics world object
  108536. * @param impostor imposter to match
  108537. */
  108538. private _afterSoftStep;
  108539. /**
  108540. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108541. * @param impostor imposter to match
  108542. */
  108543. private _ropeStep;
  108544. /**
  108545. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108546. * @param impostor imposter to match
  108547. */
  108548. private _softbodyOrClothStep;
  108549. private _tmpVector;
  108550. private _tmpMatrix;
  108551. /**
  108552. * Applies an impulse on the imposter
  108553. * @param impostor imposter to apply impulse to
  108554. * @param force amount of force to be applied to the imposter
  108555. * @param contactPoint the location to apply the impulse on the imposter
  108556. */
  108557. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108558. /**
  108559. * Applies a force on the imposter
  108560. * @param impostor imposter to apply force
  108561. * @param force amount of force to be applied to the imposter
  108562. * @param contactPoint the location to apply the force on the imposter
  108563. */
  108564. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108565. /**
  108566. * Creates a physics body using the plugin
  108567. * @param impostor the imposter to create the physics body on
  108568. */
  108569. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108570. /**
  108571. * Removes the physics body from the imposter and disposes of the body's memory
  108572. * @param impostor imposter to remove the physics body from
  108573. */
  108574. removePhysicsBody(impostor: PhysicsImpostor): void;
  108575. /**
  108576. * Generates a joint
  108577. * @param impostorJoint the imposter joint to create the joint with
  108578. */
  108579. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108580. /**
  108581. * Removes a joint
  108582. * @param impostorJoint the imposter joint to remove the joint from
  108583. */
  108584. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108585. private _addMeshVerts;
  108586. /**
  108587. * Initialise the soft body vertices to match its object's (mesh) vertices
  108588. * Softbody vertices (nodes) are in world space and to match this
  108589. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108590. * @param impostor to create the softbody for
  108591. */
  108592. private _softVertexData;
  108593. /**
  108594. * Create an impostor's soft body
  108595. * @param impostor to create the softbody for
  108596. */
  108597. private _createSoftbody;
  108598. /**
  108599. * Create cloth for an impostor
  108600. * @param impostor to create the softbody for
  108601. */
  108602. private _createCloth;
  108603. /**
  108604. * Create rope for an impostor
  108605. * @param impostor to create the softbody for
  108606. */
  108607. private _createRope;
  108608. private _addHullVerts;
  108609. private _createShape;
  108610. /**
  108611. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108612. * @param impostor imposter containing the physics body and babylon object
  108613. */
  108614. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108615. /**
  108616. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108617. * @param impostor imposter containing the physics body and babylon object
  108618. * @param newPosition new position
  108619. * @param newRotation new rotation
  108620. */
  108621. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108622. /**
  108623. * If this plugin is supported
  108624. * @returns true if its supported
  108625. */
  108626. isSupported(): boolean;
  108627. /**
  108628. * Sets the linear velocity of the physics body
  108629. * @param impostor imposter to set the velocity on
  108630. * @param velocity velocity to set
  108631. */
  108632. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108633. /**
  108634. * Sets the angular velocity of the physics body
  108635. * @param impostor imposter to set the velocity on
  108636. * @param velocity velocity to set
  108637. */
  108638. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108639. /**
  108640. * gets the linear velocity
  108641. * @param impostor imposter to get linear velocity from
  108642. * @returns linear velocity
  108643. */
  108644. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108645. /**
  108646. * gets the angular velocity
  108647. * @param impostor imposter to get angular velocity from
  108648. * @returns angular velocity
  108649. */
  108650. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108651. /**
  108652. * Sets the mass of physics body
  108653. * @param impostor imposter to set the mass on
  108654. * @param mass mass to set
  108655. */
  108656. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108657. /**
  108658. * Gets the mass of the physics body
  108659. * @param impostor imposter to get the mass from
  108660. * @returns mass
  108661. */
  108662. getBodyMass(impostor: PhysicsImpostor): number;
  108663. /**
  108664. * Gets friction of the impostor
  108665. * @param impostor impostor to get friction from
  108666. * @returns friction value
  108667. */
  108668. getBodyFriction(impostor: PhysicsImpostor): number;
  108669. /**
  108670. * Sets friction of the impostor
  108671. * @param impostor impostor to set friction on
  108672. * @param friction friction value
  108673. */
  108674. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108675. /**
  108676. * Gets restitution of the impostor
  108677. * @param impostor impostor to get restitution from
  108678. * @returns restitution value
  108679. */
  108680. getBodyRestitution(impostor: PhysicsImpostor): number;
  108681. /**
  108682. * Sets resitution of the impostor
  108683. * @param impostor impostor to set resitution on
  108684. * @param restitution resitution value
  108685. */
  108686. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108687. /**
  108688. * Gets pressure inside the impostor
  108689. * @param impostor impostor to get pressure from
  108690. * @returns pressure value
  108691. */
  108692. getBodyPressure(impostor: PhysicsImpostor): number;
  108693. /**
  108694. * Sets pressure inside a soft body impostor
  108695. * Cloth and rope must remain 0 pressure
  108696. * @param impostor impostor to set pressure on
  108697. * @param pressure pressure value
  108698. */
  108699. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108700. /**
  108701. * Gets stiffness of the impostor
  108702. * @param impostor impostor to get stiffness from
  108703. * @returns pressure value
  108704. */
  108705. getBodyStiffness(impostor: PhysicsImpostor): number;
  108706. /**
  108707. * Sets stiffness of the impostor
  108708. * @param impostor impostor to set stiffness on
  108709. * @param stiffness stiffness value from 0 to 1
  108710. */
  108711. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108712. /**
  108713. * Gets velocityIterations of the impostor
  108714. * @param impostor impostor to get velocity iterations from
  108715. * @returns velocityIterations value
  108716. */
  108717. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108718. /**
  108719. * Sets velocityIterations of the impostor
  108720. * @param impostor impostor to set velocity iterations on
  108721. * @param velocityIterations velocityIterations value
  108722. */
  108723. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108724. /**
  108725. * Gets positionIterations of the impostor
  108726. * @param impostor impostor to get position iterations from
  108727. * @returns positionIterations value
  108728. */
  108729. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108730. /**
  108731. * Sets positionIterations of the impostor
  108732. * @param impostor impostor to set position on
  108733. * @param positionIterations positionIterations value
  108734. */
  108735. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108736. /**
  108737. * Append an anchor to a cloth object
  108738. * @param impostor is the cloth impostor to add anchor to
  108739. * @param otherImpostor is the rigid impostor to anchor to
  108740. * @param width ratio across width from 0 to 1
  108741. * @param height ratio up height from 0 to 1
  108742. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108743. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108744. */
  108745. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108746. /**
  108747. * Append an hook to a rope object
  108748. * @param impostor is the rope impostor to add hook to
  108749. * @param otherImpostor is the rigid impostor to hook to
  108750. * @param length ratio along the rope from 0 to 1
  108751. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108752. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108753. */
  108754. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108755. /**
  108756. * Sleeps the physics body and stops it from being active
  108757. * @param impostor impostor to sleep
  108758. */
  108759. sleepBody(impostor: PhysicsImpostor): void;
  108760. /**
  108761. * Activates the physics body
  108762. * @param impostor impostor to activate
  108763. */
  108764. wakeUpBody(impostor: PhysicsImpostor): void;
  108765. /**
  108766. * Updates the distance parameters of the joint
  108767. * @param joint joint to update
  108768. * @param maxDistance maximum distance of the joint
  108769. * @param minDistance minimum distance of the joint
  108770. */
  108771. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108772. /**
  108773. * Sets a motor on the joint
  108774. * @param joint joint to set motor on
  108775. * @param speed speed of the motor
  108776. * @param maxForce maximum force of the motor
  108777. * @param motorIndex index of the motor
  108778. */
  108779. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108780. /**
  108781. * Sets the motors limit
  108782. * @param joint joint to set limit on
  108783. * @param upperLimit upper limit
  108784. * @param lowerLimit lower limit
  108785. */
  108786. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108787. /**
  108788. * Syncs the position and rotation of a mesh with the impostor
  108789. * @param mesh mesh to sync
  108790. * @param impostor impostor to update the mesh with
  108791. */
  108792. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108793. /**
  108794. * Gets the radius of the impostor
  108795. * @param impostor impostor to get radius from
  108796. * @returns the radius
  108797. */
  108798. getRadius(impostor: PhysicsImpostor): number;
  108799. /**
  108800. * Gets the box size of the impostor
  108801. * @param impostor impostor to get box size from
  108802. * @param result the resulting box size
  108803. */
  108804. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108805. /**
  108806. * Disposes of the impostor
  108807. */
  108808. dispose(): void;
  108809. /**
  108810. * Does a raycast in the physics world
  108811. * @param from when should the ray start?
  108812. * @param to when should the ray end?
  108813. * @returns PhysicsRaycastResult
  108814. */
  108815. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108816. }
  108817. }
  108818. declare module BABYLON {
  108819. interface AbstractScene {
  108820. /**
  108821. * The list of reflection probes added to the scene
  108822. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108823. */
  108824. reflectionProbes: Array<ReflectionProbe>;
  108825. /**
  108826. * Removes the given reflection probe from this scene.
  108827. * @param toRemove The reflection probe to remove
  108828. * @returns The index of the removed reflection probe
  108829. */
  108830. removeReflectionProbe(toRemove: ReflectionProbe): number;
  108831. /**
  108832. * Adds the given reflection probe to this scene.
  108833. * @param newReflectionProbe The reflection probe to add
  108834. */
  108835. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  108836. }
  108837. /**
  108838. * Class used to generate realtime reflection / refraction cube textures
  108839. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108840. */
  108841. export class ReflectionProbe {
  108842. /** defines the name of the probe */
  108843. name: string;
  108844. private _scene;
  108845. private _renderTargetTexture;
  108846. private _projectionMatrix;
  108847. private _viewMatrix;
  108848. private _target;
  108849. private _add;
  108850. private _attachedMesh;
  108851. private _invertYAxis;
  108852. /** Gets or sets probe position (center of the cube map) */
  108853. position: Vector3;
  108854. /**
  108855. * Creates a new reflection probe
  108856. * @param name defines the name of the probe
  108857. * @param size defines the texture resolution (for each face)
  108858. * @param scene defines the hosting scene
  108859. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  108860. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  108861. */
  108862. constructor(
  108863. /** defines the name of the probe */
  108864. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  108865. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  108866. samples: number;
  108867. /** Gets or sets the refresh rate to use (on every frame by default) */
  108868. refreshRate: number;
  108869. /**
  108870. * Gets the hosting scene
  108871. * @returns a Scene
  108872. */
  108873. getScene(): Scene;
  108874. /** Gets the internal CubeTexture used to render to */
  108875. readonly cubeTexture: RenderTargetTexture;
  108876. /** Gets the list of meshes to render */
  108877. readonly renderList: Nullable<AbstractMesh[]>;
  108878. /**
  108879. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108880. * @param mesh defines the mesh to attach to
  108881. */
  108882. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108883. /**
  108884. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108885. * @param renderingGroupId The rendering group id corresponding to its index
  108886. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108887. */
  108888. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108889. /**
  108890. * Clean all associated resources
  108891. */
  108892. dispose(): void;
  108893. /**
  108894. * Converts the reflection probe information to a readable string for debug purpose.
  108895. * @param fullDetails Supports for multiple levels of logging within scene loading
  108896. * @returns the human readable reflection probe info
  108897. */
  108898. toString(fullDetails?: boolean): string;
  108899. /**
  108900. * Get the class name of the relfection probe.
  108901. * @returns "ReflectionProbe"
  108902. */
  108903. getClassName(): string;
  108904. /**
  108905. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108906. * @returns The JSON representation of the texture
  108907. */
  108908. serialize(): any;
  108909. /**
  108910. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108911. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108912. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108913. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108914. * @returns The parsed reflection probe if successful
  108915. */
  108916. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108917. }
  108918. }
  108919. declare module BABYLON {
  108920. /** @hidden */
  108921. export var _BabylonLoaderRegistered: boolean;
  108922. }
  108923. declare module BABYLON {
  108924. /**
  108925. * The Physically based simple base material of BJS.
  108926. *
  108927. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108928. * It is used as the base class for both the specGloss and metalRough conventions.
  108929. */
  108930. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108931. /**
  108932. * Number of Simultaneous lights allowed on the material.
  108933. */
  108934. maxSimultaneousLights: number;
  108935. /**
  108936. * If sets to true, disables all the lights affecting the material.
  108937. */
  108938. disableLighting: boolean;
  108939. /**
  108940. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108941. */
  108942. environmentTexture: BaseTexture;
  108943. /**
  108944. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108945. */
  108946. invertNormalMapX: boolean;
  108947. /**
  108948. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108949. */
  108950. invertNormalMapY: boolean;
  108951. /**
  108952. * Normal map used in the model.
  108953. */
  108954. normalTexture: BaseTexture;
  108955. /**
  108956. * Emissivie color used to self-illuminate the model.
  108957. */
  108958. emissiveColor: Color3;
  108959. /**
  108960. * Emissivie texture used to self-illuminate the model.
  108961. */
  108962. emissiveTexture: BaseTexture;
  108963. /**
  108964. * Occlusion Channel Strenght.
  108965. */
  108966. occlusionStrength: number;
  108967. /**
  108968. * Occlusion Texture of the material (adding extra occlusion effects).
  108969. */
  108970. occlusionTexture: BaseTexture;
  108971. /**
  108972. * Defines the alpha limits in alpha test mode.
  108973. */
  108974. alphaCutOff: number;
  108975. /**
  108976. * Gets the current double sided mode.
  108977. */
  108978. /**
  108979. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108980. */
  108981. doubleSided: boolean;
  108982. /**
  108983. * Stores the pre-calculated light information of a mesh in a texture.
  108984. */
  108985. lightmapTexture: BaseTexture;
  108986. /**
  108987. * If true, the light map contains occlusion information instead of lighting info.
  108988. */
  108989. useLightmapAsShadowmap: boolean;
  108990. /**
  108991. * Instantiates a new PBRMaterial instance.
  108992. *
  108993. * @param name The material name
  108994. * @param scene The scene the material will be use in.
  108995. */
  108996. constructor(name: string, scene: Scene);
  108997. getClassName(): string;
  108998. }
  108999. }
  109000. declare module BABYLON {
  109001. /**
  109002. * The PBR material of BJS following the metal roughness convention.
  109003. *
  109004. * This fits to the PBR convention in the GLTF definition:
  109005. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  109006. */
  109007. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  109008. /**
  109009. * The base color has two different interpretations depending on the value of metalness.
  109010. * When the material is a metal, the base color is the specific measured reflectance value
  109011. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  109012. * of the material.
  109013. */
  109014. baseColor: Color3;
  109015. /**
  109016. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  109017. * well as opacity information in the alpha channel.
  109018. */
  109019. baseTexture: BaseTexture;
  109020. /**
  109021. * Specifies the metallic scalar value of the material.
  109022. * Can also be used to scale the metalness values of the metallic texture.
  109023. */
  109024. metallic: number;
  109025. /**
  109026. * Specifies the roughness scalar value of the material.
  109027. * Can also be used to scale the roughness values of the metallic texture.
  109028. */
  109029. roughness: number;
  109030. /**
  109031. * Texture containing both the metallic value in the B channel and the
  109032. * roughness value in the G channel to keep better precision.
  109033. */
  109034. metallicRoughnessTexture: BaseTexture;
  109035. /**
  109036. * Instantiates a new PBRMetalRoughnessMaterial instance.
  109037. *
  109038. * @param name The material name
  109039. * @param scene The scene the material will be use in.
  109040. */
  109041. constructor(name: string, scene: Scene);
  109042. /**
  109043. * Return the currrent class name of the material.
  109044. */
  109045. getClassName(): string;
  109046. /**
  109047. * Makes a duplicate of the current material.
  109048. * @param name - name to use for the new material.
  109049. */
  109050. clone(name: string): PBRMetallicRoughnessMaterial;
  109051. /**
  109052. * Serialize the material to a parsable JSON object.
  109053. */
  109054. serialize(): any;
  109055. /**
  109056. * Parses a JSON object correponding to the serialize function.
  109057. */
  109058. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  109059. }
  109060. }
  109061. declare module BABYLON {
  109062. /**
  109063. * The PBR material of BJS following the specular glossiness convention.
  109064. *
  109065. * This fits to the PBR convention in the GLTF definition:
  109066. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  109067. */
  109068. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  109069. /**
  109070. * Specifies the diffuse color of the material.
  109071. */
  109072. diffuseColor: Color3;
  109073. /**
  109074. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  109075. * channel.
  109076. */
  109077. diffuseTexture: BaseTexture;
  109078. /**
  109079. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  109080. */
  109081. specularColor: Color3;
  109082. /**
  109083. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  109084. */
  109085. glossiness: number;
  109086. /**
  109087. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  109088. */
  109089. specularGlossinessTexture: BaseTexture;
  109090. /**
  109091. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  109092. *
  109093. * @param name The material name
  109094. * @param scene The scene the material will be use in.
  109095. */
  109096. constructor(name: string, scene: Scene);
  109097. /**
  109098. * Return the currrent class name of the material.
  109099. */
  109100. getClassName(): string;
  109101. /**
  109102. * Makes a duplicate of the current material.
  109103. * @param name - name to use for the new material.
  109104. */
  109105. clone(name: string): PBRSpecularGlossinessMaterial;
  109106. /**
  109107. * Serialize the material to a parsable JSON object.
  109108. */
  109109. serialize(): any;
  109110. /**
  109111. * Parses a JSON object correponding to the serialize function.
  109112. */
  109113. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  109114. }
  109115. }
  109116. declare module BABYLON {
  109117. /**
  109118. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  109119. * It can help converting any input color in a desired output one. This can then be used to create effects
  109120. * from sepia, black and white to sixties or futuristic rendering...
  109121. *
  109122. * The only supported format is currently 3dl.
  109123. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  109124. */
  109125. export class ColorGradingTexture extends BaseTexture {
  109126. /**
  109127. * The current texture matrix. (will always be identity in color grading texture)
  109128. */
  109129. private _textureMatrix;
  109130. /**
  109131. * The texture URL.
  109132. */
  109133. url: string;
  109134. /**
  109135. * Empty line regex stored for GC.
  109136. */
  109137. private static _noneEmptyLineRegex;
  109138. private _engine;
  109139. /**
  109140. * Instantiates a ColorGradingTexture from the following parameters.
  109141. *
  109142. * @param url The location of the color gradind data (currently only supporting 3dl)
  109143. * @param scene The scene the texture will be used in
  109144. */
  109145. constructor(url: string, scene: Scene);
  109146. /**
  109147. * Returns the texture matrix used in most of the material.
  109148. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  109149. */
  109150. getTextureMatrix(): Matrix;
  109151. /**
  109152. * Occurs when the file being loaded is a .3dl LUT file.
  109153. */
  109154. private load3dlTexture;
  109155. /**
  109156. * Starts the loading process of the texture.
  109157. */
  109158. private loadTexture;
  109159. /**
  109160. * Clones the color gradind texture.
  109161. */
  109162. clone(): ColorGradingTexture;
  109163. /**
  109164. * Called during delayed load for textures.
  109165. */
  109166. delayLoad(): void;
  109167. /**
  109168. * Parses a color grading texture serialized by Babylon.
  109169. * @param parsedTexture The texture information being parsedTexture
  109170. * @param scene The scene to load the texture in
  109171. * @param rootUrl The root url of the data assets to load
  109172. * @return A color gradind texture
  109173. */
  109174. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  109175. /**
  109176. * Serializes the LUT texture to json format.
  109177. */
  109178. serialize(): any;
  109179. }
  109180. }
  109181. declare module BABYLON {
  109182. /**
  109183. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  109184. */
  109185. export class EquiRectangularCubeTexture extends BaseTexture {
  109186. /** The six faces of the cube. */
  109187. private static _FacesMapping;
  109188. private _noMipmap;
  109189. private _onLoad;
  109190. private _onError;
  109191. /** The size of the cubemap. */
  109192. private _size;
  109193. /** The buffer of the image. */
  109194. private _buffer;
  109195. /** The width of the input image. */
  109196. private _width;
  109197. /** The height of the input image. */
  109198. private _height;
  109199. /** The URL to the image. */
  109200. url: string;
  109201. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  109202. coordinatesMode: number;
  109203. /**
  109204. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  109205. * @param url The location of the image
  109206. * @param scene The scene the texture will be used in
  109207. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  109208. * @param noMipmap Forces to not generate the mipmap if true
  109209. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  109210. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  109211. * @param onLoad — defines a callback called when texture is loaded
  109212. * @param onError — defines a callback called if there is an error
  109213. */
  109214. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  109215. /**
  109216. * Load the image data, by putting the image on a canvas and extracting its buffer.
  109217. */
  109218. private loadImage;
  109219. /**
  109220. * Convert the image buffer into a cubemap and create a CubeTexture.
  109221. */
  109222. private loadTexture;
  109223. /**
  109224. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  109225. * @param buffer The ArrayBuffer that should be converted.
  109226. * @returns The buffer as Float32Array.
  109227. */
  109228. private getFloat32ArrayFromArrayBuffer;
  109229. /**
  109230. * Get the current class name of the texture useful for serialization or dynamic coding.
  109231. * @returns "EquiRectangularCubeTexture"
  109232. */
  109233. getClassName(): string;
  109234. /**
  109235. * Create a clone of the current EquiRectangularCubeTexture and return it.
  109236. * @returns A clone of the current EquiRectangularCubeTexture.
  109237. */
  109238. clone(): EquiRectangularCubeTexture;
  109239. }
  109240. }
  109241. declare module BABYLON {
  109242. /**
  109243. * Based on jsTGALoader - Javascript loader for TGA file
  109244. * By Vincent Thibault
  109245. * @see http://blog.robrowser.com/javascript-tga-loader.html
  109246. */
  109247. export class TGATools {
  109248. private static _TYPE_INDEXED;
  109249. private static _TYPE_RGB;
  109250. private static _TYPE_GREY;
  109251. private static _TYPE_RLE_INDEXED;
  109252. private static _TYPE_RLE_RGB;
  109253. private static _TYPE_RLE_GREY;
  109254. private static _ORIGIN_MASK;
  109255. private static _ORIGIN_SHIFT;
  109256. private static _ORIGIN_BL;
  109257. private static _ORIGIN_BR;
  109258. private static _ORIGIN_UL;
  109259. private static _ORIGIN_UR;
  109260. /**
  109261. * Gets the header of a TGA file
  109262. * @param data defines the TGA data
  109263. * @returns the header
  109264. */
  109265. static GetTGAHeader(data: Uint8Array): any;
  109266. /**
  109267. * Uploads TGA content to a Babylon Texture
  109268. * @hidden
  109269. */
  109270. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  109271. /** @hidden */
  109272. 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;
  109273. /** @hidden */
  109274. 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;
  109275. /** @hidden */
  109276. 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;
  109277. /** @hidden */
  109278. 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;
  109279. /** @hidden */
  109280. 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;
  109281. /** @hidden */
  109282. 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;
  109283. }
  109284. }
  109285. declare module BABYLON {
  109286. /**
  109287. * Implementation of the TGA Texture Loader.
  109288. * @hidden
  109289. */
  109290. export class _TGATextureLoader implements IInternalTextureLoader {
  109291. /**
  109292. * Defines wether the loader supports cascade loading the different faces.
  109293. */
  109294. readonly supportCascades: boolean;
  109295. /**
  109296. * This returns if the loader support the current file information.
  109297. * @param extension defines the file extension of the file being loaded
  109298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109299. * @param fallback defines the fallback internal texture if any
  109300. * @param isBase64 defines whether the texture is encoded as a base64
  109301. * @param isBuffer defines whether the texture data are stored as a buffer
  109302. * @returns true if the loader can load the specified file
  109303. */
  109304. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109305. /**
  109306. * Transform the url before loading if required.
  109307. * @param rootUrl the url of the texture
  109308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109309. * @returns the transformed texture
  109310. */
  109311. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109312. /**
  109313. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109314. * @param rootUrl the url of the texture
  109315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109316. * @returns the fallback texture
  109317. */
  109318. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109319. /**
  109320. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109321. * @param data contains the texture data
  109322. * @param texture defines the BabylonJS internal texture
  109323. * @param createPolynomials will be true if polynomials have been requested
  109324. * @param onLoad defines the callback to trigger once the texture is ready
  109325. * @param onError defines the callback to trigger in case of error
  109326. */
  109327. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109328. /**
  109329. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109330. * @param data contains the texture data
  109331. * @param texture defines the BabylonJS internal texture
  109332. * @param callback defines the method to call once ready to upload
  109333. */
  109334. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109335. }
  109336. }
  109337. declare module BABYLON {
  109338. /**
  109339. * 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.
  109340. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109341. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109342. */
  109343. export class CustomProceduralTexture extends ProceduralTexture {
  109344. private _animate;
  109345. private _time;
  109346. private _config;
  109347. private _texturePath;
  109348. /**
  109349. * Instantiates a new Custom Procedural Texture.
  109350. * 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.
  109351. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109352. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109353. * @param name Define the name of the texture
  109354. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  109355. * @param size Define the size of the texture to create
  109356. * @param scene Define the scene the texture belongs to
  109357. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  109358. * @param generateMipMaps Define if the texture should creates mip maps or not
  109359. */
  109360. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109361. private _loadJson;
  109362. /**
  109363. * Is the texture ready to be used ? (rendered at least once)
  109364. * @returns true if ready, otherwise, false.
  109365. */
  109366. isReady(): boolean;
  109367. /**
  109368. * Render the texture to its associated render target.
  109369. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  109370. */
  109371. render(useCameraPostProcess?: boolean): void;
  109372. /**
  109373. * Update the list of dependant textures samplers in the shader.
  109374. */
  109375. updateTextures(): void;
  109376. /**
  109377. * Update the uniform values of the procedural texture in the shader.
  109378. */
  109379. updateShaderUniforms(): void;
  109380. /**
  109381. * Define if the texture animates or not.
  109382. */
  109383. animate: boolean;
  109384. }
  109385. }
  109386. declare module BABYLON {
  109387. /** @hidden */
  109388. export var noisePixelShader: {
  109389. name: string;
  109390. shader: string;
  109391. };
  109392. }
  109393. declare module BABYLON {
  109394. /**
  109395. * Class used to generate noise procedural textures
  109396. */
  109397. export class NoiseProceduralTexture extends ProceduralTexture {
  109398. private _time;
  109399. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  109400. brightness: number;
  109401. /** Defines the number of octaves to process */
  109402. octaves: number;
  109403. /** Defines the level of persistence (0.8 by default) */
  109404. persistence: number;
  109405. /** Gets or sets animation speed factor (default is 1) */
  109406. animationSpeedFactor: number;
  109407. /**
  109408. * Creates a new NoiseProceduralTexture
  109409. * @param name defines the name fo the texture
  109410. * @param size defines the size of the texture (default is 256)
  109411. * @param scene defines the hosting scene
  109412. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  109413. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  109414. */
  109415. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109416. private _updateShaderUniforms;
  109417. protected _getDefines(): string;
  109418. /** Generate the current state of the procedural texture */
  109419. render(useCameraPostProcess?: boolean): void;
  109420. /**
  109421. * Serializes this noise procedural texture
  109422. * @returns a serialized noise procedural texture object
  109423. */
  109424. serialize(): any;
  109425. /**
  109426. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  109427. * @param parsedTexture defines parsed texture data
  109428. * @param scene defines the current scene
  109429. * @param rootUrl defines the root URL containing noise procedural texture information
  109430. * @returns a parsed NoiseProceduralTexture
  109431. */
  109432. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  109433. }
  109434. }
  109435. declare module BABYLON {
  109436. /**
  109437. * Raw cube texture where the raw buffers are passed in
  109438. */
  109439. export class RawCubeTexture extends CubeTexture {
  109440. /**
  109441. * Creates a cube texture where the raw buffers are passed in.
  109442. * @param scene defines the scene the texture is attached to
  109443. * @param data defines the array of data to use to create each face
  109444. * @param size defines the size of the textures
  109445. * @param format defines the format of the data
  109446. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  109447. * @param generateMipMaps defines if the engine should generate the mip levels
  109448. * @param invertY defines if data must be stored with Y axis inverted
  109449. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  109450. * @param compression defines the compression used (null by default)
  109451. */
  109452. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  109453. /**
  109454. * Updates the raw cube texture.
  109455. * @param data defines the data to store
  109456. * @param format defines the data format
  109457. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109458. * @param invertY defines if data must be stored with Y axis inverted
  109459. * @param compression defines the compression used (null by default)
  109460. * @param level defines which level of the texture to update
  109461. */
  109462. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  109463. /**
  109464. * Updates a raw cube texture with RGBD encoded data.
  109465. * @param data defines the array of data [mipmap][face] to use to create each face
  109466. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  109467. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109468. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109469. * @returns a promsie that resolves when the operation is complete
  109470. */
  109471. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  109472. /**
  109473. * Clones the raw cube texture.
  109474. * @return a new cube texture
  109475. */
  109476. clone(): CubeTexture;
  109477. /** @hidden */
  109478. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109479. }
  109480. }
  109481. declare module BABYLON {
  109482. /**
  109483. * Class used to store 3D textures containing user data
  109484. */
  109485. export class RawTexture3D extends Texture {
  109486. /** Gets or sets the texture format to use */
  109487. format: number;
  109488. private _engine;
  109489. /**
  109490. * Create a new RawTexture3D
  109491. * @param data defines the data of the texture
  109492. * @param width defines the width of the texture
  109493. * @param height defines the height of the texture
  109494. * @param depth defines the depth of the texture
  109495. * @param format defines the texture format to use
  109496. * @param scene defines the hosting scene
  109497. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  109498. * @param invertY defines if texture must be stored with Y axis inverted
  109499. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109500. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  109501. */
  109502. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  109503. /** Gets or sets the texture format to use */
  109504. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  109505. /**
  109506. * Update the texture with new data
  109507. * @param data defines the data to store in the texture
  109508. */
  109509. update(data: ArrayBufferView): void;
  109510. }
  109511. }
  109512. declare module BABYLON {
  109513. /**
  109514. * Creates a refraction texture used by refraction channel of the standard material.
  109515. * It is like a mirror but to see through a material.
  109516. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109517. */
  109518. export class RefractionTexture extends RenderTargetTexture {
  109519. /**
  109520. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  109521. * 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.
  109522. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109523. */
  109524. refractionPlane: Plane;
  109525. /**
  109526. * Define how deep under the surface we should see.
  109527. */
  109528. depth: number;
  109529. /**
  109530. * Creates a refraction texture used by refraction channel of the standard material.
  109531. * It is like a mirror but to see through a material.
  109532. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109533. * @param name Define the texture name
  109534. * @param size Define the size of the underlying texture
  109535. * @param scene Define the scene the refraction belongs to
  109536. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109537. */
  109538. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109539. /**
  109540. * Clone the refraction texture.
  109541. * @returns the cloned texture
  109542. */
  109543. clone(): RefractionTexture;
  109544. /**
  109545. * Serialize the texture to a JSON representation you could use in Parse later on
  109546. * @returns the serialized JSON representation
  109547. */
  109548. serialize(): any;
  109549. }
  109550. }
  109551. declare module BABYLON {
  109552. /**
  109553. * Defines the options related to the creation of an HtmlElementTexture
  109554. */
  109555. export interface IHtmlElementTextureOptions {
  109556. /**
  109557. * Defines wether mip maps should be created or not.
  109558. */
  109559. generateMipMaps?: boolean;
  109560. /**
  109561. * Defines the sampling mode of the texture.
  109562. */
  109563. samplingMode?: number;
  109564. /**
  109565. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109566. */
  109567. engine: Nullable<Engine>;
  109568. /**
  109569. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109570. */
  109571. scene: Nullable<Scene>;
  109572. }
  109573. /**
  109574. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109575. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109576. * is automatically managed.
  109577. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109578. * in your application.
  109579. *
  109580. * As the update is not automatic, you need to call them manually.
  109581. */
  109582. export class HtmlElementTexture extends BaseTexture {
  109583. /**
  109584. * The texture URL.
  109585. */
  109586. element: HTMLVideoElement | HTMLCanvasElement;
  109587. private static readonly DefaultOptions;
  109588. private _textureMatrix;
  109589. private _engine;
  109590. private _isVideo;
  109591. private _generateMipMaps;
  109592. private _samplingMode;
  109593. /**
  109594. * Instantiates a HtmlElementTexture from the following parameters.
  109595. *
  109596. * @param name Defines the name of the texture
  109597. * @param element Defines the video or canvas the texture is filled with
  109598. * @param options Defines the other none mandatory texture creation options
  109599. */
  109600. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109601. private _createInternalTexture;
  109602. /**
  109603. * Returns the texture matrix used in most of the material.
  109604. */
  109605. getTextureMatrix(): Matrix;
  109606. /**
  109607. * Updates the content of the texture.
  109608. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109609. */
  109610. update(invertY?: Nullable<boolean>): void;
  109611. }
  109612. }
  109613. declare module BABYLON {
  109614. /**
  109615. * Helper class to push actions to a pool of workers.
  109616. */
  109617. export class WorkerPool implements IDisposable {
  109618. private _workerInfos;
  109619. private _pendingActions;
  109620. /**
  109621. * Constructor
  109622. * @param workers Array of workers to use for actions
  109623. */
  109624. constructor(workers: Array<Worker>);
  109625. /**
  109626. * Terminates all workers and clears any pending actions.
  109627. */
  109628. dispose(): void;
  109629. /**
  109630. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109631. * pended until a worker has completed its action.
  109632. * @param action The action to perform. Call onComplete when the action is complete.
  109633. */
  109634. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109635. private _execute;
  109636. }
  109637. }
  109638. declare module BABYLON {
  109639. /**
  109640. * Configuration for Draco compression
  109641. */
  109642. export interface IDracoCompressionConfiguration {
  109643. /**
  109644. * Configuration for the decoder.
  109645. */
  109646. decoder: {
  109647. /**
  109648. * The url to the WebAssembly module.
  109649. */
  109650. wasmUrl?: string;
  109651. /**
  109652. * The url to the WebAssembly binary.
  109653. */
  109654. wasmBinaryUrl?: string;
  109655. /**
  109656. * The url to the fallback JavaScript module.
  109657. */
  109658. fallbackUrl?: string;
  109659. };
  109660. }
  109661. /**
  109662. * Draco compression (https://google.github.io/draco/)
  109663. *
  109664. * This class wraps the Draco module.
  109665. *
  109666. * **Encoder**
  109667. *
  109668. * The encoder is not currently implemented.
  109669. *
  109670. * **Decoder**
  109671. *
  109672. * 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.
  109673. *
  109674. * To update the configuration, use the following code:
  109675. * ```javascript
  109676. * DracoCompression.Configuration = {
  109677. * decoder: {
  109678. * wasmUrl: "<url to the WebAssembly library>",
  109679. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109680. * fallbackUrl: "<url to the fallback JavaScript library>",
  109681. * }
  109682. * };
  109683. * ```
  109684. *
  109685. * 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.
  109686. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109687. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  109688. *
  109689. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  109690. * ```javascript
  109691. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  109692. * ```
  109693. *
  109694. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109695. */
  109696. export class DracoCompression implements IDisposable {
  109697. private _workerPoolPromise?;
  109698. private _decoderModulePromise?;
  109699. /**
  109700. * The configuration. Defaults to the following urls:
  109701. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109702. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109703. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109704. */
  109705. static Configuration: IDracoCompressionConfiguration;
  109706. /**
  109707. * Returns true if the decoder configuration is available.
  109708. */
  109709. static readonly DecoderAvailable: boolean;
  109710. /**
  109711. * Default number of workers to create when creating the draco compression object.
  109712. */
  109713. static DefaultNumWorkers: number;
  109714. private static GetDefaultNumWorkers;
  109715. private static _Default;
  109716. /**
  109717. * Default instance for the draco compression object.
  109718. */
  109719. static readonly Default: DracoCompression;
  109720. /**
  109721. * Constructor
  109722. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  109723. */
  109724. constructor(numWorkers?: number);
  109725. /**
  109726. * Stop all async operations and release resources.
  109727. */
  109728. dispose(): void;
  109729. /**
  109730. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109731. * @returns a promise that resolves when ready
  109732. */
  109733. whenReadyAsync(): Promise<void>;
  109734. /**
  109735. * Decode Draco compressed mesh data to vertex data.
  109736. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109737. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109738. * @returns A promise that resolves with the decoded vertex data
  109739. */
  109740. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109741. [kind: string]: number;
  109742. }): Promise<VertexData>;
  109743. }
  109744. }
  109745. declare module BABYLON {
  109746. /**
  109747. * Class for building Constructive Solid Geometry
  109748. */
  109749. export class CSG {
  109750. private polygons;
  109751. /**
  109752. * The world matrix
  109753. */
  109754. matrix: Matrix;
  109755. /**
  109756. * Stores the position
  109757. */
  109758. position: Vector3;
  109759. /**
  109760. * Stores the rotation
  109761. */
  109762. rotation: Vector3;
  109763. /**
  109764. * Stores the rotation quaternion
  109765. */
  109766. rotationQuaternion: Nullable<Quaternion>;
  109767. /**
  109768. * Stores the scaling vector
  109769. */
  109770. scaling: Vector3;
  109771. /**
  109772. * Convert the Mesh to CSG
  109773. * @param mesh The Mesh to convert to CSG
  109774. * @returns A new CSG from the Mesh
  109775. */
  109776. static FromMesh(mesh: Mesh): CSG;
  109777. /**
  109778. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109779. * @param polygons Polygons used to construct a CSG solid
  109780. */
  109781. private static FromPolygons;
  109782. /**
  109783. * Clones, or makes a deep copy, of the CSG
  109784. * @returns A new CSG
  109785. */
  109786. clone(): CSG;
  109787. /**
  109788. * Unions this CSG with another CSG
  109789. * @param csg The CSG to union against this CSG
  109790. * @returns The unioned CSG
  109791. */
  109792. union(csg: CSG): CSG;
  109793. /**
  109794. * Unions this CSG with another CSG in place
  109795. * @param csg The CSG to union against this CSG
  109796. */
  109797. unionInPlace(csg: CSG): void;
  109798. /**
  109799. * Subtracts this CSG with another CSG
  109800. * @param csg The CSG to subtract against this CSG
  109801. * @returns A new CSG
  109802. */
  109803. subtract(csg: CSG): CSG;
  109804. /**
  109805. * Subtracts this CSG with another CSG in place
  109806. * @param csg The CSG to subtact against this CSG
  109807. */
  109808. subtractInPlace(csg: CSG): void;
  109809. /**
  109810. * Intersect this CSG with another CSG
  109811. * @param csg The CSG to intersect against this CSG
  109812. * @returns A new CSG
  109813. */
  109814. intersect(csg: CSG): CSG;
  109815. /**
  109816. * Intersects this CSG with another CSG in place
  109817. * @param csg The CSG to intersect against this CSG
  109818. */
  109819. intersectInPlace(csg: CSG): void;
  109820. /**
  109821. * Return a new CSG solid with solid and empty space switched. This solid is
  109822. * not modified.
  109823. * @returns A new CSG solid with solid and empty space switched
  109824. */
  109825. inverse(): CSG;
  109826. /**
  109827. * Inverses the CSG in place
  109828. */
  109829. inverseInPlace(): void;
  109830. /**
  109831. * This is used to keep meshes transformations so they can be restored
  109832. * when we build back a Babylon Mesh
  109833. * NB : All CSG operations are performed in world coordinates
  109834. * @param csg The CSG to copy the transform attributes from
  109835. * @returns This CSG
  109836. */
  109837. copyTransformAttributes(csg: CSG): CSG;
  109838. /**
  109839. * Build Raw mesh from CSG
  109840. * Coordinates here are in world space
  109841. * @param name The name of the mesh geometry
  109842. * @param scene The Scene
  109843. * @param keepSubMeshes Specifies if the submeshes should be kept
  109844. * @returns A new Mesh
  109845. */
  109846. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  109847. /**
  109848. * Build Mesh from CSG taking material and transforms into account
  109849. * @param name The name of the Mesh
  109850. * @param material The material of the Mesh
  109851. * @param scene The Scene
  109852. * @param keepSubMeshes Specifies if submeshes should be kept
  109853. * @returns The new Mesh
  109854. */
  109855. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  109856. }
  109857. }
  109858. declare module BABYLON {
  109859. /**
  109860. * Class used to create a trail following a mesh
  109861. */
  109862. export class TrailMesh extends Mesh {
  109863. private _generator;
  109864. private _autoStart;
  109865. private _running;
  109866. private _diameter;
  109867. private _length;
  109868. private _sectionPolygonPointsCount;
  109869. private _sectionVectors;
  109870. private _sectionNormalVectors;
  109871. private _beforeRenderObserver;
  109872. /**
  109873. * @constructor
  109874. * @param name The value used by scene.getMeshByName() to do a lookup.
  109875. * @param generator The mesh to generate a trail.
  109876. * @param scene The scene to add this mesh to.
  109877. * @param diameter Diameter of trailing mesh. Default is 1.
  109878. * @param length Length of trailing mesh. Default is 60.
  109879. * @param autoStart Automatically start trailing mesh. Default true.
  109880. */
  109881. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  109882. /**
  109883. * "TrailMesh"
  109884. * @returns "TrailMesh"
  109885. */
  109886. getClassName(): string;
  109887. private _createMesh;
  109888. /**
  109889. * Start trailing mesh.
  109890. */
  109891. start(): void;
  109892. /**
  109893. * Stop trailing mesh.
  109894. */
  109895. stop(): void;
  109896. /**
  109897. * Update trailing mesh geometry.
  109898. */
  109899. update(): void;
  109900. /**
  109901. * Returns a new TrailMesh object.
  109902. * @param name is a string, the name given to the new mesh
  109903. * @param newGenerator use new generator object for cloned trail mesh
  109904. * @returns a new mesh
  109905. */
  109906. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  109907. /**
  109908. * Serializes this trail mesh
  109909. * @param serializationObject object to write serialization to
  109910. */
  109911. serialize(serializationObject: any): void;
  109912. /**
  109913. * Parses a serialized trail mesh
  109914. * @param parsedMesh the serialized mesh
  109915. * @param scene the scene to create the trail mesh in
  109916. * @returns the created trail mesh
  109917. */
  109918. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  109919. }
  109920. }
  109921. declare module BABYLON {
  109922. /**
  109923. * Class containing static functions to help procedurally build meshes
  109924. */
  109925. export class TorusKnotBuilder {
  109926. /**
  109927. * Creates a torus knot mesh
  109928. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109929. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109930. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109931. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109935. * @param name defines the name of the mesh
  109936. * @param options defines the options used to create the mesh
  109937. * @param scene defines the hosting scene
  109938. * @returns the torus knot mesh
  109939. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109940. */
  109941. static CreateTorusKnot(name: string, options: {
  109942. radius?: number;
  109943. tube?: number;
  109944. radialSegments?: number;
  109945. tubularSegments?: number;
  109946. p?: number;
  109947. q?: number;
  109948. updatable?: boolean;
  109949. sideOrientation?: number;
  109950. frontUVs?: Vector4;
  109951. backUVs?: Vector4;
  109952. }, scene: any): Mesh;
  109953. }
  109954. }
  109955. declare module BABYLON {
  109956. /**
  109957. * Polygon
  109958. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109959. */
  109960. export class Polygon {
  109961. /**
  109962. * Creates a rectangle
  109963. * @param xmin bottom X coord
  109964. * @param ymin bottom Y coord
  109965. * @param xmax top X coord
  109966. * @param ymax top Y coord
  109967. * @returns points that make the resulting rectation
  109968. */
  109969. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109970. /**
  109971. * Creates a circle
  109972. * @param radius radius of circle
  109973. * @param cx scale in x
  109974. * @param cy scale in y
  109975. * @param numberOfSides number of sides that make up the circle
  109976. * @returns points that make the resulting circle
  109977. */
  109978. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109979. /**
  109980. * Creates a polygon from input string
  109981. * @param input Input polygon data
  109982. * @returns the parsed points
  109983. */
  109984. static Parse(input: string): Vector2[];
  109985. /**
  109986. * Starts building a polygon from x and y coordinates
  109987. * @param x x coordinate
  109988. * @param y y coordinate
  109989. * @returns the started path2
  109990. */
  109991. static StartingAt(x: number, y: number): Path2;
  109992. }
  109993. /**
  109994. * Builds a polygon
  109995. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  109996. */
  109997. export class PolygonMeshBuilder {
  109998. private _points;
  109999. private _outlinepoints;
  110000. private _holes;
  110001. private _name;
  110002. private _scene;
  110003. private _epoints;
  110004. private _eholes;
  110005. private _addToepoint;
  110006. /**
  110007. * Babylon reference to the earcut plugin.
  110008. */
  110009. bjsEarcut: any;
  110010. /**
  110011. * Creates a PolygonMeshBuilder
  110012. * @param name name of the builder
  110013. * @param contours Path of the polygon
  110014. * @param scene scene to add to when creating the mesh
  110015. * @param earcutInjection can be used to inject your own earcut reference
  110016. */
  110017. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  110018. /**
  110019. * Adds a whole within the polygon
  110020. * @param hole Array of points defining the hole
  110021. * @returns this
  110022. */
  110023. addHole(hole: Vector2[]): PolygonMeshBuilder;
  110024. /**
  110025. * Creates the polygon
  110026. * @param updatable If the mesh should be updatable
  110027. * @param depth The depth of the mesh created
  110028. * @returns the created mesh
  110029. */
  110030. build(updatable?: boolean, depth?: number): Mesh;
  110031. /**
  110032. * Creates the polygon
  110033. * @param depth The depth of the mesh created
  110034. * @returns the created VertexData
  110035. */
  110036. buildVertexData(depth?: number): VertexData;
  110037. /**
  110038. * Adds a side to the polygon
  110039. * @param positions points that make the polygon
  110040. * @param normals normals of the polygon
  110041. * @param uvs uvs of the polygon
  110042. * @param indices indices of the polygon
  110043. * @param bounds bounds of the polygon
  110044. * @param points points of the polygon
  110045. * @param depth depth of the polygon
  110046. * @param flip flip of the polygon
  110047. */
  110048. private addSide;
  110049. }
  110050. }
  110051. declare module BABYLON {
  110052. /**
  110053. * Class containing static functions to help procedurally build meshes
  110054. */
  110055. export class PolygonBuilder {
  110056. /**
  110057. * Creates a polygon mesh
  110058. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110059. * * 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
  110060. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110063. * * Remember you can only change the shape positions, not their number when updating a polygon
  110064. * @param name defines the name of the mesh
  110065. * @param options defines the options used to create the mesh
  110066. * @param scene defines the hosting scene
  110067. * @param earcutInjection can be used to inject your own earcut reference
  110068. * @returns the polygon mesh
  110069. */
  110070. static CreatePolygon(name: string, options: {
  110071. shape: Vector3[];
  110072. holes?: Vector3[][];
  110073. depth?: number;
  110074. faceUV?: Vector4[];
  110075. faceColors?: Color4[];
  110076. updatable?: boolean;
  110077. sideOrientation?: number;
  110078. frontUVs?: Vector4;
  110079. backUVs?: Vector4;
  110080. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110081. /**
  110082. * Creates an extruded polygon mesh, with depth in the Y direction.
  110083. * * 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)
  110084. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110085. * @param name defines the name of the mesh
  110086. * @param options defines the options used to create the mesh
  110087. * @param scene defines the hosting scene
  110088. * @param earcutInjection can be used to inject your own earcut reference
  110089. * @returns the polygon mesh
  110090. */
  110091. static ExtrudePolygon(name: string, options: {
  110092. shape: Vector3[];
  110093. holes?: Vector3[][];
  110094. depth?: number;
  110095. faceUV?: Vector4[];
  110096. faceColors?: Color4[];
  110097. updatable?: boolean;
  110098. sideOrientation?: number;
  110099. frontUVs?: Vector4;
  110100. backUVs?: Vector4;
  110101. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110102. }
  110103. }
  110104. declare module BABYLON {
  110105. /**
  110106. * Class containing static functions to help procedurally build meshes
  110107. */
  110108. export class LatheBuilder {
  110109. /**
  110110. * Creates lathe mesh.
  110111. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110112. * * 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
  110113. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110114. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110115. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110116. * * 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
  110117. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110118. * * 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
  110119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110121. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110123. * @param name defines the name of the mesh
  110124. * @param options defines the options used to create the mesh
  110125. * @param scene defines the hosting scene
  110126. * @returns the lathe mesh
  110127. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110128. */
  110129. static CreateLathe(name: string, options: {
  110130. shape: Vector3[];
  110131. radius?: number;
  110132. tessellation?: number;
  110133. clip?: number;
  110134. arc?: number;
  110135. closed?: boolean;
  110136. updatable?: boolean;
  110137. sideOrientation?: number;
  110138. frontUVs?: Vector4;
  110139. backUVs?: Vector4;
  110140. cap?: number;
  110141. invertUV?: boolean;
  110142. }, scene?: Nullable<Scene>): Mesh;
  110143. }
  110144. }
  110145. declare module BABYLON {
  110146. /**
  110147. * Class containing static functions to help procedurally build meshes
  110148. */
  110149. export class TubeBuilder {
  110150. /**
  110151. * Creates a tube mesh.
  110152. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110153. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110154. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110155. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110156. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110157. * * 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)
  110158. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110159. * * 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
  110160. * * 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
  110161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110163. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110165. * @param name defines the name of the mesh
  110166. * @param options defines the options used to create the mesh
  110167. * @param scene defines the hosting scene
  110168. * @returns the tube mesh
  110169. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110170. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110171. */
  110172. static CreateTube(name: string, options: {
  110173. path: Vector3[];
  110174. radius?: number;
  110175. tessellation?: number;
  110176. radiusFunction?: {
  110177. (i: number, distance: number): number;
  110178. };
  110179. cap?: number;
  110180. arc?: number;
  110181. updatable?: boolean;
  110182. sideOrientation?: number;
  110183. frontUVs?: Vector4;
  110184. backUVs?: Vector4;
  110185. instance?: Mesh;
  110186. invertUV?: boolean;
  110187. }, scene?: Nullable<Scene>): Mesh;
  110188. }
  110189. }
  110190. declare module BABYLON {
  110191. /**
  110192. * Class containing static functions to help procedurally build meshes
  110193. */
  110194. export class IcoSphereBuilder {
  110195. /**
  110196. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110197. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110198. * * 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`)
  110199. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110200. * * 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
  110201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110204. * @param name defines the name of the mesh
  110205. * @param options defines the options used to create the mesh
  110206. * @param scene defines the hosting scene
  110207. * @returns the icosahedron mesh
  110208. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110209. */
  110210. static CreateIcoSphere(name: string, options: {
  110211. radius?: number;
  110212. radiusX?: number;
  110213. radiusY?: number;
  110214. radiusZ?: number;
  110215. flat?: boolean;
  110216. subdivisions?: number;
  110217. sideOrientation?: number;
  110218. frontUVs?: Vector4;
  110219. backUVs?: Vector4;
  110220. updatable?: boolean;
  110221. }, scene?: Nullable<Scene>): Mesh;
  110222. }
  110223. }
  110224. declare module BABYLON {
  110225. /**
  110226. * Class containing static functions to help procedurally build meshes
  110227. */
  110228. export class DecalBuilder {
  110229. /**
  110230. * Creates a decal mesh.
  110231. * 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
  110232. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110233. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110234. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110235. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110236. * @param name defines the name of the mesh
  110237. * @param sourceMesh defines the mesh where the decal must be applied
  110238. * @param options defines the options used to create the mesh
  110239. * @param scene defines the hosting scene
  110240. * @returns the decal mesh
  110241. * @see https://doc.babylonjs.com/how_to/decals
  110242. */
  110243. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110244. position?: Vector3;
  110245. normal?: Vector3;
  110246. size?: Vector3;
  110247. angle?: number;
  110248. }): Mesh;
  110249. }
  110250. }
  110251. declare module BABYLON {
  110252. /**
  110253. * Class containing static functions to help procedurally build meshes
  110254. */
  110255. export class MeshBuilder {
  110256. /**
  110257. * Creates a box mesh
  110258. * * The parameter `size` sets the size (float) of each box side (default 1)
  110259. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110260. * * 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)
  110261. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110265. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110266. * @param name defines the name of the mesh
  110267. * @param options defines the options used to create the mesh
  110268. * @param scene defines the hosting scene
  110269. * @returns the box mesh
  110270. */
  110271. static CreateBox(name: string, options: {
  110272. size?: number;
  110273. width?: number;
  110274. height?: number;
  110275. depth?: number;
  110276. faceUV?: Vector4[];
  110277. faceColors?: Color4[];
  110278. sideOrientation?: number;
  110279. frontUVs?: Vector4;
  110280. backUVs?: Vector4;
  110281. updatable?: boolean;
  110282. }, scene?: Nullable<Scene>): Mesh;
  110283. /**
  110284. * Creates a sphere mesh
  110285. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110286. * * 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`)
  110287. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110288. * * 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
  110289. * * 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)
  110290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110293. * @param name defines the name of the mesh
  110294. * @param options defines the options used to create the mesh
  110295. * @param scene defines the hosting scene
  110296. * @returns the sphere mesh
  110297. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110298. */
  110299. static CreateSphere(name: string, options: {
  110300. segments?: number;
  110301. diameter?: number;
  110302. diameterX?: number;
  110303. diameterY?: number;
  110304. diameterZ?: number;
  110305. arc?: number;
  110306. slice?: number;
  110307. sideOrientation?: number;
  110308. frontUVs?: Vector4;
  110309. backUVs?: Vector4;
  110310. updatable?: boolean;
  110311. }, scene?: Nullable<Scene>): Mesh;
  110312. /**
  110313. * Creates a plane polygonal mesh. By default, this is a disc
  110314. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110315. * * 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
  110316. * * 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
  110317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110320. * @param name defines the name of the mesh
  110321. * @param options defines the options used to create the mesh
  110322. * @param scene defines the hosting scene
  110323. * @returns the plane polygonal mesh
  110324. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110325. */
  110326. static CreateDisc(name: string, options: {
  110327. radius?: number;
  110328. tessellation?: number;
  110329. arc?: number;
  110330. updatable?: boolean;
  110331. sideOrientation?: number;
  110332. frontUVs?: Vector4;
  110333. backUVs?: Vector4;
  110334. }, scene?: Nullable<Scene>): Mesh;
  110335. /**
  110336. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110337. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110338. * * 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`)
  110339. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110340. * * 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
  110341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110344. * @param name defines the name of the mesh
  110345. * @param options defines the options used to create the mesh
  110346. * @param scene defines the hosting scene
  110347. * @returns the icosahedron mesh
  110348. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110349. */
  110350. static CreateIcoSphere(name: string, options: {
  110351. radius?: number;
  110352. radiusX?: number;
  110353. radiusY?: number;
  110354. radiusZ?: number;
  110355. flat?: boolean;
  110356. subdivisions?: number;
  110357. sideOrientation?: number;
  110358. frontUVs?: Vector4;
  110359. backUVs?: Vector4;
  110360. updatable?: boolean;
  110361. }, scene?: Nullable<Scene>): Mesh;
  110362. /**
  110363. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110364. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110365. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110366. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110367. * * 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
  110368. * * 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
  110369. * * 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
  110370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110372. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110373. * * 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
  110374. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110375. * * 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
  110376. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110378. * @param name defines the name of the mesh
  110379. * @param options defines the options used to create the mesh
  110380. * @param scene defines the hosting scene
  110381. * @returns the ribbon mesh
  110382. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110383. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110384. */
  110385. static CreateRibbon(name: string, options: {
  110386. pathArray: Vector3[][];
  110387. closeArray?: boolean;
  110388. closePath?: boolean;
  110389. offset?: number;
  110390. updatable?: boolean;
  110391. sideOrientation?: number;
  110392. frontUVs?: Vector4;
  110393. backUVs?: Vector4;
  110394. instance?: Mesh;
  110395. invertUV?: boolean;
  110396. uvs?: Vector2[];
  110397. colors?: Color4[];
  110398. }, scene?: Nullable<Scene>): Mesh;
  110399. /**
  110400. * Creates a cylinder or a cone mesh
  110401. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110402. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110403. * * 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.
  110404. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110405. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110406. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110407. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110408. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110409. * * 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).
  110410. * * 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
  110411. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110412. * * 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
  110413. * * 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.
  110414. * * If `enclose` is false, a ring surface is one element.
  110415. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110416. * * 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
  110417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110420. * @param name defines the name of the mesh
  110421. * @param options defines the options used to create the mesh
  110422. * @param scene defines the hosting scene
  110423. * @returns the cylinder mesh
  110424. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110425. */
  110426. static CreateCylinder(name: string, options: {
  110427. height?: number;
  110428. diameterTop?: number;
  110429. diameterBottom?: number;
  110430. diameter?: number;
  110431. tessellation?: number;
  110432. subdivisions?: number;
  110433. arc?: number;
  110434. faceColors?: Color4[];
  110435. faceUV?: Vector4[];
  110436. updatable?: boolean;
  110437. hasRings?: boolean;
  110438. enclose?: boolean;
  110439. sideOrientation?: number;
  110440. frontUVs?: Vector4;
  110441. backUVs?: Vector4;
  110442. }, scene?: Nullable<Scene>): Mesh;
  110443. /**
  110444. * Creates a torus mesh
  110445. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110446. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110447. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110451. * @param name defines the name of the mesh
  110452. * @param options defines the options used to create the mesh
  110453. * @param scene defines the hosting scene
  110454. * @returns the torus mesh
  110455. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110456. */
  110457. static CreateTorus(name: string, options: {
  110458. diameter?: number;
  110459. thickness?: number;
  110460. tessellation?: number;
  110461. updatable?: boolean;
  110462. sideOrientation?: number;
  110463. frontUVs?: Vector4;
  110464. backUVs?: Vector4;
  110465. }, scene?: Nullable<Scene>): Mesh;
  110466. /**
  110467. * Creates a torus knot mesh
  110468. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110469. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110470. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110471. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110475. * @param name defines the name of the mesh
  110476. * @param options defines the options used to create the mesh
  110477. * @param scene defines the hosting scene
  110478. * @returns the torus knot mesh
  110479. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110480. */
  110481. static CreateTorusKnot(name: string, options: {
  110482. radius?: number;
  110483. tube?: number;
  110484. radialSegments?: number;
  110485. tubularSegments?: number;
  110486. p?: number;
  110487. q?: number;
  110488. updatable?: boolean;
  110489. sideOrientation?: number;
  110490. frontUVs?: Vector4;
  110491. backUVs?: Vector4;
  110492. }, scene?: Nullable<Scene>): Mesh;
  110493. /**
  110494. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110495. * * 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
  110496. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110497. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110498. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110499. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110500. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110501. * * 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
  110502. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110505. * @param name defines the name of the new line system
  110506. * @param options defines the options used to create the line system
  110507. * @param scene defines the hosting scene
  110508. * @returns a new line system mesh
  110509. */
  110510. static CreateLineSystem(name: string, options: {
  110511. lines: Vector3[][];
  110512. updatable?: boolean;
  110513. instance?: Nullable<LinesMesh>;
  110514. colors?: Nullable<Color4[][]>;
  110515. useVertexAlpha?: boolean;
  110516. }, scene: Nullable<Scene>): LinesMesh;
  110517. /**
  110518. * Creates a line mesh
  110519. * 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
  110520. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110521. * * The parameter `points` is an array successive Vector3
  110522. * * 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
  110523. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110524. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110525. * * When updating an instance, remember that only point positions can change, not the number of points
  110526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110527. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110528. * @param name defines the name of the new line system
  110529. * @param options defines the options used to create the line system
  110530. * @param scene defines the hosting scene
  110531. * @returns a new line mesh
  110532. */
  110533. static CreateLines(name: string, options: {
  110534. points: Vector3[];
  110535. updatable?: boolean;
  110536. instance?: Nullable<LinesMesh>;
  110537. colors?: Color4[];
  110538. useVertexAlpha?: boolean;
  110539. }, scene?: Nullable<Scene>): LinesMesh;
  110540. /**
  110541. * Creates a dashed line mesh
  110542. * * 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
  110543. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110544. * * The parameter `points` is an array successive Vector3
  110545. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110546. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110547. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110548. * * 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
  110549. * * When updating an instance, remember that only point positions can change, not the number of points
  110550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110551. * @param name defines the name of the mesh
  110552. * @param options defines the options used to create the mesh
  110553. * @param scene defines the hosting scene
  110554. * @returns the dashed line mesh
  110555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110556. */
  110557. static CreateDashedLines(name: string, options: {
  110558. points: Vector3[];
  110559. dashSize?: number;
  110560. gapSize?: number;
  110561. dashNb?: number;
  110562. updatable?: boolean;
  110563. instance?: LinesMesh;
  110564. }, scene?: Nullable<Scene>): LinesMesh;
  110565. /**
  110566. * 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.
  110567. * * 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.
  110568. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110569. * * 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.
  110570. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110571. * * 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
  110572. * * 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
  110573. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110576. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110578. * @param name defines the name of the mesh
  110579. * @param options defines the options used to create the mesh
  110580. * @param scene defines the hosting scene
  110581. * @returns the extruded shape mesh
  110582. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110583. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110584. */
  110585. static ExtrudeShape(name: string, options: {
  110586. shape: Vector3[];
  110587. path: Vector3[];
  110588. scale?: number;
  110589. rotation?: number;
  110590. cap?: number;
  110591. updatable?: boolean;
  110592. sideOrientation?: number;
  110593. frontUVs?: Vector4;
  110594. backUVs?: Vector4;
  110595. instance?: Mesh;
  110596. invertUV?: boolean;
  110597. }, scene?: Nullable<Scene>): Mesh;
  110598. /**
  110599. * Creates an custom extruded shape mesh.
  110600. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110601. * * 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.
  110602. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110603. * * 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
  110604. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110605. * * 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
  110606. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110607. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110608. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110609. * * 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
  110610. * * 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
  110611. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110614. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110616. * @param name defines the name of the mesh
  110617. * @param options defines the options used to create the mesh
  110618. * @param scene defines the hosting scene
  110619. * @returns the custom extruded shape mesh
  110620. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110621. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110622. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110623. */
  110624. static ExtrudeShapeCustom(name: string, options: {
  110625. shape: Vector3[];
  110626. path: Vector3[];
  110627. scaleFunction?: any;
  110628. rotationFunction?: any;
  110629. ribbonCloseArray?: boolean;
  110630. ribbonClosePath?: boolean;
  110631. cap?: number;
  110632. updatable?: boolean;
  110633. sideOrientation?: number;
  110634. frontUVs?: Vector4;
  110635. backUVs?: Vector4;
  110636. instance?: Mesh;
  110637. invertUV?: boolean;
  110638. }, scene?: Nullable<Scene>): Mesh;
  110639. /**
  110640. * Creates lathe mesh.
  110641. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110642. * * 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
  110643. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110644. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110645. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110646. * * 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
  110647. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110648. * * 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
  110649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110651. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110653. * @param name defines the name of the mesh
  110654. * @param options defines the options used to create the mesh
  110655. * @param scene defines the hosting scene
  110656. * @returns the lathe mesh
  110657. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110658. */
  110659. static CreateLathe(name: string, options: {
  110660. shape: Vector3[];
  110661. radius?: number;
  110662. tessellation?: number;
  110663. clip?: number;
  110664. arc?: number;
  110665. closed?: boolean;
  110666. updatable?: boolean;
  110667. sideOrientation?: number;
  110668. frontUVs?: Vector4;
  110669. backUVs?: Vector4;
  110670. cap?: number;
  110671. invertUV?: boolean;
  110672. }, scene?: Nullable<Scene>): Mesh;
  110673. /**
  110674. * Creates a plane mesh
  110675. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110676. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110677. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110681. * @param name defines the name of the mesh
  110682. * @param options defines the options used to create the mesh
  110683. * @param scene defines the hosting scene
  110684. * @returns the plane mesh
  110685. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110686. */
  110687. static CreatePlane(name: string, options: {
  110688. size?: number;
  110689. width?: number;
  110690. height?: number;
  110691. sideOrientation?: number;
  110692. frontUVs?: Vector4;
  110693. backUVs?: Vector4;
  110694. updatable?: boolean;
  110695. sourcePlane?: Plane;
  110696. }, scene?: Nullable<Scene>): Mesh;
  110697. /**
  110698. * Creates a ground mesh
  110699. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110700. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110702. * @param name defines the name of the mesh
  110703. * @param options defines the options used to create the mesh
  110704. * @param scene defines the hosting scene
  110705. * @returns the ground mesh
  110706. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110707. */
  110708. static CreateGround(name: string, options: {
  110709. width?: number;
  110710. height?: number;
  110711. subdivisions?: number;
  110712. subdivisionsX?: number;
  110713. subdivisionsY?: number;
  110714. updatable?: boolean;
  110715. }, scene?: Nullable<Scene>): Mesh;
  110716. /**
  110717. * Creates a tiled ground mesh
  110718. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110719. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110720. * * 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
  110721. * * 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
  110722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110723. * @param name defines the name of the mesh
  110724. * @param options defines the options used to create the mesh
  110725. * @param scene defines the hosting scene
  110726. * @returns the tiled ground mesh
  110727. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110728. */
  110729. static CreateTiledGround(name: string, options: {
  110730. xmin: number;
  110731. zmin: number;
  110732. xmax: number;
  110733. zmax: number;
  110734. subdivisions?: {
  110735. w: number;
  110736. h: number;
  110737. };
  110738. precision?: {
  110739. w: number;
  110740. h: number;
  110741. };
  110742. updatable?: boolean;
  110743. }, scene?: Nullable<Scene>): Mesh;
  110744. /**
  110745. * Creates a ground mesh from a height map
  110746. * * The parameter `url` sets the URL of the height map image resource.
  110747. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110748. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110749. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110750. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110751. * * 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.
  110752. * * 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).
  110753. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110755. * @param name defines the name of the mesh
  110756. * @param url defines the url to the height map
  110757. * @param options defines the options used to create the mesh
  110758. * @param scene defines the hosting scene
  110759. * @returns the ground mesh
  110760. * @see https://doc.babylonjs.com/babylon101/height_map
  110761. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110762. */
  110763. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110764. width?: number;
  110765. height?: number;
  110766. subdivisions?: number;
  110767. minHeight?: number;
  110768. maxHeight?: number;
  110769. colorFilter?: Color3;
  110770. alphaFilter?: number;
  110771. updatable?: boolean;
  110772. onReady?: (mesh: GroundMesh) => void;
  110773. }, scene?: Nullable<Scene>): GroundMesh;
  110774. /**
  110775. * Creates a polygon mesh
  110776. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110777. * * 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
  110778. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110781. * * Remember you can only change the shape positions, not their number when updating a polygon
  110782. * @param name defines the name of the mesh
  110783. * @param options defines the options used to create the mesh
  110784. * @param scene defines the hosting scene
  110785. * @param earcutInjection can be used to inject your own earcut reference
  110786. * @returns the polygon mesh
  110787. */
  110788. static CreatePolygon(name: string, options: {
  110789. shape: Vector3[];
  110790. holes?: Vector3[][];
  110791. depth?: number;
  110792. faceUV?: Vector4[];
  110793. faceColors?: Color4[];
  110794. updatable?: boolean;
  110795. sideOrientation?: number;
  110796. frontUVs?: Vector4;
  110797. backUVs?: Vector4;
  110798. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110799. /**
  110800. * Creates an extruded polygon mesh, with depth in the Y direction.
  110801. * * 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)
  110802. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110803. * @param name defines the name of the mesh
  110804. * @param options defines the options used to create the mesh
  110805. * @param scene defines the hosting scene
  110806. * @param earcutInjection can be used to inject your own earcut reference
  110807. * @returns the polygon mesh
  110808. */
  110809. static ExtrudePolygon(name: string, options: {
  110810. shape: Vector3[];
  110811. holes?: Vector3[][];
  110812. depth?: number;
  110813. faceUV?: Vector4[];
  110814. faceColors?: Color4[];
  110815. updatable?: boolean;
  110816. sideOrientation?: number;
  110817. frontUVs?: Vector4;
  110818. backUVs?: Vector4;
  110819. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110820. /**
  110821. * Creates a tube mesh.
  110822. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110823. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110824. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110825. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110826. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110827. * * 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)
  110828. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110829. * * 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
  110830. * * 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
  110831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110832. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110833. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110835. * @param name defines the name of the mesh
  110836. * @param options defines the options used to create the mesh
  110837. * @param scene defines the hosting scene
  110838. * @returns the tube mesh
  110839. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110840. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110841. */
  110842. static CreateTube(name: string, options: {
  110843. path: Vector3[];
  110844. radius?: number;
  110845. tessellation?: number;
  110846. radiusFunction?: {
  110847. (i: number, distance: number): number;
  110848. };
  110849. cap?: number;
  110850. arc?: number;
  110851. updatable?: boolean;
  110852. sideOrientation?: number;
  110853. frontUVs?: Vector4;
  110854. backUVs?: Vector4;
  110855. instance?: Mesh;
  110856. invertUV?: boolean;
  110857. }, scene?: Nullable<Scene>): Mesh;
  110858. /**
  110859. * Creates a polyhedron mesh
  110860. * * 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
  110861. * * The parameter `size` (positive float, default 1) sets the polygon size
  110862. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110863. * * 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`
  110864. * * 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
  110865. * * 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)`)
  110866. * * 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
  110867. * * 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
  110868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110871. * @param name defines the name of the mesh
  110872. * @param options defines the options used to create the mesh
  110873. * @param scene defines the hosting scene
  110874. * @returns the polyhedron mesh
  110875. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110876. */
  110877. static CreatePolyhedron(name: string, options: {
  110878. type?: number;
  110879. size?: number;
  110880. sizeX?: number;
  110881. sizeY?: number;
  110882. sizeZ?: number;
  110883. custom?: any;
  110884. faceUV?: Vector4[];
  110885. faceColors?: Color4[];
  110886. flat?: boolean;
  110887. updatable?: boolean;
  110888. sideOrientation?: number;
  110889. frontUVs?: Vector4;
  110890. backUVs?: Vector4;
  110891. }, scene?: Nullable<Scene>): Mesh;
  110892. /**
  110893. * Creates a decal mesh.
  110894. * 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
  110895. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110896. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110897. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110898. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110899. * @param name defines the name of the mesh
  110900. * @param sourceMesh defines the mesh where the decal must be applied
  110901. * @param options defines the options used to create the mesh
  110902. * @param scene defines the hosting scene
  110903. * @returns the decal mesh
  110904. * @see https://doc.babylonjs.com/how_to/decals
  110905. */
  110906. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110907. position?: Vector3;
  110908. normal?: Vector3;
  110909. size?: Vector3;
  110910. angle?: number;
  110911. }): Mesh;
  110912. }
  110913. }
  110914. declare module BABYLON {
  110915. /**
  110916. * A simplifier interface for future simplification implementations
  110917. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110918. */
  110919. export interface ISimplifier {
  110920. /**
  110921. * Simplification of a given mesh according to the given settings.
  110922. * Since this requires computation, it is assumed that the function runs async.
  110923. * @param settings The settings of the simplification, including quality and distance
  110924. * @param successCallback A callback that will be called after the mesh was simplified.
  110925. * @param errorCallback in case of an error, this callback will be called. optional.
  110926. */
  110927. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  110928. }
  110929. /**
  110930. * Expected simplification settings.
  110931. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110932. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110933. */
  110934. export interface ISimplificationSettings {
  110935. /**
  110936. * Gets or sets the expected quality
  110937. */
  110938. quality: number;
  110939. /**
  110940. * Gets or sets the distance when this optimized version should be used
  110941. */
  110942. distance: number;
  110943. /**
  110944. * Gets an already optimized mesh
  110945. */
  110946. optimizeMesh?: boolean;
  110947. }
  110948. /**
  110949. * Class used to specify simplification options
  110950. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110951. */
  110952. export class SimplificationSettings implements ISimplificationSettings {
  110953. /** expected quality */
  110954. quality: number;
  110955. /** distance when this optimized version should be used */
  110956. distance: number;
  110957. /** already optimized mesh */
  110958. optimizeMesh?: boolean | undefined;
  110959. /**
  110960. * Creates a SimplificationSettings
  110961. * @param quality expected quality
  110962. * @param distance distance when this optimized version should be used
  110963. * @param optimizeMesh already optimized mesh
  110964. */
  110965. constructor(
  110966. /** expected quality */
  110967. quality: number,
  110968. /** distance when this optimized version should be used */
  110969. distance: number,
  110970. /** already optimized mesh */
  110971. optimizeMesh?: boolean | undefined);
  110972. }
  110973. /**
  110974. * Interface used to define a simplification task
  110975. */
  110976. export interface ISimplificationTask {
  110977. /**
  110978. * Array of settings
  110979. */
  110980. settings: Array<ISimplificationSettings>;
  110981. /**
  110982. * Simplification type
  110983. */
  110984. simplificationType: SimplificationType;
  110985. /**
  110986. * Mesh to simplify
  110987. */
  110988. mesh: Mesh;
  110989. /**
  110990. * Callback called on success
  110991. */
  110992. successCallback?: () => void;
  110993. /**
  110994. * Defines if parallel processing can be used
  110995. */
  110996. parallelProcessing: boolean;
  110997. }
  110998. /**
  110999. * Queue used to order the simplification tasks
  111000. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111001. */
  111002. export class SimplificationQueue {
  111003. private _simplificationArray;
  111004. /**
  111005. * Gets a boolean indicating that the process is still running
  111006. */
  111007. running: boolean;
  111008. /**
  111009. * Creates a new queue
  111010. */
  111011. constructor();
  111012. /**
  111013. * Adds a new simplification task
  111014. * @param task defines a task to add
  111015. */
  111016. addTask(task: ISimplificationTask): void;
  111017. /**
  111018. * Execute next task
  111019. */
  111020. executeNext(): void;
  111021. /**
  111022. * Execute a simplification task
  111023. * @param task defines the task to run
  111024. */
  111025. runSimplification(task: ISimplificationTask): void;
  111026. private getSimplifier;
  111027. }
  111028. /**
  111029. * The implemented types of simplification
  111030. * At the moment only Quadratic Error Decimation is implemented
  111031. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111032. */
  111033. export enum SimplificationType {
  111034. /** Quadratic error decimation */
  111035. QUADRATIC = 0
  111036. }
  111037. }
  111038. declare module BABYLON {
  111039. interface Scene {
  111040. /** @hidden (Backing field) */
  111041. _simplificationQueue: SimplificationQueue;
  111042. /**
  111043. * Gets or sets the simplification queue attached to the scene
  111044. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111045. */
  111046. simplificationQueue: SimplificationQueue;
  111047. }
  111048. interface Mesh {
  111049. /**
  111050. * Simplify the mesh according to the given array of settings.
  111051. * Function will return immediately and will simplify async
  111052. * @param settings a collection of simplification settings
  111053. * @param parallelProcessing should all levels calculate parallel or one after the other
  111054. * @param simplificationType the type of simplification to run
  111055. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  111056. * @returns the current mesh
  111057. */
  111058. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  111059. }
  111060. /**
  111061. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  111062. * created in a scene
  111063. */
  111064. export class SimplicationQueueSceneComponent implements ISceneComponent {
  111065. /**
  111066. * The component name helpfull to identify the component in the list of scene components.
  111067. */
  111068. readonly name: string;
  111069. /**
  111070. * The scene the component belongs to.
  111071. */
  111072. scene: Scene;
  111073. /**
  111074. * Creates a new instance of the component for the given scene
  111075. * @param scene Defines the scene to register the component in
  111076. */
  111077. constructor(scene: Scene);
  111078. /**
  111079. * Registers the component in a given scene
  111080. */
  111081. register(): void;
  111082. /**
  111083. * Rebuilds the elements related to this component in case of
  111084. * context lost for instance.
  111085. */
  111086. rebuild(): void;
  111087. /**
  111088. * Disposes the component and the associated ressources
  111089. */
  111090. dispose(): void;
  111091. private _beforeCameraUpdate;
  111092. }
  111093. }
  111094. declare module BABYLON {
  111095. /**
  111096. * Class used to enable access to IndexedDB
  111097. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  111098. */
  111099. export class Database implements IOfflineProvider {
  111100. private _callbackManifestChecked;
  111101. private _currentSceneUrl;
  111102. private _db;
  111103. private _enableSceneOffline;
  111104. private _enableTexturesOffline;
  111105. private _manifestVersionFound;
  111106. private _mustUpdateRessources;
  111107. private _hasReachedQuota;
  111108. private _isSupported;
  111109. private _idbFactory;
  111110. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  111111. private static IsUASupportingBlobStorage;
  111112. /**
  111113. * Gets a boolean indicating if Database storate is enabled (off by default)
  111114. */
  111115. static IDBStorageEnabled: boolean;
  111116. /**
  111117. * Gets a boolean indicating if scene must be saved in the database
  111118. */
  111119. readonly enableSceneOffline: boolean;
  111120. /**
  111121. * Gets a boolean indicating if textures must be saved in the database
  111122. */
  111123. readonly enableTexturesOffline: boolean;
  111124. /**
  111125. * Creates a new Database
  111126. * @param urlToScene defines the url to load the scene
  111127. * @param callbackManifestChecked defines the callback to use when manifest is checked
  111128. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  111129. */
  111130. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  111131. private static _ParseURL;
  111132. private static _ReturnFullUrlLocation;
  111133. private _checkManifestFile;
  111134. /**
  111135. * Open the database and make it available
  111136. * @param successCallback defines the callback to call on success
  111137. * @param errorCallback defines the callback to call on error
  111138. */
  111139. open(successCallback: () => void, errorCallback: () => void): void;
  111140. /**
  111141. * Loads an image from the database
  111142. * @param url defines the url to load from
  111143. * @param image defines the target DOM image
  111144. */
  111145. loadImage(url: string, image: HTMLImageElement): void;
  111146. private _loadImageFromDBAsync;
  111147. private _saveImageIntoDBAsync;
  111148. private _checkVersionFromDB;
  111149. private _loadVersionFromDBAsync;
  111150. private _saveVersionIntoDBAsync;
  111151. /**
  111152. * Loads a file from database
  111153. * @param url defines the URL to load from
  111154. * @param sceneLoaded defines a callback to call on success
  111155. * @param progressCallBack defines a callback to call when progress changed
  111156. * @param errorCallback defines a callback to call on error
  111157. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  111158. */
  111159. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  111160. private _loadFileAsync;
  111161. private _saveFileAsync;
  111162. /**
  111163. * Validates if xhr data is correct
  111164. * @param xhr defines the request to validate
  111165. * @param dataType defines the expected data type
  111166. * @returns true if data is correct
  111167. */
  111168. private static _ValidateXHRData;
  111169. }
  111170. }
  111171. declare module BABYLON {
  111172. /** @hidden */
  111173. export var gpuUpdateParticlesPixelShader: {
  111174. name: string;
  111175. shader: string;
  111176. };
  111177. }
  111178. declare module BABYLON {
  111179. /** @hidden */
  111180. export var gpuUpdateParticlesVertexShader: {
  111181. name: string;
  111182. shader: string;
  111183. };
  111184. }
  111185. declare module BABYLON {
  111186. /** @hidden */
  111187. export var clipPlaneFragmentDeclaration2: {
  111188. name: string;
  111189. shader: string;
  111190. };
  111191. }
  111192. declare module BABYLON {
  111193. /** @hidden */
  111194. export var gpuRenderParticlesPixelShader: {
  111195. name: string;
  111196. shader: string;
  111197. };
  111198. }
  111199. declare module BABYLON {
  111200. /** @hidden */
  111201. export var clipPlaneVertexDeclaration2: {
  111202. name: string;
  111203. shader: string;
  111204. };
  111205. }
  111206. declare module BABYLON {
  111207. /** @hidden */
  111208. export var gpuRenderParticlesVertexShader: {
  111209. name: string;
  111210. shader: string;
  111211. };
  111212. }
  111213. declare module BABYLON {
  111214. /**
  111215. * This represents a GPU particle system in Babylon
  111216. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  111217. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  111218. */
  111219. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  111220. /**
  111221. * The layer mask we are rendering the particles through.
  111222. */
  111223. layerMask: number;
  111224. private _capacity;
  111225. private _activeCount;
  111226. private _currentActiveCount;
  111227. private _accumulatedCount;
  111228. private _renderEffect;
  111229. private _updateEffect;
  111230. private _buffer0;
  111231. private _buffer1;
  111232. private _spriteBuffer;
  111233. private _updateVAO;
  111234. private _renderVAO;
  111235. private _targetIndex;
  111236. private _sourceBuffer;
  111237. private _targetBuffer;
  111238. private _engine;
  111239. private _currentRenderId;
  111240. private _started;
  111241. private _stopped;
  111242. private _timeDelta;
  111243. private _randomTexture;
  111244. private _randomTexture2;
  111245. private _attributesStrideSize;
  111246. private _updateEffectOptions;
  111247. private _randomTextureSize;
  111248. private _actualFrame;
  111249. private readonly _rawTextureWidth;
  111250. /**
  111251. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  111252. */
  111253. static readonly IsSupported: boolean;
  111254. /**
  111255. * An event triggered when the system is disposed.
  111256. */
  111257. onDisposeObservable: Observable<GPUParticleSystem>;
  111258. /**
  111259. * Gets the maximum number of particles active at the same time.
  111260. * @returns The max number of active particles.
  111261. */
  111262. getCapacity(): number;
  111263. /**
  111264. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  111265. * to override the particles.
  111266. */
  111267. forceDepthWrite: boolean;
  111268. /**
  111269. * Gets or set the number of active particles
  111270. */
  111271. activeParticleCount: number;
  111272. private _preWarmDone;
  111273. /**
  111274. * Is this system ready to be used/rendered
  111275. * @return true if the system is ready
  111276. */
  111277. isReady(): boolean;
  111278. /**
  111279. * Gets if the system has been started. (Note: this will still be true after stop is called)
  111280. * @returns True if it has been started, otherwise false.
  111281. */
  111282. isStarted(): boolean;
  111283. /**
  111284. * Starts the particle system and begins to emit
  111285. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  111286. */
  111287. start(delay?: number): void;
  111288. /**
  111289. * Stops the particle system.
  111290. */
  111291. stop(): void;
  111292. /**
  111293. * Remove all active particles
  111294. */
  111295. reset(): void;
  111296. /**
  111297. * Returns the string "GPUParticleSystem"
  111298. * @returns a string containing the class name
  111299. */
  111300. getClassName(): string;
  111301. private _colorGradientsTexture;
  111302. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  111303. /**
  111304. * Adds a new color gradient
  111305. * @param gradient defines the gradient to use (between 0 and 1)
  111306. * @param color1 defines the color to affect to the specified gradient
  111307. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  111308. * @returns the current particle system
  111309. */
  111310. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  111311. /**
  111312. * Remove a specific color gradient
  111313. * @param gradient defines the gradient to remove
  111314. * @returns the current particle system
  111315. */
  111316. removeColorGradient(gradient: number): GPUParticleSystem;
  111317. private _angularSpeedGradientsTexture;
  111318. private _sizeGradientsTexture;
  111319. private _velocityGradientsTexture;
  111320. private _limitVelocityGradientsTexture;
  111321. private _dragGradientsTexture;
  111322. private _addFactorGradient;
  111323. /**
  111324. * Adds a new size gradient
  111325. * @param gradient defines the gradient to use (between 0 and 1)
  111326. * @param factor defines the size factor to affect to the specified gradient
  111327. * @returns the current particle system
  111328. */
  111329. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  111330. /**
  111331. * Remove a specific size gradient
  111332. * @param gradient defines the gradient to remove
  111333. * @returns the current particle system
  111334. */
  111335. removeSizeGradient(gradient: number): GPUParticleSystem;
  111336. /**
  111337. * Adds a new angular speed gradient
  111338. * @param gradient defines the gradient to use (between 0 and 1)
  111339. * @param factor defines the angular speed to affect to the specified gradient
  111340. * @returns the current particle system
  111341. */
  111342. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  111343. /**
  111344. * Remove a specific angular speed gradient
  111345. * @param gradient defines the gradient to remove
  111346. * @returns the current particle system
  111347. */
  111348. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  111349. /**
  111350. * Adds a new velocity gradient
  111351. * @param gradient defines the gradient to use (between 0 and 1)
  111352. * @param factor defines the velocity to affect to the specified gradient
  111353. * @returns the current particle system
  111354. */
  111355. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111356. /**
  111357. * Remove a specific velocity gradient
  111358. * @param gradient defines the gradient to remove
  111359. * @returns the current particle system
  111360. */
  111361. removeVelocityGradient(gradient: number): GPUParticleSystem;
  111362. /**
  111363. * Adds a new limit velocity gradient
  111364. * @param gradient defines the gradient to use (between 0 and 1)
  111365. * @param factor defines the limit velocity value to affect to the specified gradient
  111366. * @returns the current particle system
  111367. */
  111368. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111369. /**
  111370. * Remove a specific limit velocity gradient
  111371. * @param gradient defines the gradient to remove
  111372. * @returns the current particle system
  111373. */
  111374. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  111375. /**
  111376. * Adds a new drag gradient
  111377. * @param gradient defines the gradient to use (between 0 and 1)
  111378. * @param factor defines the drag value to affect to the specified gradient
  111379. * @returns the current particle system
  111380. */
  111381. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  111382. /**
  111383. * Remove a specific drag gradient
  111384. * @param gradient defines the gradient to remove
  111385. * @returns the current particle system
  111386. */
  111387. removeDragGradient(gradient: number): GPUParticleSystem;
  111388. /**
  111389. * Not supported by GPUParticleSystem
  111390. * @param gradient defines the gradient to use (between 0 and 1)
  111391. * @param factor defines the emit rate value to affect to the specified gradient
  111392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111393. * @returns the current particle system
  111394. */
  111395. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111396. /**
  111397. * Not supported by GPUParticleSystem
  111398. * @param gradient defines the gradient to remove
  111399. * @returns the current particle system
  111400. */
  111401. removeEmitRateGradient(gradient: number): IParticleSystem;
  111402. /**
  111403. * Not supported by GPUParticleSystem
  111404. * @param gradient defines the gradient to use (between 0 and 1)
  111405. * @param factor defines the start size value to affect to the specified gradient
  111406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111407. * @returns the current particle system
  111408. */
  111409. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111410. /**
  111411. * Not supported by GPUParticleSystem
  111412. * @param gradient defines the gradient to remove
  111413. * @returns the current particle system
  111414. */
  111415. removeStartSizeGradient(gradient: number): IParticleSystem;
  111416. /**
  111417. * Not supported by GPUParticleSystem
  111418. * @param gradient defines the gradient to use (between 0 and 1)
  111419. * @param min defines the color remap minimal range
  111420. * @param max defines the color remap maximal range
  111421. * @returns the current particle system
  111422. */
  111423. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111424. /**
  111425. * Not supported by GPUParticleSystem
  111426. * @param gradient defines the gradient to remove
  111427. * @returns the current particle system
  111428. */
  111429. removeColorRemapGradient(): IParticleSystem;
  111430. /**
  111431. * Not supported by GPUParticleSystem
  111432. * @param gradient defines the gradient to use (between 0 and 1)
  111433. * @param min defines the alpha remap minimal range
  111434. * @param max defines the alpha remap maximal range
  111435. * @returns the current particle system
  111436. */
  111437. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111438. /**
  111439. * Not supported by GPUParticleSystem
  111440. * @param gradient defines the gradient to remove
  111441. * @returns the current particle system
  111442. */
  111443. removeAlphaRemapGradient(): IParticleSystem;
  111444. /**
  111445. * Not supported by GPUParticleSystem
  111446. * @param gradient defines the gradient to use (between 0 and 1)
  111447. * @param color defines the color to affect to the specified gradient
  111448. * @returns the current particle system
  111449. */
  111450. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  111451. /**
  111452. * Not supported by GPUParticleSystem
  111453. * @param gradient defines the gradient to remove
  111454. * @returns the current particle system
  111455. */
  111456. removeRampGradient(): IParticleSystem;
  111457. /**
  111458. * Not supported by GPUParticleSystem
  111459. * @returns the list of ramp gradients
  111460. */
  111461. getRampGradients(): Nullable<Array<Color3Gradient>>;
  111462. /**
  111463. * Not supported by GPUParticleSystem
  111464. * Gets or sets a boolean indicating that ramp gradients must be used
  111465. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  111466. */
  111467. useRampGradients: boolean;
  111468. /**
  111469. * Not supported by GPUParticleSystem
  111470. * @param gradient defines the gradient to use (between 0 and 1)
  111471. * @param factor defines the life time factor to affect to the specified gradient
  111472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111473. * @returns the current particle system
  111474. */
  111475. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111476. /**
  111477. * Not supported by GPUParticleSystem
  111478. * @param gradient defines the gradient to remove
  111479. * @returns the current particle system
  111480. */
  111481. removeLifeTimeGradient(gradient: number): IParticleSystem;
  111482. /**
  111483. * Instantiates a GPU particle system.
  111484. * 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.
  111485. * @param name The name of the particle system
  111486. * @param options The options used to create the system
  111487. * @param scene The scene the particle system belongs to
  111488. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  111489. */
  111490. constructor(name: string, options: Partial<{
  111491. capacity: number;
  111492. randomTextureSize: number;
  111493. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  111494. protected _reset(): void;
  111495. private _createUpdateVAO;
  111496. private _createRenderVAO;
  111497. private _initialize;
  111498. /** @hidden */
  111499. _recreateUpdateEffect(): void;
  111500. /** @hidden */
  111501. _recreateRenderEffect(): void;
  111502. /**
  111503. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111504. * @param preWarm defines if we are in the pre-warmimg phase
  111505. */
  111506. animate(preWarm?: boolean): void;
  111507. private _createFactorGradientTexture;
  111508. private _createSizeGradientTexture;
  111509. private _createAngularSpeedGradientTexture;
  111510. private _createVelocityGradientTexture;
  111511. private _createLimitVelocityGradientTexture;
  111512. private _createDragGradientTexture;
  111513. private _createColorGradientTexture;
  111514. /**
  111515. * Renders the particle system in its current state
  111516. * @param preWarm defines if the system should only update the particles but not render them
  111517. * @returns the current number of particles
  111518. */
  111519. render(preWarm?: boolean): number;
  111520. /**
  111521. * Rebuilds the particle system
  111522. */
  111523. rebuild(): void;
  111524. private _releaseBuffers;
  111525. private _releaseVAOs;
  111526. /**
  111527. * Disposes the particle system and free the associated resources
  111528. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111529. */
  111530. dispose(disposeTexture?: boolean): void;
  111531. /**
  111532. * Clones the particle system.
  111533. * @param name The name of the cloned object
  111534. * @param newEmitter The new emitter to use
  111535. * @returns the cloned particle system
  111536. */
  111537. clone(name: string, newEmitter: any): GPUParticleSystem;
  111538. /**
  111539. * Serializes the particle system to a JSON object.
  111540. * @returns the JSON object
  111541. */
  111542. serialize(): any;
  111543. /**
  111544. * Parses a JSON object to create a GPU particle system.
  111545. * @param parsedParticleSystem The JSON object to parse
  111546. * @param scene The scene to create the particle system in
  111547. * @param rootUrl The root url to use to load external dependencies like texture
  111548. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111549. * @returns the parsed GPU particle system
  111550. */
  111551. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111552. }
  111553. }
  111554. declare module BABYLON {
  111555. /**
  111556. * Represents a set of particle systems working together to create a specific effect
  111557. */
  111558. export class ParticleSystemSet implements IDisposable {
  111559. private _emitterCreationOptions;
  111560. private _emitterNode;
  111561. /**
  111562. * Gets the particle system list
  111563. */
  111564. systems: IParticleSystem[];
  111565. /**
  111566. * Gets the emitter node used with this set
  111567. */
  111568. readonly emitterNode: Nullable<TransformNode>;
  111569. /**
  111570. * Creates a new emitter mesh as a sphere
  111571. * @param options defines the options used to create the sphere
  111572. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111573. * @param scene defines the hosting scene
  111574. */
  111575. setEmitterAsSphere(options: {
  111576. diameter: number;
  111577. segments: number;
  111578. color: Color3;
  111579. }, renderingGroupId: number, scene: Scene): void;
  111580. /**
  111581. * Starts all particle systems of the set
  111582. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111583. */
  111584. start(emitter?: AbstractMesh): void;
  111585. /**
  111586. * Release all associated resources
  111587. */
  111588. dispose(): void;
  111589. /**
  111590. * Serialize the set into a JSON compatible object
  111591. * @returns a JSON compatible representation of the set
  111592. */
  111593. serialize(): any;
  111594. /**
  111595. * Parse a new ParticleSystemSet from a serialized source
  111596. * @param data defines a JSON compatible representation of the set
  111597. * @param scene defines the hosting scene
  111598. * @param gpu defines if we want GPU particles or CPU particles
  111599. * @returns a new ParticleSystemSet
  111600. */
  111601. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111602. }
  111603. }
  111604. declare module BABYLON {
  111605. /**
  111606. * This class is made for on one-liner static method to help creating particle system set.
  111607. */
  111608. export class ParticleHelper {
  111609. /**
  111610. * Gets or sets base Assets URL
  111611. */
  111612. static BaseAssetsUrl: string;
  111613. /**
  111614. * Create a default particle system that you can tweak
  111615. * @param emitter defines the emitter to use
  111616. * @param capacity defines the system capacity (default is 500 particles)
  111617. * @param scene defines the hosting scene
  111618. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111619. * @returns the new Particle system
  111620. */
  111621. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111622. /**
  111623. * This is the main static method (one-liner) of this helper to create different particle systems
  111624. * @param type This string represents the type to the particle system to create
  111625. * @param scene The scene where the particle system should live
  111626. * @param gpu If the system will use gpu
  111627. * @returns the ParticleSystemSet created
  111628. */
  111629. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111630. /**
  111631. * Static function used to export a particle system to a ParticleSystemSet variable.
  111632. * Please note that the emitter shape is not exported
  111633. * @param systems defines the particle systems to export
  111634. * @returns the created particle system set
  111635. */
  111636. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111637. }
  111638. }
  111639. declare module BABYLON {
  111640. interface Engine {
  111641. /**
  111642. * Create an effect to use with particle systems.
  111643. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111644. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111645. * @param uniformsNames defines a list of attribute names
  111646. * @param samplers defines an array of string used to represent textures
  111647. * @param defines defines the string containing the defines to use to compile the shaders
  111648. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111649. * @param onCompiled defines a function to call when the effect creation is successful
  111650. * @param onError defines a function to call when the effect creation has failed
  111651. * @returns the new Effect
  111652. */
  111653. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111654. }
  111655. interface Mesh {
  111656. /**
  111657. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111658. * @returns an array of IParticleSystem
  111659. */
  111660. getEmittedParticleSystems(): IParticleSystem[];
  111661. /**
  111662. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111663. * @returns an array of IParticleSystem
  111664. */
  111665. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111666. }
  111667. /**
  111668. * @hidden
  111669. */
  111670. export var _IDoNeedToBeInTheBuild: number;
  111671. }
  111672. declare module BABYLON {
  111673. interface Scene {
  111674. /** @hidden (Backing field) */
  111675. _physicsEngine: Nullable<IPhysicsEngine>;
  111676. /**
  111677. * Gets the current physics engine
  111678. * @returns a IPhysicsEngine or null if none attached
  111679. */
  111680. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111681. /**
  111682. * Enables physics to the current scene
  111683. * @param gravity defines the scene's gravity for the physics engine
  111684. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111685. * @return a boolean indicating if the physics engine was initialized
  111686. */
  111687. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111688. /**
  111689. * Disables and disposes the physics engine associated with the scene
  111690. */
  111691. disablePhysicsEngine(): void;
  111692. /**
  111693. * Gets a boolean indicating if there is an active physics engine
  111694. * @returns a boolean indicating if there is an active physics engine
  111695. */
  111696. isPhysicsEnabled(): boolean;
  111697. /**
  111698. * Deletes a physics compound impostor
  111699. * @param compound defines the compound to delete
  111700. */
  111701. deleteCompoundImpostor(compound: any): void;
  111702. /**
  111703. * An event triggered when physic simulation is about to be run
  111704. */
  111705. onBeforePhysicsObservable: Observable<Scene>;
  111706. /**
  111707. * An event triggered when physic simulation has been done
  111708. */
  111709. onAfterPhysicsObservable: Observable<Scene>;
  111710. }
  111711. interface AbstractMesh {
  111712. /** @hidden */
  111713. _physicsImpostor: Nullable<PhysicsImpostor>;
  111714. /**
  111715. * Gets or sets impostor used for physic simulation
  111716. * @see http://doc.babylonjs.com/features/physics_engine
  111717. */
  111718. physicsImpostor: Nullable<PhysicsImpostor>;
  111719. /**
  111720. * Gets the current physics impostor
  111721. * @see http://doc.babylonjs.com/features/physics_engine
  111722. * @returns a physics impostor or null
  111723. */
  111724. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111725. /** Apply a physic impulse to the mesh
  111726. * @param force defines the force to apply
  111727. * @param contactPoint defines where to apply the force
  111728. * @returns the current mesh
  111729. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111730. */
  111731. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111732. /**
  111733. * Creates a physic joint between two meshes
  111734. * @param otherMesh defines the other mesh to use
  111735. * @param pivot1 defines the pivot to use on this mesh
  111736. * @param pivot2 defines the pivot to use on the other mesh
  111737. * @param options defines additional options (can be plugin dependent)
  111738. * @returns the current mesh
  111739. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111740. */
  111741. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111742. /** @hidden */
  111743. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111744. }
  111745. /**
  111746. * Defines the physics engine scene component responsible to manage a physics engine
  111747. */
  111748. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111749. /**
  111750. * The component name helpful to identify the component in the list of scene components.
  111751. */
  111752. readonly name: string;
  111753. /**
  111754. * The scene the component belongs to.
  111755. */
  111756. scene: Scene;
  111757. /**
  111758. * Creates a new instance of the component for the given scene
  111759. * @param scene Defines the scene to register the component in
  111760. */
  111761. constructor(scene: Scene);
  111762. /**
  111763. * Registers the component in a given scene
  111764. */
  111765. register(): void;
  111766. /**
  111767. * Rebuilds the elements related to this component in case of
  111768. * context lost for instance.
  111769. */
  111770. rebuild(): void;
  111771. /**
  111772. * Disposes the component and the associated ressources
  111773. */
  111774. dispose(): void;
  111775. }
  111776. }
  111777. declare module BABYLON {
  111778. /**
  111779. * A helper for physics simulations
  111780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111781. */
  111782. export class PhysicsHelper {
  111783. private _scene;
  111784. private _physicsEngine;
  111785. /**
  111786. * Initializes the Physics helper
  111787. * @param scene Babylon.js scene
  111788. */
  111789. constructor(scene: Scene);
  111790. /**
  111791. * Applies a radial explosion impulse
  111792. * @param origin the origin of the explosion
  111793. * @param radiusOrEventOptions the radius or the options of radial explosion
  111794. * @param strength the explosion strength
  111795. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111796. * @returns A physics radial explosion event, or null
  111797. */
  111798. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111799. /**
  111800. * Applies a radial explosion force
  111801. * @param origin the origin of the explosion
  111802. * @param radiusOrEventOptions the radius or the options of radial explosion
  111803. * @param strength the explosion strength
  111804. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111805. * @returns A physics radial explosion event, or null
  111806. */
  111807. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111808. /**
  111809. * Creates a gravitational field
  111810. * @param origin the origin of the explosion
  111811. * @param radiusOrEventOptions the radius or the options of radial explosion
  111812. * @param strength the explosion strength
  111813. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111814. * @returns A physics gravitational field event, or null
  111815. */
  111816. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111817. /**
  111818. * Creates a physics updraft event
  111819. * @param origin the origin of the updraft
  111820. * @param radiusOrEventOptions the radius or the options of the updraft
  111821. * @param strength the strength of the updraft
  111822. * @param height the height of the updraft
  111823. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111824. * @returns A physics updraft event, or null
  111825. */
  111826. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  111827. /**
  111828. * Creates a physics vortex event
  111829. * @param origin the of the vortex
  111830. * @param radiusOrEventOptions the radius or the options of the vortex
  111831. * @param strength the strength of the vortex
  111832. * @param height the height of the vortex
  111833. * @returns a Physics vortex event, or null
  111834. * A physics vortex event or null
  111835. */
  111836. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  111837. }
  111838. /**
  111839. * Represents a physics radial explosion event
  111840. */
  111841. class PhysicsRadialExplosionEvent {
  111842. private _scene;
  111843. private _options;
  111844. private _sphere;
  111845. private _dataFetched;
  111846. /**
  111847. * Initializes a radial explosioin event
  111848. * @param _scene BabylonJS scene
  111849. * @param _options The options for the vortex event
  111850. */
  111851. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  111852. /**
  111853. * Returns the data related to the radial explosion event (sphere).
  111854. * @returns The radial explosion event data
  111855. */
  111856. getData(): PhysicsRadialExplosionEventData;
  111857. /**
  111858. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111859. * @param impostor A physics imposter
  111860. * @param origin the origin of the explosion
  111861. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  111862. */
  111863. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  111864. /**
  111865. * Triggers affecterd impostors callbacks
  111866. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  111867. */
  111868. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  111869. /**
  111870. * Disposes the sphere.
  111871. * @param force Specifies if the sphere should be disposed by force
  111872. */
  111873. dispose(force?: boolean): void;
  111874. /*** Helpers ***/
  111875. private _prepareSphere;
  111876. private _intersectsWithSphere;
  111877. }
  111878. /**
  111879. * Represents a gravitational field event
  111880. */
  111881. class PhysicsGravitationalFieldEvent {
  111882. private _physicsHelper;
  111883. private _scene;
  111884. private _origin;
  111885. private _options;
  111886. private _tickCallback;
  111887. private _sphere;
  111888. private _dataFetched;
  111889. /**
  111890. * Initializes the physics gravitational field event
  111891. * @param _physicsHelper A physics helper
  111892. * @param _scene BabylonJS scene
  111893. * @param _origin The origin position of the gravitational field event
  111894. * @param _options The options for the vortex event
  111895. */
  111896. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  111897. /**
  111898. * Returns the data related to the gravitational field event (sphere).
  111899. * @returns A gravitational field event
  111900. */
  111901. getData(): PhysicsGravitationalFieldEventData;
  111902. /**
  111903. * Enables the gravitational field.
  111904. */
  111905. enable(): void;
  111906. /**
  111907. * Disables the gravitational field.
  111908. */
  111909. disable(): void;
  111910. /**
  111911. * Disposes the sphere.
  111912. * @param force The force to dispose from the gravitational field event
  111913. */
  111914. dispose(force?: boolean): void;
  111915. private _tick;
  111916. }
  111917. /**
  111918. * Represents a physics updraft event
  111919. */
  111920. class PhysicsUpdraftEvent {
  111921. private _scene;
  111922. private _origin;
  111923. private _options;
  111924. private _physicsEngine;
  111925. private _originTop;
  111926. private _originDirection;
  111927. private _tickCallback;
  111928. private _cylinder;
  111929. private _cylinderPosition;
  111930. private _dataFetched;
  111931. /**
  111932. * Initializes the physics updraft event
  111933. * @param _scene BabylonJS scene
  111934. * @param _origin The origin position of the updraft
  111935. * @param _options The options for the updraft event
  111936. */
  111937. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111938. /**
  111939. * Returns the data related to the updraft event (cylinder).
  111940. * @returns A physics updraft event
  111941. */
  111942. getData(): PhysicsUpdraftEventData;
  111943. /**
  111944. * Enables the updraft.
  111945. */
  111946. enable(): void;
  111947. /**
  111948. * Disables the updraft.
  111949. */
  111950. disable(): void;
  111951. /**
  111952. * Disposes the cylinder.
  111953. * @param force Specifies if the updraft should be disposed by force
  111954. */
  111955. dispose(force?: boolean): void;
  111956. private getImpostorHitData;
  111957. private _tick;
  111958. /*** Helpers ***/
  111959. private _prepareCylinder;
  111960. private _intersectsWithCylinder;
  111961. }
  111962. /**
  111963. * Represents a physics vortex event
  111964. */
  111965. class PhysicsVortexEvent {
  111966. private _scene;
  111967. private _origin;
  111968. private _options;
  111969. private _physicsEngine;
  111970. private _originTop;
  111971. private _tickCallback;
  111972. private _cylinder;
  111973. private _cylinderPosition;
  111974. private _dataFetched;
  111975. /**
  111976. * Initializes the physics vortex event
  111977. * @param _scene The BabylonJS scene
  111978. * @param _origin The origin position of the vortex
  111979. * @param _options The options for the vortex event
  111980. */
  111981. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111982. /**
  111983. * Returns the data related to the vortex event (cylinder).
  111984. * @returns The physics vortex event data
  111985. */
  111986. getData(): PhysicsVortexEventData;
  111987. /**
  111988. * Enables the vortex.
  111989. */
  111990. enable(): void;
  111991. /**
  111992. * Disables the cortex.
  111993. */
  111994. disable(): void;
  111995. /**
  111996. * Disposes the sphere.
  111997. * @param force
  111998. */
  111999. dispose(force?: boolean): void;
  112000. private getImpostorHitData;
  112001. private _tick;
  112002. /*** Helpers ***/
  112003. private _prepareCylinder;
  112004. private _intersectsWithCylinder;
  112005. }
  112006. /**
  112007. * Options fot the radial explosion event
  112008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112009. */
  112010. export class PhysicsRadialExplosionEventOptions {
  112011. /**
  112012. * The radius of the sphere for the radial explosion.
  112013. */
  112014. radius: number;
  112015. /**
  112016. * The strenth of the explosion.
  112017. */
  112018. strength: number;
  112019. /**
  112020. * The strenght of the force in correspondence to the distance of the affected object
  112021. */
  112022. falloff: PhysicsRadialImpulseFalloff;
  112023. /**
  112024. * Sphere options for the radial explosion.
  112025. */
  112026. sphere: {
  112027. segments: number;
  112028. diameter: number;
  112029. };
  112030. /**
  112031. * Sphere options for the radial explosion.
  112032. */
  112033. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  112034. }
  112035. /**
  112036. * Options fot the updraft event
  112037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112038. */
  112039. export class PhysicsUpdraftEventOptions {
  112040. /**
  112041. * The radius of the cylinder for the vortex
  112042. */
  112043. radius: number;
  112044. /**
  112045. * The strenth of the updraft.
  112046. */
  112047. strength: number;
  112048. /**
  112049. * The height of the cylinder for the updraft.
  112050. */
  112051. height: number;
  112052. /**
  112053. * The mode for the the updraft.
  112054. */
  112055. updraftMode: PhysicsUpdraftMode;
  112056. }
  112057. /**
  112058. * Options fot the vortex event
  112059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112060. */
  112061. export class PhysicsVortexEventOptions {
  112062. /**
  112063. * The radius of the cylinder for the vortex
  112064. */
  112065. radius: number;
  112066. /**
  112067. * The strenth of the vortex.
  112068. */
  112069. strength: number;
  112070. /**
  112071. * The height of the cylinder for the vortex.
  112072. */
  112073. height: number;
  112074. /**
  112075. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  112076. */
  112077. centripetalForceThreshold: number;
  112078. /**
  112079. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  112080. */
  112081. centripetalForceMultiplier: number;
  112082. /**
  112083. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  112084. */
  112085. centrifugalForceMultiplier: number;
  112086. /**
  112087. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  112088. */
  112089. updraftForceMultiplier: number;
  112090. }
  112091. /**
  112092. * The strenght of the force in correspondence to the distance of the affected object
  112093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112094. */
  112095. export enum PhysicsRadialImpulseFalloff {
  112096. /** Defines that impulse is constant in strength across it's whole radius */
  112097. Constant = 0,
  112098. /** Defines that impulse gets weaker if it's further from the origin */
  112099. Linear = 1
  112100. }
  112101. /**
  112102. * The strength 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 PhysicsUpdraftMode {
  112106. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  112107. Center = 0,
  112108. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  112109. Perpendicular = 1
  112110. }
  112111. /**
  112112. * Interface for a physics hit data
  112113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112114. */
  112115. export interface PhysicsHitData {
  112116. /**
  112117. * The force applied at the contact point
  112118. */
  112119. force: Vector3;
  112120. /**
  112121. * The contact point
  112122. */
  112123. contactPoint: Vector3;
  112124. /**
  112125. * The distance from the origin to the contact point
  112126. */
  112127. distanceFromOrigin: number;
  112128. }
  112129. /**
  112130. * Interface for radial explosion event data
  112131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112132. */
  112133. export interface PhysicsRadialExplosionEventData {
  112134. /**
  112135. * A sphere used for the radial explosion event
  112136. */
  112137. sphere: Mesh;
  112138. }
  112139. /**
  112140. * Interface for gravitational field event data
  112141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112142. */
  112143. export interface PhysicsGravitationalFieldEventData {
  112144. /**
  112145. * A sphere mesh used for the gravitational field event
  112146. */
  112147. sphere: Mesh;
  112148. }
  112149. /**
  112150. * Interface for updraft event data
  112151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112152. */
  112153. export interface PhysicsUpdraftEventData {
  112154. /**
  112155. * A cylinder used for the updraft event
  112156. */
  112157. cylinder: Mesh;
  112158. }
  112159. /**
  112160. * Interface for vortex event data
  112161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112162. */
  112163. export interface PhysicsVortexEventData {
  112164. /**
  112165. * A cylinder used for the vortex event
  112166. */
  112167. cylinder: Mesh;
  112168. }
  112169. /**
  112170. * Interface for an affected physics impostor
  112171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112172. */
  112173. export interface PhysicsAffectedImpostorWithData {
  112174. /**
  112175. * The impostor affected by the effect
  112176. */
  112177. impostor: PhysicsImpostor;
  112178. /**
  112179. * The data about the hit/horce from the explosion
  112180. */
  112181. hitData: PhysicsHitData;
  112182. }
  112183. }
  112184. declare module BABYLON {
  112185. /** @hidden */
  112186. export var blackAndWhitePixelShader: {
  112187. name: string;
  112188. shader: string;
  112189. };
  112190. }
  112191. declare module BABYLON {
  112192. /**
  112193. * Post process used to render in black and white
  112194. */
  112195. export class BlackAndWhitePostProcess extends PostProcess {
  112196. /**
  112197. * Linear about to convert he result to black and white (default: 1)
  112198. */
  112199. degree: number;
  112200. /**
  112201. * Creates a black and white post process
  112202. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  112203. * @param name The name of the effect.
  112204. * @param options The required width/height ratio to downsize to before computing the render pass.
  112205. * @param camera The camera to apply the render pass to.
  112206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112207. * @param engine The engine which the post process will be applied. (default: current engine)
  112208. * @param reusable If the post process can be reused on the same frame. (default: false)
  112209. */
  112210. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112211. }
  112212. }
  112213. declare module BABYLON {
  112214. /**
  112215. * This represents a set of one or more post processes in Babylon.
  112216. * A post process can be used to apply a shader to a texture after it is rendered.
  112217. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112218. */
  112219. export class PostProcessRenderEffect {
  112220. private _postProcesses;
  112221. private _getPostProcesses;
  112222. private _singleInstance;
  112223. private _cameras;
  112224. private _indicesForCamera;
  112225. /**
  112226. * Name of the effect
  112227. * @hidden
  112228. */
  112229. _name: string;
  112230. /**
  112231. * Instantiates a post process render effect.
  112232. * A post process can be used to apply a shader to a texture after it is rendered.
  112233. * @param engine The engine the effect is tied to
  112234. * @param name The name of the effect
  112235. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  112236. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  112237. */
  112238. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  112239. /**
  112240. * Checks if all the post processes in the effect are supported.
  112241. */
  112242. readonly isSupported: boolean;
  112243. /**
  112244. * Updates the current state of the effect
  112245. * @hidden
  112246. */
  112247. _update(): void;
  112248. /**
  112249. * Attaches the effect on cameras
  112250. * @param cameras The camera to attach to.
  112251. * @hidden
  112252. */
  112253. _attachCameras(cameras: Camera): void;
  112254. /**
  112255. * Attaches the effect on cameras
  112256. * @param cameras The camera to attach to.
  112257. * @hidden
  112258. */
  112259. _attachCameras(cameras: Camera[]): void;
  112260. /**
  112261. * Detaches the effect on cameras
  112262. * @param cameras The camera to detatch from.
  112263. * @hidden
  112264. */
  112265. _detachCameras(cameras: Camera): void;
  112266. /**
  112267. * Detatches the effect on cameras
  112268. * @param cameras The camera to detatch from.
  112269. * @hidden
  112270. */
  112271. _detachCameras(cameras: Camera[]): void;
  112272. /**
  112273. * Enables the effect on given cameras
  112274. * @param cameras The camera to enable.
  112275. * @hidden
  112276. */
  112277. _enable(cameras: Camera): void;
  112278. /**
  112279. * Enables the effect on given cameras
  112280. * @param cameras The camera to enable.
  112281. * @hidden
  112282. */
  112283. _enable(cameras: Nullable<Camera[]>): void;
  112284. /**
  112285. * Disables the effect on the given cameras
  112286. * @param cameras The camera to disable.
  112287. * @hidden
  112288. */
  112289. _disable(cameras: Camera): void;
  112290. /**
  112291. * Disables the effect on the given cameras
  112292. * @param cameras The camera to disable.
  112293. * @hidden
  112294. */
  112295. _disable(cameras: Nullable<Camera[]>): void;
  112296. /**
  112297. * Gets a list of the post processes contained in the effect.
  112298. * @param camera The camera to get the post processes on.
  112299. * @returns The list of the post processes in the effect.
  112300. */
  112301. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  112302. }
  112303. }
  112304. declare module BABYLON {
  112305. /** @hidden */
  112306. export var extractHighlightsPixelShader: {
  112307. name: string;
  112308. shader: string;
  112309. };
  112310. }
  112311. declare module BABYLON {
  112312. /**
  112313. * 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.
  112314. */
  112315. export class ExtractHighlightsPostProcess extends PostProcess {
  112316. /**
  112317. * The luminance threshold, pixels below this value will be set to black.
  112318. */
  112319. threshold: number;
  112320. /** @hidden */
  112321. _exposure: number;
  112322. /**
  112323. * Post process which has the input texture to be used when performing highlight extraction
  112324. * @hidden
  112325. */
  112326. _inputPostProcess: Nullable<PostProcess>;
  112327. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112328. }
  112329. }
  112330. declare module BABYLON {
  112331. /** @hidden */
  112332. export var bloomMergePixelShader: {
  112333. name: string;
  112334. shader: string;
  112335. };
  112336. }
  112337. declare module BABYLON {
  112338. /**
  112339. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112340. */
  112341. export class BloomMergePostProcess extends PostProcess {
  112342. /** Weight of the bloom to be added to the original input. */
  112343. weight: number;
  112344. /**
  112345. * Creates a new instance of @see BloomMergePostProcess
  112346. * @param name The name of the effect.
  112347. * @param originalFromInput Post process which's input will be used for the merge.
  112348. * @param blurred Blurred highlights post process which's output will be used.
  112349. * @param weight Weight of the bloom to be added to the original input.
  112350. * @param options The required width/height ratio to downsize to before computing the render pass.
  112351. * @param camera The camera to apply the render pass to.
  112352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112353. * @param engine The engine which the post process will be applied. (default: current engine)
  112354. * @param reusable If the post process can be reused on the same frame. (default: false)
  112355. * @param textureType Type of textures used when performing the post process. (default: 0)
  112356. * @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)
  112357. */
  112358. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  112359. /** Weight of the bloom to be added to the original input. */
  112360. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112361. }
  112362. }
  112363. declare module BABYLON {
  112364. /**
  112365. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  112366. */
  112367. export class BloomEffect extends PostProcessRenderEffect {
  112368. private bloomScale;
  112369. /**
  112370. * @hidden Internal
  112371. */
  112372. _effects: Array<PostProcess>;
  112373. /**
  112374. * @hidden Internal
  112375. */
  112376. _downscale: ExtractHighlightsPostProcess;
  112377. private _blurX;
  112378. private _blurY;
  112379. private _merge;
  112380. /**
  112381. * The luminance threshold to find bright areas of the image to bloom.
  112382. */
  112383. threshold: number;
  112384. /**
  112385. * The strength of the bloom.
  112386. */
  112387. weight: number;
  112388. /**
  112389. * Specifies the size of the bloom blur kernel, relative to the final output size
  112390. */
  112391. kernel: number;
  112392. /**
  112393. * Creates a new instance of @see BloomEffect
  112394. * @param scene The scene the effect belongs to.
  112395. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  112396. * @param bloomKernel The size of the kernel to be used when applying the blur.
  112397. * @param bloomWeight The the strength of bloom.
  112398. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112399. * @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)
  112400. */
  112401. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  112402. /**
  112403. * Disposes each of the internal effects for a given camera.
  112404. * @param camera The camera to dispose the effect on.
  112405. */
  112406. disposeEffects(camera: Camera): void;
  112407. /**
  112408. * @hidden Internal
  112409. */
  112410. _updateEffects(): void;
  112411. /**
  112412. * Internal
  112413. * @returns if all the contained post processes are ready.
  112414. * @hidden
  112415. */
  112416. _isReady(): boolean;
  112417. }
  112418. }
  112419. declare module BABYLON {
  112420. /** @hidden */
  112421. export var chromaticAberrationPixelShader: {
  112422. name: string;
  112423. shader: string;
  112424. };
  112425. }
  112426. declare module BABYLON {
  112427. /**
  112428. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  112429. */
  112430. export class ChromaticAberrationPostProcess extends PostProcess {
  112431. /**
  112432. * The amount of seperation of rgb channels (default: 30)
  112433. */
  112434. aberrationAmount: number;
  112435. /**
  112436. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  112437. */
  112438. radialIntensity: number;
  112439. /**
  112440. * 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))
  112441. */
  112442. direction: Vector2;
  112443. /**
  112444. * 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))
  112445. */
  112446. centerPosition: Vector2;
  112447. /**
  112448. * Creates a new instance ChromaticAberrationPostProcess
  112449. * @param name The name of the effect.
  112450. * @param screenWidth The width of the screen to apply the effect on.
  112451. * @param screenHeight The height of the screen to apply the effect on.
  112452. * @param options The required width/height ratio to downsize to before computing the render pass.
  112453. * @param camera The camera to apply the render pass to.
  112454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112455. * @param engine The engine which the post process will be applied. (default: current engine)
  112456. * @param reusable If the post process can be reused on the same frame. (default: false)
  112457. * @param textureType Type of textures used when performing the post process. (default: 0)
  112458. * @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)
  112459. */
  112460. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112461. }
  112462. }
  112463. declare module BABYLON {
  112464. /** @hidden */
  112465. export var circleOfConfusionPixelShader: {
  112466. name: string;
  112467. shader: string;
  112468. };
  112469. }
  112470. declare module BABYLON {
  112471. /**
  112472. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  112473. */
  112474. export class CircleOfConfusionPostProcess extends PostProcess {
  112475. /**
  112476. * 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.
  112477. */
  112478. lensSize: number;
  112479. /**
  112480. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112481. */
  112482. fStop: number;
  112483. /**
  112484. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112485. */
  112486. focusDistance: number;
  112487. /**
  112488. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  112489. */
  112490. focalLength: number;
  112491. private _depthTexture;
  112492. /**
  112493. * Creates a new instance CircleOfConfusionPostProcess
  112494. * @param name The name of the effect.
  112495. * @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.
  112496. * @param options The required width/height ratio to downsize to before computing the render pass.
  112497. * @param camera The camera to apply the render pass to.
  112498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112499. * @param engine The engine which the post process will be applied. (default: current engine)
  112500. * @param reusable If the post process can be reused on the same frame. (default: false)
  112501. * @param textureType Type of textures used when performing the post process. (default: 0)
  112502. * @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)
  112503. */
  112504. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112505. /**
  112506. * 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.
  112507. */
  112508. depthTexture: RenderTargetTexture;
  112509. }
  112510. }
  112511. declare module BABYLON {
  112512. /** @hidden */
  112513. export var colorCorrectionPixelShader: {
  112514. name: string;
  112515. shader: string;
  112516. };
  112517. }
  112518. declare module BABYLON {
  112519. /**
  112520. *
  112521. * This post-process allows the modification of rendered colors by using
  112522. * a 'look-up table' (LUT). This effect is also called Color Grading.
  112523. *
  112524. * The object needs to be provided an url to a texture containing the color
  112525. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  112526. * Use an image editing software to tweak the LUT to match your needs.
  112527. *
  112528. * For an example of a color LUT, see here:
  112529. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  112530. * For explanations on color grading, see here:
  112531. * @see http://udn.epicgames.com/Three/ColorGrading.html
  112532. *
  112533. */
  112534. export class ColorCorrectionPostProcess extends PostProcess {
  112535. private _colorTableTexture;
  112536. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112537. }
  112538. }
  112539. declare module BABYLON {
  112540. /** @hidden */
  112541. export var convolutionPixelShader: {
  112542. name: string;
  112543. shader: string;
  112544. };
  112545. }
  112546. declare module BABYLON {
  112547. /**
  112548. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112549. * input texture to perform effects such as edge detection or sharpening
  112550. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112551. */
  112552. export class ConvolutionPostProcess extends PostProcess {
  112553. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112554. kernel: number[];
  112555. /**
  112556. * Creates a new instance ConvolutionPostProcess
  112557. * @param name The name of the effect.
  112558. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112559. * @param options The required width/height ratio to downsize to before computing the render pass.
  112560. * @param camera The camera to apply the render pass to.
  112561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112562. * @param engine The engine which the post process will be applied. (default: current engine)
  112563. * @param reusable If the post process can be reused on the same frame. (default: false)
  112564. * @param textureType Type of textures used when performing the post process. (default: 0)
  112565. */
  112566. constructor(name: string,
  112567. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112568. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112569. /**
  112570. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112571. */
  112572. static EdgeDetect0Kernel: number[];
  112573. /**
  112574. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112575. */
  112576. static EdgeDetect1Kernel: number[];
  112577. /**
  112578. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112579. */
  112580. static EdgeDetect2Kernel: number[];
  112581. /**
  112582. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112583. */
  112584. static SharpenKernel: number[];
  112585. /**
  112586. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112587. */
  112588. static EmbossKernel: number[];
  112589. /**
  112590. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112591. */
  112592. static GaussianKernel: number[];
  112593. }
  112594. }
  112595. declare module BABYLON {
  112596. /**
  112597. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112598. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112599. * based on samples that have a large difference in distance than the center pixel.
  112600. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112601. */
  112602. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112603. direction: Vector2;
  112604. /**
  112605. * Creates a new instance CircleOfConfusionPostProcess
  112606. * @param name The name of the effect.
  112607. * @param scene The scene the effect belongs to.
  112608. * @param direction The direction the blur should be applied.
  112609. * @param kernel The size of the kernel used to blur.
  112610. * @param options The required width/height ratio to downsize to before computing the render pass.
  112611. * @param camera The camera to apply the render pass to.
  112612. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112613. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112615. * @param engine The engine which the post process will be applied. (default: current engine)
  112616. * @param reusable If the post process can be reused on the same frame. (default: false)
  112617. * @param textureType Type of textures used when performing the post process. (default: 0)
  112618. * @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)
  112619. */
  112620. 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);
  112621. }
  112622. }
  112623. declare module BABYLON {
  112624. /** @hidden */
  112625. export var depthOfFieldMergePixelShader: {
  112626. name: string;
  112627. shader: string;
  112628. };
  112629. }
  112630. declare module BABYLON {
  112631. /**
  112632. * Options to be set when merging outputs from the default pipeline.
  112633. */
  112634. export class DepthOfFieldMergePostProcessOptions {
  112635. /**
  112636. * The original image to merge on top of
  112637. */
  112638. originalFromInput: PostProcess;
  112639. /**
  112640. * Parameters to perform the merge of the depth of field effect
  112641. */
  112642. depthOfField?: {
  112643. circleOfConfusion: PostProcess;
  112644. blurSteps: Array<PostProcess>;
  112645. };
  112646. /**
  112647. * Parameters to perform the merge of bloom effect
  112648. */
  112649. bloom?: {
  112650. blurred: PostProcess;
  112651. weight: number;
  112652. };
  112653. }
  112654. /**
  112655. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112656. */
  112657. export class DepthOfFieldMergePostProcess extends PostProcess {
  112658. private blurSteps;
  112659. /**
  112660. * Creates a new instance of DepthOfFieldMergePostProcess
  112661. * @param name The name of the effect.
  112662. * @param originalFromInput Post process which's input will be used for the merge.
  112663. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112664. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112665. * @param options The required width/height ratio to downsize to before computing the render pass.
  112666. * @param camera The camera to apply the render pass to.
  112667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112668. * @param engine The engine which the post process will be applied. (default: current engine)
  112669. * @param reusable If the post process can be reused on the same frame. (default: false)
  112670. * @param textureType Type of textures used when performing the post process. (default: 0)
  112671. * @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)
  112672. */
  112673. 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);
  112674. /**
  112675. * Updates the effect with the current post process compile time values and recompiles the shader.
  112676. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112677. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112678. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112679. * @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
  112680. * @param onCompiled Called when the shader has been compiled.
  112681. * @param onError Called if there is an error when compiling a shader.
  112682. */
  112683. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112684. }
  112685. }
  112686. declare module BABYLON {
  112687. /**
  112688. * Specifies the level of max blur that should be applied when using the depth of field effect
  112689. */
  112690. export enum DepthOfFieldEffectBlurLevel {
  112691. /**
  112692. * Subtle blur
  112693. */
  112694. Low = 0,
  112695. /**
  112696. * Medium blur
  112697. */
  112698. Medium = 1,
  112699. /**
  112700. * Large blur
  112701. */
  112702. High = 2
  112703. }
  112704. /**
  112705. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112706. */
  112707. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112708. private _circleOfConfusion;
  112709. /**
  112710. * @hidden Internal, blurs from high to low
  112711. */
  112712. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112713. private _depthOfFieldBlurY;
  112714. private _dofMerge;
  112715. /**
  112716. * @hidden Internal post processes in depth of field effect
  112717. */
  112718. _effects: Array<PostProcess>;
  112719. /**
  112720. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112721. */
  112722. focalLength: number;
  112723. /**
  112724. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112725. */
  112726. fStop: number;
  112727. /**
  112728. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112729. */
  112730. focusDistance: number;
  112731. /**
  112732. * 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.
  112733. */
  112734. lensSize: number;
  112735. /**
  112736. * Creates a new instance DepthOfFieldEffect
  112737. * @param scene The scene the effect belongs to.
  112738. * @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.
  112739. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112740. * @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)
  112741. */
  112742. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112743. /**
  112744. * Get the current class name of the current effet
  112745. * @returns "DepthOfFieldEffect"
  112746. */
  112747. getClassName(): string;
  112748. /**
  112749. * 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.
  112750. */
  112751. depthTexture: RenderTargetTexture;
  112752. /**
  112753. * Disposes each of the internal effects for a given camera.
  112754. * @param camera The camera to dispose the effect on.
  112755. */
  112756. disposeEffects(camera: Camera): void;
  112757. /**
  112758. * @hidden Internal
  112759. */
  112760. _updateEffects(): void;
  112761. /**
  112762. * Internal
  112763. * @returns if all the contained post processes are ready.
  112764. * @hidden
  112765. */
  112766. _isReady(): boolean;
  112767. }
  112768. }
  112769. declare module BABYLON {
  112770. /** @hidden */
  112771. export var displayPassPixelShader: {
  112772. name: string;
  112773. shader: string;
  112774. };
  112775. }
  112776. declare module BABYLON {
  112777. /**
  112778. * DisplayPassPostProcess which produces an output the same as it's input
  112779. */
  112780. export class DisplayPassPostProcess extends PostProcess {
  112781. /**
  112782. * Creates the DisplayPassPostProcess
  112783. * @param name The name of the effect.
  112784. * @param options The required width/height ratio to downsize to before computing the render pass.
  112785. * @param camera The camera to apply the render pass to.
  112786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112787. * @param engine The engine which the post process will be applied. (default: current engine)
  112788. * @param reusable If the post process can be reused on the same frame. (default: false)
  112789. */
  112790. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112791. }
  112792. }
  112793. declare module BABYLON {
  112794. /** @hidden */
  112795. export var filterPixelShader: {
  112796. name: string;
  112797. shader: string;
  112798. };
  112799. }
  112800. declare module BABYLON {
  112801. /**
  112802. * Applies a kernel filter to the image
  112803. */
  112804. export class FilterPostProcess extends PostProcess {
  112805. /** The matrix to be applied to the image */
  112806. kernelMatrix: Matrix;
  112807. /**
  112808. *
  112809. * @param name The name of the effect.
  112810. * @param kernelMatrix The matrix to be applied to the image
  112811. * @param options The required width/height ratio to downsize to before computing the render pass.
  112812. * @param camera The camera to apply the render pass to.
  112813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112814. * @param engine The engine which the post process will be applied. (default: current engine)
  112815. * @param reusable If the post process can be reused on the same frame. (default: false)
  112816. */
  112817. constructor(name: string,
  112818. /** The matrix to be applied to the image */
  112819. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112820. }
  112821. }
  112822. declare module BABYLON {
  112823. /** @hidden */
  112824. export var fxaaPixelShader: {
  112825. name: string;
  112826. shader: string;
  112827. };
  112828. }
  112829. declare module BABYLON {
  112830. /** @hidden */
  112831. export var fxaaVertexShader: {
  112832. name: string;
  112833. shader: string;
  112834. };
  112835. }
  112836. declare module BABYLON {
  112837. /**
  112838. * Fxaa post process
  112839. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  112840. */
  112841. export class FxaaPostProcess extends PostProcess {
  112842. /** @hidden */
  112843. texelWidth: number;
  112844. /** @hidden */
  112845. texelHeight: number;
  112846. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112847. private _getDefines;
  112848. }
  112849. }
  112850. declare module BABYLON {
  112851. /** @hidden */
  112852. export var grainPixelShader: {
  112853. name: string;
  112854. shader: string;
  112855. };
  112856. }
  112857. declare module BABYLON {
  112858. /**
  112859. * The GrainPostProcess adds noise to the image at mid luminance levels
  112860. */
  112861. export class GrainPostProcess extends PostProcess {
  112862. /**
  112863. * The intensity of the grain added (default: 30)
  112864. */
  112865. intensity: number;
  112866. /**
  112867. * If the grain should be randomized on every frame
  112868. */
  112869. animated: boolean;
  112870. /**
  112871. * Creates a new instance of @see GrainPostProcess
  112872. * @param name The name of the effect.
  112873. * @param options The required width/height ratio to downsize to before computing the render pass.
  112874. * @param camera The camera to apply the render pass to.
  112875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112876. * @param engine The engine which the post process will be applied. (default: current engine)
  112877. * @param reusable If the post process can be reused on the same frame. (default: false)
  112878. * @param textureType Type of textures used when performing the post process. (default: 0)
  112879. * @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)
  112880. */
  112881. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112882. }
  112883. }
  112884. declare module BABYLON {
  112885. /** @hidden */
  112886. export var highlightsPixelShader: {
  112887. name: string;
  112888. shader: string;
  112889. };
  112890. }
  112891. declare module BABYLON {
  112892. /**
  112893. * Extracts highlights from the image
  112894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112895. */
  112896. export class HighlightsPostProcess extends PostProcess {
  112897. /**
  112898. * Extracts highlights from the image
  112899. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112900. * @param name The name of the effect.
  112901. * @param options The required width/height ratio to downsize to before computing the render pass.
  112902. * @param camera The camera to apply the render pass to.
  112903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112904. * @param engine The engine which the post process will be applied. (default: current engine)
  112905. * @param reusable If the post process can be reused on the same frame. (default: false)
  112906. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  112907. */
  112908. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112909. }
  112910. }
  112911. declare module BABYLON {
  112912. /** @hidden */
  112913. export var mrtFragmentDeclaration: {
  112914. name: string;
  112915. shader: string;
  112916. };
  112917. }
  112918. declare module BABYLON {
  112919. /** @hidden */
  112920. export var geometryPixelShader: {
  112921. name: string;
  112922. shader: string;
  112923. };
  112924. }
  112925. declare module BABYLON {
  112926. /** @hidden */
  112927. export var geometryVertexShader: {
  112928. name: string;
  112929. shader: string;
  112930. };
  112931. }
  112932. declare module BABYLON {
  112933. /**
  112934. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112935. */
  112936. export class GeometryBufferRenderer {
  112937. /**
  112938. * Constant used to retrieve the position texture index in the G-Buffer textures array
  112939. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  112940. */
  112941. static readonly POSITION_TEXTURE_TYPE: number;
  112942. /**
  112943. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112944. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112945. */
  112946. static readonly VELOCITY_TEXTURE_TYPE: number;
  112947. /**
  112948. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112949. * in order to compute objects velocities when enableVelocity is set to "true"
  112950. * @hidden
  112951. */
  112952. _previousTransformationMatrices: {
  112953. [index: number]: Matrix;
  112954. };
  112955. private _scene;
  112956. private _multiRenderTarget;
  112957. private _ratio;
  112958. private _enablePosition;
  112959. private _enableVelocity;
  112960. private _positionIndex;
  112961. private _velocityIndex;
  112962. protected _effect: Effect;
  112963. protected _cachedDefines: string;
  112964. /**
  112965. * Set the render list (meshes to be rendered) used in the G buffer.
  112966. */
  112967. renderList: Mesh[];
  112968. /**
  112969. * Gets wether or not G buffer are supported by the running hardware.
  112970. * This requires draw buffer supports
  112971. */
  112972. readonly isSupported: boolean;
  112973. /**
  112974. * Returns the index of the given texture type in the G-Buffer textures array
  112975. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112976. * @returns the index of the given texture type in the G-Buffer textures array
  112977. */
  112978. getTextureIndex(textureType: number): number;
  112979. /**
  112980. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112981. */
  112982. /**
  112983. * Sets whether or not objects positions are enabled for the G buffer.
  112984. */
  112985. enablePosition: boolean;
  112986. /**
  112987. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112988. */
  112989. /**
  112990. * Sets wether or not objects velocities are enabled for the G buffer.
  112991. */
  112992. enableVelocity: boolean;
  112993. /**
  112994. * Gets the scene associated with the buffer.
  112995. */
  112996. readonly scene: Scene;
  112997. /**
  112998. * Gets the ratio used by the buffer during its creation.
  112999. * How big is the buffer related to the main canvas.
  113000. */
  113001. readonly ratio: number;
  113002. /** @hidden */
  113003. static _SceneComponentInitialization: (scene: Scene) => void;
  113004. /**
  113005. * Creates a new G Buffer for the scene
  113006. * @param scene The scene the buffer belongs to
  113007. * @param ratio How big is the buffer related to the main canvas.
  113008. */
  113009. constructor(scene: Scene, ratio?: number);
  113010. /**
  113011. * Checks wether everything is ready to render a submesh to the G buffer.
  113012. * @param subMesh the submesh to check readiness for
  113013. * @param useInstances is the mesh drawn using instance or not
  113014. * @returns true if ready otherwise false
  113015. */
  113016. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113017. /**
  113018. * Gets the current underlying G Buffer.
  113019. * @returns the buffer
  113020. */
  113021. getGBuffer(): MultiRenderTarget;
  113022. /**
  113023. * Gets the number of samples used to render the buffer (anti aliasing).
  113024. */
  113025. /**
  113026. * Sets the number of samples used to render the buffer (anti aliasing).
  113027. */
  113028. samples: number;
  113029. /**
  113030. * Disposes the renderer and frees up associated resources.
  113031. */
  113032. dispose(): void;
  113033. protected _createRenderTargets(): void;
  113034. }
  113035. }
  113036. declare module BABYLON {
  113037. interface Scene {
  113038. /** @hidden (Backing field) */
  113039. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113040. /**
  113041. * Gets or Sets the current geometry buffer associated to the scene.
  113042. */
  113043. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113044. /**
  113045. * Enables a GeometryBufferRender and associates it with the scene
  113046. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  113047. * @returns the GeometryBufferRenderer
  113048. */
  113049. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  113050. /**
  113051. * Disables the GeometryBufferRender associated with the scene
  113052. */
  113053. disableGeometryBufferRenderer(): void;
  113054. }
  113055. /**
  113056. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  113057. * in several rendering techniques.
  113058. */
  113059. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  113060. /**
  113061. * The component name helpful to identify the component in the list of scene components.
  113062. */
  113063. readonly name: string;
  113064. /**
  113065. * The scene the component belongs to.
  113066. */
  113067. scene: Scene;
  113068. /**
  113069. * Creates a new instance of the component for the given scene
  113070. * @param scene Defines the scene to register the component in
  113071. */
  113072. constructor(scene: Scene);
  113073. /**
  113074. * Registers the component in a given scene
  113075. */
  113076. register(): void;
  113077. /**
  113078. * Rebuilds the elements related to this component in case of
  113079. * context lost for instance.
  113080. */
  113081. rebuild(): void;
  113082. /**
  113083. * Disposes the component and the associated ressources
  113084. */
  113085. dispose(): void;
  113086. private _gatherRenderTargets;
  113087. }
  113088. }
  113089. declare module BABYLON {
  113090. /** @hidden */
  113091. export var motionBlurPixelShader: {
  113092. name: string;
  113093. shader: string;
  113094. };
  113095. }
  113096. declare module BABYLON {
  113097. /**
  113098. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  113099. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  113100. * As an example, all you have to do is to create the post-process:
  113101. * var mb = new BABYLON.MotionBlurPostProcess(
  113102. * 'mb', // The name of the effect.
  113103. * scene, // The scene containing the objects to blur according to their velocity.
  113104. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  113105. * camera // The camera to apply the render pass to.
  113106. * );
  113107. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  113108. */
  113109. export class MotionBlurPostProcess extends PostProcess {
  113110. /**
  113111. * Defines how much the image is blurred by the movement. Default value is equal to 1
  113112. */
  113113. motionStrength: number;
  113114. /**
  113115. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  113116. */
  113117. /**
  113118. * Sets the number of iterations to be used for motion blur quality
  113119. */
  113120. motionBlurSamples: number;
  113121. private _motionBlurSamples;
  113122. private _geometryBufferRenderer;
  113123. /**
  113124. * Creates a new instance MotionBlurPostProcess
  113125. * @param name The name of the effect.
  113126. * @param scene The scene containing the objects to blur according to their velocity.
  113127. * @param options The required width/height ratio to downsize to before computing the render pass.
  113128. * @param camera The camera to apply the render pass to.
  113129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113130. * @param engine The engine which the post process will be applied. (default: current engine)
  113131. * @param reusable If the post process can be reused on the same frame. (default: false)
  113132. * @param textureType Type of textures used when performing the post process. (default: 0)
  113133. * @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)
  113134. */
  113135. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113136. /**
  113137. * Disposes the post process.
  113138. * @param camera The camera to dispose the post process on.
  113139. */
  113140. dispose(camera?: Camera): void;
  113141. }
  113142. }
  113143. declare module BABYLON {
  113144. /** @hidden */
  113145. export var refractionPixelShader: {
  113146. name: string;
  113147. shader: string;
  113148. };
  113149. }
  113150. declare module BABYLON {
  113151. /**
  113152. * Post process which applies a refractin texture
  113153. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113154. */
  113155. export class RefractionPostProcess extends PostProcess {
  113156. /** the base color of the refraction (used to taint the rendering) */
  113157. color: Color3;
  113158. /** simulated refraction depth */
  113159. depth: number;
  113160. /** the coefficient of the base color (0 to remove base color tainting) */
  113161. colorLevel: number;
  113162. private _refTexture;
  113163. private _ownRefractionTexture;
  113164. /**
  113165. * Gets or sets the refraction texture
  113166. * Please note that you are responsible for disposing the texture if you set it manually
  113167. */
  113168. refractionTexture: Texture;
  113169. /**
  113170. * Initializes the RefractionPostProcess
  113171. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113172. * @param name The name of the effect.
  113173. * @param refractionTextureUrl Url of the refraction texture to use
  113174. * @param color the base color of the refraction (used to taint the rendering)
  113175. * @param depth simulated refraction depth
  113176. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  113177. * @param camera The camera to apply the render pass to.
  113178. * @param options The required width/height ratio to downsize to before computing the render pass.
  113179. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113180. * @param engine The engine which the post process will be applied. (default: current engine)
  113181. * @param reusable If the post process can be reused on the same frame. (default: false)
  113182. */
  113183. constructor(name: string, refractionTextureUrl: string,
  113184. /** the base color of the refraction (used to taint the rendering) */
  113185. color: Color3,
  113186. /** simulated refraction depth */
  113187. depth: number,
  113188. /** the coefficient of the base color (0 to remove base color tainting) */
  113189. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113190. /**
  113191. * Disposes of the post process
  113192. * @param camera Camera to dispose post process on
  113193. */
  113194. dispose(camera: Camera): void;
  113195. }
  113196. }
  113197. declare module BABYLON {
  113198. /** @hidden */
  113199. export var sharpenPixelShader: {
  113200. name: string;
  113201. shader: string;
  113202. };
  113203. }
  113204. declare module BABYLON {
  113205. /**
  113206. * The SharpenPostProcess applies a sharpen kernel to every pixel
  113207. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  113208. */
  113209. export class SharpenPostProcess extends PostProcess {
  113210. /**
  113211. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  113212. */
  113213. colorAmount: number;
  113214. /**
  113215. * How much sharpness should be applied (default: 0.3)
  113216. */
  113217. edgeAmount: number;
  113218. /**
  113219. * Creates a new instance ConvolutionPostProcess
  113220. * @param name The name of the effect.
  113221. * @param options The required width/height ratio to downsize to before computing the render pass.
  113222. * @param camera The camera to apply the render pass to.
  113223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113224. * @param engine The engine which the post process will be applied. (default: current engine)
  113225. * @param reusable If the post process can be reused on the same frame. (default: false)
  113226. * @param textureType Type of textures used when performing the post process. (default: 0)
  113227. * @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)
  113228. */
  113229. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113230. }
  113231. }
  113232. declare module BABYLON {
  113233. /**
  113234. * PostProcessRenderPipeline
  113235. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113236. */
  113237. export class PostProcessRenderPipeline {
  113238. private engine;
  113239. private _renderEffects;
  113240. private _renderEffectsForIsolatedPass;
  113241. /**
  113242. * List of inspectable custom properties (used by the Inspector)
  113243. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113244. */
  113245. inspectableCustomProperties: IInspectable[];
  113246. /**
  113247. * @hidden
  113248. */
  113249. protected _cameras: Camera[];
  113250. /** @hidden */
  113251. _name: string;
  113252. /**
  113253. * Gets pipeline name
  113254. */
  113255. readonly name: string;
  113256. /**
  113257. * Initializes a PostProcessRenderPipeline
  113258. * @param engine engine to add the pipeline to
  113259. * @param name name of the pipeline
  113260. */
  113261. constructor(engine: Engine, name: string);
  113262. /**
  113263. * Gets the class name
  113264. * @returns "PostProcessRenderPipeline"
  113265. */
  113266. getClassName(): string;
  113267. /**
  113268. * If all the render effects in the pipeline are supported
  113269. */
  113270. readonly isSupported: boolean;
  113271. /**
  113272. * Adds an effect to the pipeline
  113273. * @param renderEffect the effect to add
  113274. */
  113275. addEffect(renderEffect: PostProcessRenderEffect): void;
  113276. /** @hidden */
  113277. _rebuild(): void;
  113278. /** @hidden */
  113279. _enableEffect(renderEffectName: string, cameras: Camera): void;
  113280. /** @hidden */
  113281. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  113282. /** @hidden */
  113283. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113284. /** @hidden */
  113285. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113286. /** @hidden */
  113287. _attachCameras(cameras: Camera, unique: boolean): void;
  113288. /** @hidden */
  113289. _attachCameras(cameras: Camera[], unique: boolean): void;
  113290. /** @hidden */
  113291. _detachCameras(cameras: Camera): void;
  113292. /** @hidden */
  113293. _detachCameras(cameras: Nullable<Camera[]>): void;
  113294. /** @hidden */
  113295. _update(): void;
  113296. /** @hidden */
  113297. _reset(): void;
  113298. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  113299. /**
  113300. * Disposes of the pipeline
  113301. */
  113302. dispose(): void;
  113303. }
  113304. }
  113305. declare module BABYLON {
  113306. /**
  113307. * PostProcessRenderPipelineManager class
  113308. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113309. */
  113310. export class PostProcessRenderPipelineManager {
  113311. private _renderPipelines;
  113312. /**
  113313. * Initializes a PostProcessRenderPipelineManager
  113314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113315. */
  113316. constructor();
  113317. /**
  113318. * Gets the list of supported render pipelines
  113319. */
  113320. readonly supportedPipelines: PostProcessRenderPipeline[];
  113321. /**
  113322. * Adds a pipeline to the manager
  113323. * @param renderPipeline The pipeline to add
  113324. */
  113325. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  113326. /**
  113327. * Attaches a camera to the pipeline
  113328. * @param renderPipelineName The name of the pipeline to attach to
  113329. * @param cameras the camera to attach
  113330. * @param unique if the camera can be attached multiple times to the pipeline
  113331. */
  113332. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  113333. /**
  113334. * Detaches a camera from the pipeline
  113335. * @param renderPipelineName The name of the pipeline to detach from
  113336. * @param cameras the camera to detach
  113337. */
  113338. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  113339. /**
  113340. * Enables an effect by name on a pipeline
  113341. * @param renderPipelineName the name of the pipeline to enable the effect in
  113342. * @param renderEffectName the name of the effect to enable
  113343. * @param cameras the cameras that the effect should be enabled on
  113344. */
  113345. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113346. /**
  113347. * Disables an effect by name on a pipeline
  113348. * @param renderPipelineName the name of the pipeline to disable the effect in
  113349. * @param renderEffectName the name of the effect to disable
  113350. * @param cameras the cameras that the effect should be disabled on
  113351. */
  113352. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113353. /**
  113354. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  113355. */
  113356. update(): void;
  113357. /** @hidden */
  113358. _rebuild(): void;
  113359. /**
  113360. * Disposes of the manager and pipelines
  113361. */
  113362. dispose(): void;
  113363. }
  113364. }
  113365. declare module BABYLON {
  113366. interface Scene {
  113367. /** @hidden (Backing field) */
  113368. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113369. /**
  113370. * Gets the postprocess render pipeline manager
  113371. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113372. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113373. */
  113374. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113375. }
  113376. /**
  113377. * Defines the Render Pipeline scene component responsible to rendering pipelines
  113378. */
  113379. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  113380. /**
  113381. * The component name helpfull to identify the component in the list of scene components.
  113382. */
  113383. readonly name: string;
  113384. /**
  113385. * The scene the component belongs to.
  113386. */
  113387. scene: Scene;
  113388. /**
  113389. * Creates a new instance of the component for the given scene
  113390. * @param scene Defines the scene to register the component in
  113391. */
  113392. constructor(scene: Scene);
  113393. /**
  113394. * Registers the component in a given scene
  113395. */
  113396. register(): void;
  113397. /**
  113398. * Rebuilds the elements related to this component in case of
  113399. * context lost for instance.
  113400. */
  113401. rebuild(): void;
  113402. /**
  113403. * Disposes the component and the associated ressources
  113404. */
  113405. dispose(): void;
  113406. private _gatherRenderTargets;
  113407. }
  113408. }
  113409. declare module BABYLON {
  113410. /**
  113411. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113412. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113413. */
  113414. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113415. private _scene;
  113416. private _camerasToBeAttached;
  113417. /**
  113418. * ID of the sharpen post process,
  113419. */
  113420. private readonly SharpenPostProcessId;
  113421. /**
  113422. * @ignore
  113423. * ID of the image processing post process;
  113424. */
  113425. readonly ImageProcessingPostProcessId: string;
  113426. /**
  113427. * @ignore
  113428. * ID of the Fast Approximate Anti-Aliasing post process;
  113429. */
  113430. readonly FxaaPostProcessId: string;
  113431. /**
  113432. * ID of the chromatic aberration post process,
  113433. */
  113434. private readonly ChromaticAberrationPostProcessId;
  113435. /**
  113436. * ID of the grain post process
  113437. */
  113438. private readonly GrainPostProcessId;
  113439. /**
  113440. * Sharpen post process which will apply a sharpen convolution to enhance edges
  113441. */
  113442. sharpen: SharpenPostProcess;
  113443. private _sharpenEffect;
  113444. private bloom;
  113445. /**
  113446. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  113447. */
  113448. depthOfField: DepthOfFieldEffect;
  113449. /**
  113450. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113451. */
  113452. fxaa: FxaaPostProcess;
  113453. /**
  113454. * Image post processing pass used to perform operations such as tone mapping or color grading.
  113455. */
  113456. imageProcessing: ImageProcessingPostProcess;
  113457. /**
  113458. * Chromatic aberration post process which will shift rgb colors in the image
  113459. */
  113460. chromaticAberration: ChromaticAberrationPostProcess;
  113461. private _chromaticAberrationEffect;
  113462. /**
  113463. * Grain post process which add noise to the image
  113464. */
  113465. grain: GrainPostProcess;
  113466. private _grainEffect;
  113467. /**
  113468. * Glow post process which adds a glow to emissive areas of the image
  113469. */
  113470. private _glowLayer;
  113471. /**
  113472. * Animations which can be used to tweak settings over a period of time
  113473. */
  113474. animations: Animation[];
  113475. private _imageProcessingConfigurationObserver;
  113476. private _sharpenEnabled;
  113477. private _bloomEnabled;
  113478. private _depthOfFieldEnabled;
  113479. private _depthOfFieldBlurLevel;
  113480. private _fxaaEnabled;
  113481. private _imageProcessingEnabled;
  113482. private _defaultPipelineTextureType;
  113483. private _bloomScale;
  113484. private _chromaticAberrationEnabled;
  113485. private _grainEnabled;
  113486. private _buildAllowed;
  113487. /**
  113488. * Gets active scene
  113489. */
  113490. readonly scene: Scene;
  113491. /**
  113492. * Enable or disable the sharpen process from the pipeline
  113493. */
  113494. sharpenEnabled: boolean;
  113495. private _resizeObserver;
  113496. private _hardwareScaleLevel;
  113497. private _bloomKernel;
  113498. /**
  113499. * Specifies the size of the bloom blur kernel, relative to the final output size
  113500. */
  113501. bloomKernel: number;
  113502. /**
  113503. * Specifies the weight of the bloom in the final rendering
  113504. */
  113505. private _bloomWeight;
  113506. /**
  113507. * Specifies the luma threshold for the area that will be blurred by the bloom
  113508. */
  113509. private _bloomThreshold;
  113510. private _hdr;
  113511. /**
  113512. * The strength of the bloom.
  113513. */
  113514. bloomWeight: number;
  113515. /**
  113516. * The strength of the bloom.
  113517. */
  113518. bloomThreshold: number;
  113519. /**
  113520. * The scale of the bloom, lower value will provide better performance.
  113521. */
  113522. bloomScale: number;
  113523. /**
  113524. * Enable or disable the bloom from the pipeline
  113525. */
  113526. bloomEnabled: boolean;
  113527. private _rebuildBloom;
  113528. /**
  113529. * If the depth of field is enabled.
  113530. */
  113531. depthOfFieldEnabled: boolean;
  113532. /**
  113533. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113534. */
  113535. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  113536. /**
  113537. * If the anti aliasing is enabled.
  113538. */
  113539. fxaaEnabled: boolean;
  113540. private _samples;
  113541. /**
  113542. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113543. */
  113544. samples: number;
  113545. /**
  113546. * If image processing is enabled.
  113547. */
  113548. imageProcessingEnabled: boolean;
  113549. /**
  113550. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113551. */
  113552. glowLayerEnabled: boolean;
  113553. /**
  113554. * Gets the glow layer (or null if not defined)
  113555. */
  113556. readonly glowLayer: Nullable<GlowLayer>;
  113557. /**
  113558. * Enable or disable the chromaticAberration process from the pipeline
  113559. */
  113560. chromaticAberrationEnabled: boolean;
  113561. /**
  113562. * Enable or disable the grain process from the pipeline
  113563. */
  113564. grainEnabled: boolean;
  113565. /**
  113566. * @constructor
  113567. * @param name - The rendering pipeline name (default: "")
  113568. * @param hdr - If high dynamic range textures should be used (default: true)
  113569. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113570. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113571. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113572. */
  113573. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113574. /**
  113575. * Get the class name
  113576. * @returns "DefaultRenderingPipeline"
  113577. */
  113578. getClassName(): string;
  113579. /**
  113580. * Force the compilation of the entire pipeline.
  113581. */
  113582. prepare(): void;
  113583. private _hasCleared;
  113584. private _prevPostProcess;
  113585. private _prevPrevPostProcess;
  113586. private _setAutoClearAndTextureSharing;
  113587. private _depthOfFieldSceneObserver;
  113588. private _buildPipeline;
  113589. private _disposePostProcesses;
  113590. /**
  113591. * Adds a camera to the pipeline
  113592. * @param camera the camera to be added
  113593. */
  113594. addCamera(camera: Camera): void;
  113595. /**
  113596. * Removes a camera from the pipeline
  113597. * @param camera the camera to remove
  113598. */
  113599. removeCamera(camera: Camera): void;
  113600. /**
  113601. * Dispose of the pipeline and stop all post processes
  113602. */
  113603. dispose(): void;
  113604. /**
  113605. * Serialize the rendering pipeline (Used when exporting)
  113606. * @returns the serialized object
  113607. */
  113608. serialize(): any;
  113609. /**
  113610. * Parse the serialized pipeline
  113611. * @param source Source pipeline.
  113612. * @param scene The scene to load the pipeline to.
  113613. * @param rootUrl The URL of the serialized pipeline.
  113614. * @returns An instantiated pipeline from the serialized object.
  113615. */
  113616. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113617. }
  113618. }
  113619. declare module BABYLON {
  113620. /** @hidden */
  113621. export var lensHighlightsPixelShader: {
  113622. name: string;
  113623. shader: string;
  113624. };
  113625. }
  113626. declare module BABYLON {
  113627. /** @hidden */
  113628. export var depthOfFieldPixelShader: {
  113629. name: string;
  113630. shader: string;
  113631. };
  113632. }
  113633. declare module BABYLON {
  113634. /**
  113635. * BABYLON.JS Chromatic Aberration GLSL Shader
  113636. * Author: Olivier Guyot
  113637. * Separates very slightly R, G and B colors on the edges of the screen
  113638. * Inspired by Francois Tarlier & Martins Upitis
  113639. */
  113640. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113641. /**
  113642. * @ignore
  113643. * The chromatic aberration PostProcess id in the pipeline
  113644. */
  113645. LensChromaticAberrationEffect: string;
  113646. /**
  113647. * @ignore
  113648. * The highlights enhancing PostProcess id in the pipeline
  113649. */
  113650. HighlightsEnhancingEffect: string;
  113651. /**
  113652. * @ignore
  113653. * The depth-of-field PostProcess id in the pipeline
  113654. */
  113655. LensDepthOfFieldEffect: string;
  113656. private _scene;
  113657. private _depthTexture;
  113658. private _grainTexture;
  113659. private _chromaticAberrationPostProcess;
  113660. private _highlightsPostProcess;
  113661. private _depthOfFieldPostProcess;
  113662. private _edgeBlur;
  113663. private _grainAmount;
  113664. private _chromaticAberration;
  113665. private _distortion;
  113666. private _highlightsGain;
  113667. private _highlightsThreshold;
  113668. private _dofDistance;
  113669. private _dofAperture;
  113670. private _dofDarken;
  113671. private _dofPentagon;
  113672. private _blurNoise;
  113673. /**
  113674. * @constructor
  113675. *
  113676. * Effect parameters are as follow:
  113677. * {
  113678. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113679. * edge_blur: number; // from 0 to x (1 for realism)
  113680. * distortion: number; // from 0 to x (1 for realism)
  113681. * grain_amount: number; // from 0 to 1
  113682. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113683. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113684. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113685. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113686. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113687. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113688. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113689. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113690. * }
  113691. * Note: if an effect parameter is unset, effect is disabled
  113692. *
  113693. * @param name The rendering pipeline name
  113694. * @param parameters - An object containing all parameters (see above)
  113695. * @param scene The scene linked to this pipeline
  113696. * @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)
  113697. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113698. */
  113699. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113700. /**
  113701. * Get the class name
  113702. * @returns "LensRenderingPipeline"
  113703. */
  113704. getClassName(): string;
  113705. /**
  113706. * Gets associated scene
  113707. */
  113708. readonly scene: Scene;
  113709. /**
  113710. * Gets or sets the edge blur
  113711. */
  113712. edgeBlur: number;
  113713. /**
  113714. * Gets or sets the grain amount
  113715. */
  113716. grainAmount: number;
  113717. /**
  113718. * Gets or sets the chromatic aberration amount
  113719. */
  113720. chromaticAberration: number;
  113721. /**
  113722. * Gets or sets the depth of field aperture
  113723. */
  113724. dofAperture: number;
  113725. /**
  113726. * Gets or sets the edge distortion
  113727. */
  113728. edgeDistortion: number;
  113729. /**
  113730. * Gets or sets the depth of field distortion
  113731. */
  113732. dofDistortion: number;
  113733. /**
  113734. * Gets or sets the darken out of focus amount
  113735. */
  113736. darkenOutOfFocus: number;
  113737. /**
  113738. * Gets or sets a boolean indicating if blur noise is enabled
  113739. */
  113740. blurNoise: boolean;
  113741. /**
  113742. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113743. */
  113744. pentagonBokeh: boolean;
  113745. /**
  113746. * Gets or sets the highlight grain amount
  113747. */
  113748. highlightsGain: number;
  113749. /**
  113750. * Gets or sets the highlight threshold
  113751. */
  113752. highlightsThreshold: number;
  113753. /**
  113754. * Sets the amount of blur at the edges
  113755. * @param amount blur amount
  113756. */
  113757. setEdgeBlur(amount: number): void;
  113758. /**
  113759. * Sets edge blur to 0
  113760. */
  113761. disableEdgeBlur(): void;
  113762. /**
  113763. * Sets the amout of grain
  113764. * @param amount Amount of grain
  113765. */
  113766. setGrainAmount(amount: number): void;
  113767. /**
  113768. * Set grain amount to 0
  113769. */
  113770. disableGrain(): void;
  113771. /**
  113772. * Sets the chromatic aberration amount
  113773. * @param amount amount of chromatic aberration
  113774. */
  113775. setChromaticAberration(amount: number): void;
  113776. /**
  113777. * Sets chromatic aberration amount to 0
  113778. */
  113779. disableChromaticAberration(): void;
  113780. /**
  113781. * Sets the EdgeDistortion amount
  113782. * @param amount amount of EdgeDistortion
  113783. */
  113784. setEdgeDistortion(amount: number): void;
  113785. /**
  113786. * Sets edge distortion to 0
  113787. */
  113788. disableEdgeDistortion(): void;
  113789. /**
  113790. * Sets the FocusDistance amount
  113791. * @param amount amount of FocusDistance
  113792. */
  113793. setFocusDistance(amount: number): void;
  113794. /**
  113795. * Disables depth of field
  113796. */
  113797. disableDepthOfField(): void;
  113798. /**
  113799. * Sets the Aperture amount
  113800. * @param amount amount of Aperture
  113801. */
  113802. setAperture(amount: number): void;
  113803. /**
  113804. * Sets the DarkenOutOfFocus amount
  113805. * @param amount amount of DarkenOutOfFocus
  113806. */
  113807. setDarkenOutOfFocus(amount: number): void;
  113808. private _pentagonBokehIsEnabled;
  113809. /**
  113810. * Creates a pentagon bokeh effect
  113811. */
  113812. enablePentagonBokeh(): void;
  113813. /**
  113814. * Disables the pentagon bokeh effect
  113815. */
  113816. disablePentagonBokeh(): void;
  113817. /**
  113818. * Enables noise blur
  113819. */
  113820. enableNoiseBlur(): void;
  113821. /**
  113822. * Disables noise blur
  113823. */
  113824. disableNoiseBlur(): void;
  113825. /**
  113826. * Sets the HighlightsGain amount
  113827. * @param amount amount of HighlightsGain
  113828. */
  113829. setHighlightsGain(amount: number): void;
  113830. /**
  113831. * Sets the HighlightsThreshold amount
  113832. * @param amount amount of HighlightsThreshold
  113833. */
  113834. setHighlightsThreshold(amount: number): void;
  113835. /**
  113836. * Disables highlights
  113837. */
  113838. disableHighlights(): void;
  113839. /**
  113840. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113841. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113842. */
  113843. dispose(disableDepthRender?: boolean): void;
  113844. private _createChromaticAberrationPostProcess;
  113845. private _createHighlightsPostProcess;
  113846. private _createDepthOfFieldPostProcess;
  113847. private _createGrainTexture;
  113848. }
  113849. }
  113850. declare module BABYLON {
  113851. /** @hidden */
  113852. export var ssao2PixelShader: {
  113853. name: string;
  113854. shader: string;
  113855. };
  113856. }
  113857. declare module BABYLON {
  113858. /** @hidden */
  113859. export var ssaoCombinePixelShader: {
  113860. name: string;
  113861. shader: string;
  113862. };
  113863. }
  113864. declare module BABYLON {
  113865. /**
  113866. * Render pipeline to produce ssao effect
  113867. */
  113868. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  113869. /**
  113870. * @ignore
  113871. * The PassPostProcess id in the pipeline that contains the original scene color
  113872. */
  113873. SSAOOriginalSceneColorEffect: string;
  113874. /**
  113875. * @ignore
  113876. * The SSAO PostProcess id in the pipeline
  113877. */
  113878. SSAORenderEffect: string;
  113879. /**
  113880. * @ignore
  113881. * The horizontal blur PostProcess id in the pipeline
  113882. */
  113883. SSAOBlurHRenderEffect: string;
  113884. /**
  113885. * @ignore
  113886. * The vertical blur PostProcess id in the pipeline
  113887. */
  113888. SSAOBlurVRenderEffect: string;
  113889. /**
  113890. * @ignore
  113891. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113892. */
  113893. SSAOCombineRenderEffect: string;
  113894. /**
  113895. * The output strength of the SSAO post-process. Default value is 1.0.
  113896. */
  113897. totalStrength: number;
  113898. /**
  113899. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113900. */
  113901. maxZ: number;
  113902. /**
  113903. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113904. */
  113905. minZAspect: number;
  113906. private _samples;
  113907. /**
  113908. * Number of samples used for the SSAO calculations. Default value is 8
  113909. */
  113910. samples: number;
  113911. private _textureSamples;
  113912. /**
  113913. * Number of samples to use for antialiasing
  113914. */
  113915. textureSamples: number;
  113916. /**
  113917. * Ratio object used for SSAO ratio and blur ratio
  113918. */
  113919. private _ratio;
  113920. /**
  113921. * Dynamically generated sphere sampler.
  113922. */
  113923. private _sampleSphere;
  113924. /**
  113925. * Blur filter offsets
  113926. */
  113927. private _samplerOffsets;
  113928. private _expensiveBlur;
  113929. /**
  113930. * If bilateral blur should be used
  113931. */
  113932. expensiveBlur: boolean;
  113933. /**
  113934. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113935. */
  113936. radius: number;
  113937. /**
  113938. * The base color of the SSAO post-process
  113939. * The final result is "base + ssao" between [0, 1]
  113940. */
  113941. base: number;
  113942. /**
  113943. * Support test.
  113944. */
  113945. static readonly IsSupported: boolean;
  113946. private _scene;
  113947. private _depthTexture;
  113948. private _normalTexture;
  113949. private _randomTexture;
  113950. private _originalColorPostProcess;
  113951. private _ssaoPostProcess;
  113952. private _blurHPostProcess;
  113953. private _blurVPostProcess;
  113954. private _ssaoCombinePostProcess;
  113955. private _firstUpdate;
  113956. /**
  113957. * Gets active scene
  113958. */
  113959. readonly scene: Scene;
  113960. /**
  113961. * @constructor
  113962. * @param name The rendering pipeline name
  113963. * @param scene The scene linked to this pipeline
  113964. * @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 }
  113965. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113966. */
  113967. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113968. /**
  113969. * Get the class name
  113970. * @returns "SSAO2RenderingPipeline"
  113971. */
  113972. getClassName(): string;
  113973. /**
  113974. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113975. */
  113976. dispose(disableGeometryBufferRenderer?: boolean): void;
  113977. private _createBlurPostProcess;
  113978. /** @hidden */
  113979. _rebuild(): void;
  113980. private _bits;
  113981. private _radicalInverse_VdC;
  113982. private _hammersley;
  113983. private _hemisphereSample_uniform;
  113984. private _generateHemisphere;
  113985. private _createSSAOPostProcess;
  113986. private _createSSAOCombinePostProcess;
  113987. private _createRandomTexture;
  113988. /**
  113989. * Serialize the rendering pipeline (Used when exporting)
  113990. * @returns the serialized object
  113991. */
  113992. serialize(): any;
  113993. /**
  113994. * Parse the serialized pipeline
  113995. * @param source Source pipeline.
  113996. * @param scene The scene to load the pipeline to.
  113997. * @param rootUrl The URL of the serialized pipeline.
  113998. * @returns An instantiated pipeline from the serialized object.
  113999. */
  114000. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  114001. }
  114002. }
  114003. declare module BABYLON {
  114004. /** @hidden */
  114005. export var ssaoPixelShader: {
  114006. name: string;
  114007. shader: string;
  114008. };
  114009. }
  114010. declare module BABYLON {
  114011. /**
  114012. * Render pipeline to produce ssao effect
  114013. */
  114014. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  114015. /**
  114016. * @ignore
  114017. * The PassPostProcess id in the pipeline that contains the original scene color
  114018. */
  114019. SSAOOriginalSceneColorEffect: string;
  114020. /**
  114021. * @ignore
  114022. * The SSAO PostProcess id in the pipeline
  114023. */
  114024. SSAORenderEffect: string;
  114025. /**
  114026. * @ignore
  114027. * The horizontal blur PostProcess id in the pipeline
  114028. */
  114029. SSAOBlurHRenderEffect: string;
  114030. /**
  114031. * @ignore
  114032. * The vertical blur PostProcess id in the pipeline
  114033. */
  114034. SSAOBlurVRenderEffect: string;
  114035. /**
  114036. * @ignore
  114037. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114038. */
  114039. SSAOCombineRenderEffect: string;
  114040. /**
  114041. * The output strength of the SSAO post-process. Default value is 1.0.
  114042. */
  114043. totalStrength: number;
  114044. /**
  114045. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114046. */
  114047. radius: number;
  114048. /**
  114049. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114050. * Must not be equal to fallOff and superior to fallOff.
  114051. * Default value is 0.0075
  114052. */
  114053. area: number;
  114054. /**
  114055. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114056. * Must not be equal to area and inferior to area.
  114057. * Default value is 0.000001
  114058. */
  114059. fallOff: number;
  114060. /**
  114061. * The base color of the SSAO post-process
  114062. * The final result is "base + ssao" between [0, 1]
  114063. */
  114064. base: number;
  114065. private _scene;
  114066. private _depthTexture;
  114067. private _randomTexture;
  114068. private _originalColorPostProcess;
  114069. private _ssaoPostProcess;
  114070. private _blurHPostProcess;
  114071. private _blurVPostProcess;
  114072. private _ssaoCombinePostProcess;
  114073. private _firstUpdate;
  114074. /**
  114075. * Gets active scene
  114076. */
  114077. readonly scene: Scene;
  114078. /**
  114079. * @constructor
  114080. * @param name - The rendering pipeline name
  114081. * @param scene - The scene linked to this pipeline
  114082. * @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 }
  114083. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114084. */
  114085. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114086. /**
  114087. * Get the class name
  114088. * @returns "SSAORenderingPipeline"
  114089. */
  114090. getClassName(): string;
  114091. /**
  114092. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114093. */
  114094. dispose(disableDepthRender?: boolean): void;
  114095. private _createBlurPostProcess;
  114096. /** @hidden */
  114097. _rebuild(): void;
  114098. private _createSSAOPostProcess;
  114099. private _createSSAOCombinePostProcess;
  114100. private _createRandomTexture;
  114101. }
  114102. }
  114103. declare module BABYLON {
  114104. /** @hidden */
  114105. export var standardPixelShader: {
  114106. name: string;
  114107. shader: string;
  114108. };
  114109. }
  114110. declare module BABYLON {
  114111. /**
  114112. * Standard rendering pipeline
  114113. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114114. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114115. */
  114116. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  114117. /**
  114118. * Public members
  114119. */
  114120. /**
  114121. * Post-process which contains the original scene color before the pipeline applies all the effects
  114122. */
  114123. originalPostProcess: Nullable<PostProcess>;
  114124. /**
  114125. * Post-process used to down scale an image x4
  114126. */
  114127. downSampleX4PostProcess: Nullable<PostProcess>;
  114128. /**
  114129. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114130. */
  114131. brightPassPostProcess: Nullable<PostProcess>;
  114132. /**
  114133. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114134. */
  114135. blurHPostProcesses: PostProcess[];
  114136. /**
  114137. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114138. */
  114139. blurVPostProcesses: PostProcess[];
  114140. /**
  114141. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114142. */
  114143. textureAdderPostProcess: Nullable<PostProcess>;
  114144. /**
  114145. * Post-process used to create volumetric lighting effect
  114146. */
  114147. volumetricLightPostProcess: Nullable<PostProcess>;
  114148. /**
  114149. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114150. */
  114151. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  114152. /**
  114153. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114154. */
  114155. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  114156. /**
  114157. * Post-process used to merge the volumetric light effect and the real scene color
  114158. */
  114159. volumetricLightMergePostProces: Nullable<PostProcess>;
  114160. /**
  114161. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114162. */
  114163. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  114164. /**
  114165. * Base post-process used to calculate the average luminance of the final image for HDR
  114166. */
  114167. luminancePostProcess: Nullable<PostProcess>;
  114168. /**
  114169. * Post-processes used to create down sample post-processes in order to get
  114170. * the average luminance of the final image for HDR
  114171. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114172. */
  114173. luminanceDownSamplePostProcesses: PostProcess[];
  114174. /**
  114175. * Post-process used to create a HDR effect (light adaptation)
  114176. */
  114177. hdrPostProcess: Nullable<PostProcess>;
  114178. /**
  114179. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114180. */
  114181. textureAdderFinalPostProcess: Nullable<PostProcess>;
  114182. /**
  114183. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114184. */
  114185. lensFlareFinalPostProcess: Nullable<PostProcess>;
  114186. /**
  114187. * Post-process used to merge the final HDR post-process and the real scene color
  114188. */
  114189. hdrFinalPostProcess: Nullable<PostProcess>;
  114190. /**
  114191. * Post-process used to create a lens flare effect
  114192. */
  114193. lensFlarePostProcess: Nullable<PostProcess>;
  114194. /**
  114195. * Post-process that merges the result of the lens flare post-process and the real scene color
  114196. */
  114197. lensFlareComposePostProcess: Nullable<PostProcess>;
  114198. /**
  114199. * Post-process used to create a motion blur effect
  114200. */
  114201. motionBlurPostProcess: Nullable<PostProcess>;
  114202. /**
  114203. * Post-process used to create a depth of field effect
  114204. */
  114205. depthOfFieldPostProcess: Nullable<PostProcess>;
  114206. /**
  114207. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114208. */
  114209. fxaaPostProcess: Nullable<FxaaPostProcess>;
  114210. /**
  114211. * Represents the brightness threshold in order to configure the illuminated surfaces
  114212. */
  114213. brightThreshold: number;
  114214. /**
  114215. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114216. */
  114217. blurWidth: number;
  114218. /**
  114219. * Sets if the blur for highlighted surfaces must be only horizontal
  114220. */
  114221. horizontalBlur: boolean;
  114222. /**
  114223. * Gets the overall exposure used by the pipeline
  114224. */
  114225. /**
  114226. * Sets the overall exposure used by the pipeline
  114227. */
  114228. exposure: number;
  114229. /**
  114230. * Texture used typically to simulate "dirty" on camera lens
  114231. */
  114232. lensTexture: Nullable<Texture>;
  114233. /**
  114234. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114235. */
  114236. volumetricLightCoefficient: number;
  114237. /**
  114238. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114239. */
  114240. volumetricLightPower: number;
  114241. /**
  114242. * Used the set the blur intensity to smooth the volumetric lights
  114243. */
  114244. volumetricLightBlurScale: number;
  114245. /**
  114246. * Light (spot or directional) used to generate the volumetric lights rays
  114247. * The source light must have a shadow generate so the pipeline can get its
  114248. * depth map
  114249. */
  114250. sourceLight: Nullable<SpotLight | DirectionalLight>;
  114251. /**
  114252. * For eye adaptation, represents the minimum luminance the eye can see
  114253. */
  114254. hdrMinimumLuminance: number;
  114255. /**
  114256. * For eye adaptation, represents the decrease luminance speed
  114257. */
  114258. hdrDecreaseRate: number;
  114259. /**
  114260. * For eye adaptation, represents the increase luminance speed
  114261. */
  114262. hdrIncreaseRate: number;
  114263. /**
  114264. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114265. */
  114266. /**
  114267. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114268. */
  114269. hdrAutoExposure: boolean;
  114270. /**
  114271. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114272. */
  114273. lensColorTexture: Nullable<Texture>;
  114274. /**
  114275. * The overall strengh for the lens flare effect
  114276. */
  114277. lensFlareStrength: number;
  114278. /**
  114279. * Dispersion coefficient for lens flare ghosts
  114280. */
  114281. lensFlareGhostDispersal: number;
  114282. /**
  114283. * Main lens flare halo width
  114284. */
  114285. lensFlareHaloWidth: number;
  114286. /**
  114287. * Based on the lens distortion effect, defines how much the lens flare result
  114288. * is distorted
  114289. */
  114290. lensFlareDistortionStrength: number;
  114291. /**
  114292. * Lens star texture must be used to simulate rays on the flares and is available
  114293. * in the documentation
  114294. */
  114295. lensStarTexture: Nullable<Texture>;
  114296. /**
  114297. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114298. * flare effect by taking account of the dirt texture
  114299. */
  114300. lensFlareDirtTexture: Nullable<Texture>;
  114301. /**
  114302. * Represents the focal length for the depth of field effect
  114303. */
  114304. depthOfFieldDistance: number;
  114305. /**
  114306. * Represents the blur intensity for the blurred part of the depth of field effect
  114307. */
  114308. depthOfFieldBlurWidth: number;
  114309. /**
  114310. * For motion blur, defines how much the image is blurred by the movement
  114311. */
  114312. motionStrength: number;
  114313. /**
  114314. * List of animations for the pipeline (IAnimatable implementation)
  114315. */
  114316. animations: Animation[];
  114317. /**
  114318. * Private members
  114319. */
  114320. private _scene;
  114321. private _currentDepthOfFieldSource;
  114322. private _basePostProcess;
  114323. private _fixedExposure;
  114324. private _currentExposure;
  114325. private _hdrAutoExposure;
  114326. private _hdrCurrentLuminance;
  114327. private _floatTextureType;
  114328. private _ratio;
  114329. private _bloomEnabled;
  114330. private _depthOfFieldEnabled;
  114331. private _vlsEnabled;
  114332. private _lensFlareEnabled;
  114333. private _hdrEnabled;
  114334. private _motionBlurEnabled;
  114335. private _fxaaEnabled;
  114336. private _motionBlurSamples;
  114337. private _volumetricLightStepsCount;
  114338. private _samples;
  114339. /**
  114340. * @ignore
  114341. * Specifies if the bloom pipeline is enabled
  114342. */
  114343. BloomEnabled: boolean;
  114344. /**
  114345. * @ignore
  114346. * Specifies if the depth of field pipeline is enabed
  114347. */
  114348. DepthOfFieldEnabled: boolean;
  114349. /**
  114350. * @ignore
  114351. * Specifies if the lens flare pipeline is enabed
  114352. */
  114353. LensFlareEnabled: boolean;
  114354. /**
  114355. * @ignore
  114356. * Specifies if the HDR pipeline is enabled
  114357. */
  114358. HDREnabled: boolean;
  114359. /**
  114360. * @ignore
  114361. * Specifies if the volumetric lights scattering effect is enabled
  114362. */
  114363. VLSEnabled: boolean;
  114364. /**
  114365. * @ignore
  114366. * Specifies if the motion blur effect is enabled
  114367. */
  114368. MotionBlurEnabled: boolean;
  114369. /**
  114370. * Specifies if anti-aliasing is enabled
  114371. */
  114372. fxaaEnabled: boolean;
  114373. /**
  114374. * Specifies the number of steps used to calculate the volumetric lights
  114375. * Typically in interval [50, 200]
  114376. */
  114377. volumetricLightStepsCount: number;
  114378. /**
  114379. * Specifies the number of samples used for the motion blur effect
  114380. * Typically in interval [16, 64]
  114381. */
  114382. motionBlurSamples: number;
  114383. /**
  114384. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114385. */
  114386. samples: number;
  114387. /**
  114388. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114389. * @constructor
  114390. * @param name The rendering pipeline name
  114391. * @param scene The scene linked to this pipeline
  114392. * @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)
  114393. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114394. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114395. */
  114396. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  114397. private _buildPipeline;
  114398. private _createDownSampleX4PostProcess;
  114399. private _createBrightPassPostProcess;
  114400. private _createBlurPostProcesses;
  114401. private _createTextureAdderPostProcess;
  114402. private _createVolumetricLightPostProcess;
  114403. private _createLuminancePostProcesses;
  114404. private _createHdrPostProcess;
  114405. private _createLensFlarePostProcess;
  114406. private _createDepthOfFieldPostProcess;
  114407. private _createMotionBlurPostProcess;
  114408. private _getDepthTexture;
  114409. private _disposePostProcesses;
  114410. /**
  114411. * Dispose of the pipeline and stop all post processes
  114412. */
  114413. dispose(): void;
  114414. /**
  114415. * Serialize the rendering pipeline (Used when exporting)
  114416. * @returns the serialized object
  114417. */
  114418. serialize(): any;
  114419. /**
  114420. * Parse the serialized pipeline
  114421. * @param source Source pipeline.
  114422. * @param scene The scene to load the pipeline to.
  114423. * @param rootUrl The URL of the serialized pipeline.
  114424. * @returns An instantiated pipeline from the serialized object.
  114425. */
  114426. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  114427. /**
  114428. * Luminance steps
  114429. */
  114430. static LuminanceSteps: number;
  114431. }
  114432. }
  114433. declare module BABYLON {
  114434. /** @hidden */
  114435. export var tonemapPixelShader: {
  114436. name: string;
  114437. shader: string;
  114438. };
  114439. }
  114440. declare module BABYLON {
  114441. /** Defines operator used for tonemapping */
  114442. export enum TonemappingOperator {
  114443. /** Hable */
  114444. Hable = 0,
  114445. /** Reinhard */
  114446. Reinhard = 1,
  114447. /** HejiDawson */
  114448. HejiDawson = 2,
  114449. /** Photographic */
  114450. Photographic = 3
  114451. }
  114452. /**
  114453. * Defines a post process to apply tone mapping
  114454. */
  114455. export class TonemapPostProcess extends PostProcess {
  114456. private _operator;
  114457. /** Defines the required exposure adjustement */
  114458. exposureAdjustment: number;
  114459. /**
  114460. * Creates a new TonemapPostProcess
  114461. * @param name defines the name of the postprocess
  114462. * @param _operator defines the operator to use
  114463. * @param exposureAdjustment defines the required exposure adjustement
  114464. * @param camera defines the camera to use (can be null)
  114465. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  114466. * @param engine defines the hosting engine (can be ignore if camera is set)
  114467. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114468. */
  114469. constructor(name: string, _operator: TonemappingOperator,
  114470. /** Defines the required exposure adjustement */
  114471. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  114472. }
  114473. }
  114474. declare module BABYLON {
  114475. /** @hidden */
  114476. export var depthVertexShader: {
  114477. name: string;
  114478. shader: string;
  114479. };
  114480. }
  114481. declare module BABYLON {
  114482. /** @hidden */
  114483. export var volumetricLightScatteringPixelShader: {
  114484. name: string;
  114485. shader: string;
  114486. };
  114487. }
  114488. declare module BABYLON {
  114489. /** @hidden */
  114490. export var volumetricLightScatteringPassPixelShader: {
  114491. name: string;
  114492. shader: string;
  114493. };
  114494. }
  114495. declare module BABYLON {
  114496. /**
  114497. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  114498. */
  114499. export class VolumetricLightScatteringPostProcess extends PostProcess {
  114500. private _volumetricLightScatteringPass;
  114501. private _volumetricLightScatteringRTT;
  114502. private _viewPort;
  114503. private _screenCoordinates;
  114504. private _cachedDefines;
  114505. /**
  114506. * If not undefined, the mesh position is computed from the attached node position
  114507. */
  114508. attachedNode: {
  114509. position: Vector3;
  114510. };
  114511. /**
  114512. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  114513. */
  114514. customMeshPosition: Vector3;
  114515. /**
  114516. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  114517. */
  114518. useCustomMeshPosition: boolean;
  114519. /**
  114520. * If the post-process should inverse the light scattering direction
  114521. */
  114522. invert: boolean;
  114523. /**
  114524. * The internal mesh used by the post-process
  114525. */
  114526. mesh: Mesh;
  114527. /**
  114528. * @hidden
  114529. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  114530. */
  114531. useDiffuseColor: boolean;
  114532. /**
  114533. * Array containing the excluded meshes not rendered in the internal pass
  114534. */
  114535. excludedMeshes: AbstractMesh[];
  114536. /**
  114537. * Controls the overall intensity of the post-process
  114538. */
  114539. exposure: number;
  114540. /**
  114541. * Dissipates each sample's contribution in range [0, 1]
  114542. */
  114543. decay: number;
  114544. /**
  114545. * Controls the overall intensity of each sample
  114546. */
  114547. weight: number;
  114548. /**
  114549. * Controls the density of each sample
  114550. */
  114551. density: number;
  114552. /**
  114553. * @constructor
  114554. * @param name The post-process name
  114555. * @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)
  114556. * @param camera The camera that the post-process will be attached to
  114557. * @param mesh The mesh used to create the light scattering
  114558. * @param samples The post-process quality, default 100
  114559. * @param samplingModeThe post-process filtering mode
  114560. * @param engine The babylon engine
  114561. * @param reusable If the post-process is reusable
  114562. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114563. */
  114564. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114565. /**
  114566. * Returns the string "VolumetricLightScatteringPostProcess"
  114567. * @returns "VolumetricLightScatteringPostProcess"
  114568. */
  114569. getClassName(): string;
  114570. private _isReady;
  114571. /**
  114572. * Sets the new light position for light scattering effect
  114573. * @param position The new custom light position
  114574. */
  114575. setCustomMeshPosition(position: Vector3): void;
  114576. /**
  114577. * Returns the light position for light scattering effect
  114578. * @return Vector3 The custom light position
  114579. */
  114580. getCustomMeshPosition(): Vector3;
  114581. /**
  114582. * Disposes the internal assets and detaches the post-process from the camera
  114583. */
  114584. dispose(camera: Camera): void;
  114585. /**
  114586. * Returns the render target texture used by the post-process
  114587. * @return the render target texture used by the post-process
  114588. */
  114589. getPass(): RenderTargetTexture;
  114590. private _meshExcluded;
  114591. private _createPass;
  114592. private _updateMeshScreenCoordinates;
  114593. /**
  114594. * Creates a default mesh for the Volumeric Light Scattering post-process
  114595. * @param name The mesh name
  114596. * @param scene The scene where to create the mesh
  114597. * @return the default mesh
  114598. */
  114599. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114600. }
  114601. }
  114602. declare module BABYLON {
  114603. interface Scene {
  114604. /** @hidden (Backing field) */
  114605. _boundingBoxRenderer: BoundingBoxRenderer;
  114606. /** @hidden (Backing field) */
  114607. _forceShowBoundingBoxes: boolean;
  114608. /**
  114609. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114610. */
  114611. forceShowBoundingBoxes: boolean;
  114612. /**
  114613. * Gets the bounding box renderer associated with the scene
  114614. * @returns a BoundingBoxRenderer
  114615. */
  114616. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114617. }
  114618. interface AbstractMesh {
  114619. /** @hidden (Backing field) */
  114620. _showBoundingBox: boolean;
  114621. /**
  114622. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114623. */
  114624. showBoundingBox: boolean;
  114625. }
  114626. /**
  114627. * Component responsible of rendering the bounding box of the meshes in a scene.
  114628. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114629. */
  114630. export class BoundingBoxRenderer implements ISceneComponent {
  114631. /**
  114632. * The component name helpfull to identify the component in the list of scene components.
  114633. */
  114634. readonly name: string;
  114635. /**
  114636. * The scene the component belongs to.
  114637. */
  114638. scene: Scene;
  114639. /**
  114640. * Color of the bounding box lines placed in front of an object
  114641. */
  114642. frontColor: Color3;
  114643. /**
  114644. * Color of the bounding box lines placed behind an object
  114645. */
  114646. backColor: Color3;
  114647. /**
  114648. * Defines if the renderer should show the back lines or not
  114649. */
  114650. showBackLines: boolean;
  114651. /**
  114652. * @hidden
  114653. */
  114654. renderList: SmartArray<BoundingBox>;
  114655. private _colorShader;
  114656. private _vertexBuffers;
  114657. private _indexBuffer;
  114658. /**
  114659. * Instantiates a new bounding box renderer in a scene.
  114660. * @param scene the scene the renderer renders in
  114661. */
  114662. constructor(scene: Scene);
  114663. /**
  114664. * Registers the component in a given scene
  114665. */
  114666. register(): void;
  114667. private _evaluateSubMesh;
  114668. private _activeMesh;
  114669. private _prepareRessources;
  114670. private _createIndexBuffer;
  114671. /**
  114672. * Rebuilds the elements related to this component in case of
  114673. * context lost for instance.
  114674. */
  114675. rebuild(): void;
  114676. /**
  114677. * @hidden
  114678. */
  114679. reset(): void;
  114680. /**
  114681. * Render the bounding boxes of a specific rendering group
  114682. * @param renderingGroupId defines the rendering group to render
  114683. */
  114684. render(renderingGroupId: number): void;
  114685. /**
  114686. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114687. * @param mesh Define the mesh to render the occlusion bounding box for
  114688. */
  114689. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114690. /**
  114691. * Dispose and release the resources attached to this renderer.
  114692. */
  114693. dispose(): void;
  114694. }
  114695. }
  114696. declare module BABYLON {
  114697. /** @hidden */
  114698. export var depthPixelShader: {
  114699. name: string;
  114700. shader: string;
  114701. };
  114702. }
  114703. declare module BABYLON {
  114704. /**
  114705. * This represents a depth renderer in Babylon.
  114706. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114707. */
  114708. export class DepthRenderer {
  114709. private _scene;
  114710. private _depthMap;
  114711. private _effect;
  114712. private _cachedDefines;
  114713. private _camera;
  114714. /**
  114715. * Specifiess that the depth renderer will only be used within
  114716. * the camera it is created for.
  114717. * This can help forcing its rendering during the camera processing.
  114718. */
  114719. useOnlyInActiveCamera: boolean;
  114720. /** @hidden */
  114721. static _SceneComponentInitialization: (scene: Scene) => void;
  114722. /**
  114723. * Instantiates a depth renderer
  114724. * @param scene The scene the renderer belongs to
  114725. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114726. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114727. */
  114728. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114729. /**
  114730. * Creates the depth rendering effect and checks if the effect is ready.
  114731. * @param subMesh The submesh to be used to render the depth map of
  114732. * @param useInstances If multiple world instances should be used
  114733. * @returns if the depth renderer is ready to render the depth map
  114734. */
  114735. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114736. /**
  114737. * Gets the texture which the depth map will be written to.
  114738. * @returns The depth map texture
  114739. */
  114740. getDepthMap(): RenderTargetTexture;
  114741. /**
  114742. * Disposes of the depth renderer.
  114743. */
  114744. dispose(): void;
  114745. }
  114746. }
  114747. declare module BABYLON {
  114748. interface Scene {
  114749. /** @hidden (Backing field) */
  114750. _depthRenderer: {
  114751. [id: string]: DepthRenderer;
  114752. };
  114753. /**
  114754. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114755. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114756. * @returns the created depth renderer
  114757. */
  114758. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114759. /**
  114760. * Disables a depth renderer for a given camera
  114761. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114762. */
  114763. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114764. }
  114765. /**
  114766. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114767. * in several rendering techniques.
  114768. */
  114769. export class DepthRendererSceneComponent implements ISceneComponent {
  114770. /**
  114771. * The component name helpfull to identify the component in the list of scene components.
  114772. */
  114773. readonly name: string;
  114774. /**
  114775. * The scene the component belongs to.
  114776. */
  114777. scene: Scene;
  114778. /**
  114779. * Creates a new instance of the component for the given scene
  114780. * @param scene Defines the scene to register the component in
  114781. */
  114782. constructor(scene: Scene);
  114783. /**
  114784. * Registers the component in a given scene
  114785. */
  114786. register(): void;
  114787. /**
  114788. * Rebuilds the elements related to this component in case of
  114789. * context lost for instance.
  114790. */
  114791. rebuild(): void;
  114792. /**
  114793. * Disposes the component and the associated ressources
  114794. */
  114795. dispose(): void;
  114796. private _gatherRenderTargets;
  114797. private _gatherActiveCameraRenderTargets;
  114798. }
  114799. }
  114800. declare module BABYLON {
  114801. /** @hidden */
  114802. export var outlinePixelShader: {
  114803. name: string;
  114804. shader: string;
  114805. };
  114806. }
  114807. declare module BABYLON {
  114808. /** @hidden */
  114809. export var outlineVertexShader: {
  114810. name: string;
  114811. shader: string;
  114812. };
  114813. }
  114814. declare module BABYLON {
  114815. interface Scene {
  114816. /** @hidden */
  114817. _outlineRenderer: OutlineRenderer;
  114818. /**
  114819. * Gets the outline renderer associated with the scene
  114820. * @returns a OutlineRenderer
  114821. */
  114822. getOutlineRenderer(): OutlineRenderer;
  114823. }
  114824. interface AbstractMesh {
  114825. /** @hidden (Backing field) */
  114826. _renderOutline: boolean;
  114827. /**
  114828. * Gets or sets a boolean indicating if the outline must be rendered as well
  114829. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  114830. */
  114831. renderOutline: boolean;
  114832. /** @hidden (Backing field) */
  114833. _renderOverlay: boolean;
  114834. /**
  114835. * Gets or sets a boolean indicating if the overlay must be rendered as well
  114836. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  114837. */
  114838. renderOverlay: boolean;
  114839. }
  114840. /**
  114841. * This class is responsible to draw bothe outline/overlay of meshes.
  114842. * It should not be used directly but through the available method on mesh.
  114843. */
  114844. export class OutlineRenderer implements ISceneComponent {
  114845. /**
  114846. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  114847. */
  114848. private static _StencilReference;
  114849. /**
  114850. * The name of the component. Each component must have a unique name.
  114851. */
  114852. name: string;
  114853. /**
  114854. * The scene the component belongs to.
  114855. */
  114856. scene: Scene;
  114857. /**
  114858. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  114859. */
  114860. zOffset: number;
  114861. private _engine;
  114862. private _effect;
  114863. private _cachedDefines;
  114864. private _savedDepthWrite;
  114865. /**
  114866. * Instantiates a new outline renderer. (There could be only one per scene).
  114867. * @param scene Defines the scene it belongs to
  114868. */
  114869. constructor(scene: Scene);
  114870. /**
  114871. * Register the component to one instance of a scene.
  114872. */
  114873. register(): void;
  114874. /**
  114875. * Rebuilds the elements related to this component in case of
  114876. * context lost for instance.
  114877. */
  114878. rebuild(): void;
  114879. /**
  114880. * Disposes the component and the associated ressources.
  114881. */
  114882. dispose(): void;
  114883. /**
  114884. * Renders the outline in the canvas.
  114885. * @param subMesh Defines the sumesh to render
  114886. * @param batch Defines the batch of meshes in case of instances
  114887. * @param useOverlay Defines if the rendering is for the overlay or the outline
  114888. */
  114889. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  114890. /**
  114891. * Returns whether or not the outline renderer is ready for a given submesh.
  114892. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  114893. * @param subMesh Defines the submesh to check readyness for
  114894. * @param useInstances Defines wheter wee are trying to render instances or not
  114895. * @returns true if ready otherwise false
  114896. */
  114897. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114898. private _beforeRenderingMesh;
  114899. private _afterRenderingMesh;
  114900. }
  114901. }
  114902. declare module BABYLON {
  114903. /**
  114904. * Defines the list of states available for a task inside a AssetsManager
  114905. */
  114906. export enum AssetTaskState {
  114907. /**
  114908. * Initialization
  114909. */
  114910. INIT = 0,
  114911. /**
  114912. * Running
  114913. */
  114914. RUNNING = 1,
  114915. /**
  114916. * Done
  114917. */
  114918. DONE = 2,
  114919. /**
  114920. * Error
  114921. */
  114922. ERROR = 3
  114923. }
  114924. /**
  114925. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  114926. */
  114927. export abstract class AbstractAssetTask {
  114928. /**
  114929. * Task name
  114930. */ name: string;
  114931. /**
  114932. * Callback called when the task is successful
  114933. */
  114934. onSuccess: (task: any) => void;
  114935. /**
  114936. * Callback called when the task is not successful
  114937. */
  114938. onError: (task: any, message?: string, exception?: any) => void;
  114939. /**
  114940. * Creates a new AssetsManager
  114941. * @param name defines the name of the task
  114942. */
  114943. constructor(
  114944. /**
  114945. * Task name
  114946. */ name: string);
  114947. private _isCompleted;
  114948. private _taskState;
  114949. private _errorObject;
  114950. /**
  114951. * Get if the task is completed
  114952. */
  114953. readonly isCompleted: boolean;
  114954. /**
  114955. * Gets the current state of the task
  114956. */
  114957. readonly taskState: AssetTaskState;
  114958. /**
  114959. * Gets the current error object (if task is in error)
  114960. */
  114961. readonly errorObject: {
  114962. message?: string;
  114963. exception?: any;
  114964. };
  114965. /**
  114966. * Internal only
  114967. * @hidden
  114968. */
  114969. _setErrorObject(message?: string, exception?: any): void;
  114970. /**
  114971. * Execute the current task
  114972. * @param scene defines the scene where you want your assets to be loaded
  114973. * @param onSuccess is a callback called when the task is successfully executed
  114974. * @param onError is a callback called if an error occurs
  114975. */
  114976. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114977. /**
  114978. * Execute the current task
  114979. * @param scene defines the scene where you want your assets to be loaded
  114980. * @param onSuccess is a callback called when the task is successfully executed
  114981. * @param onError is a callback called if an error occurs
  114982. */
  114983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114984. /**
  114985. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114986. * This can be used with failed tasks that have the reason for failure fixed.
  114987. */
  114988. reset(): void;
  114989. private onErrorCallback;
  114990. private onDoneCallback;
  114991. }
  114992. /**
  114993. * Define the interface used by progress events raised during assets loading
  114994. */
  114995. export interface IAssetsProgressEvent {
  114996. /**
  114997. * Defines the number of remaining tasks to process
  114998. */
  114999. remainingCount: number;
  115000. /**
  115001. * Defines the total number of tasks
  115002. */
  115003. totalCount: number;
  115004. /**
  115005. * Defines the task that was just processed
  115006. */
  115007. task: AbstractAssetTask;
  115008. }
  115009. /**
  115010. * Class used to share progress information about assets loading
  115011. */
  115012. export class AssetsProgressEvent implements IAssetsProgressEvent {
  115013. /**
  115014. * Defines the number of remaining tasks to process
  115015. */
  115016. remainingCount: number;
  115017. /**
  115018. * Defines the total number of tasks
  115019. */
  115020. totalCount: number;
  115021. /**
  115022. * Defines the task that was just processed
  115023. */
  115024. task: AbstractAssetTask;
  115025. /**
  115026. * Creates a AssetsProgressEvent
  115027. * @param remainingCount defines the number of remaining tasks to process
  115028. * @param totalCount defines the total number of tasks
  115029. * @param task defines the task that was just processed
  115030. */
  115031. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  115032. }
  115033. /**
  115034. * Define a task used by AssetsManager to load meshes
  115035. */
  115036. export class MeshAssetTask extends AbstractAssetTask {
  115037. /**
  115038. * Defines the name of the task
  115039. */
  115040. name: string;
  115041. /**
  115042. * Defines the list of mesh's names you want to load
  115043. */
  115044. meshesNames: any;
  115045. /**
  115046. * Defines the root url to use as a base to load your meshes and associated resources
  115047. */
  115048. rootUrl: string;
  115049. /**
  115050. * Defines the filename of the scene to load from
  115051. */
  115052. sceneFilename: string;
  115053. /**
  115054. * Gets the list of loaded meshes
  115055. */
  115056. loadedMeshes: Array<AbstractMesh>;
  115057. /**
  115058. * Gets the list of loaded particle systems
  115059. */
  115060. loadedParticleSystems: Array<IParticleSystem>;
  115061. /**
  115062. * Gets the list of loaded skeletons
  115063. */
  115064. loadedSkeletons: Array<Skeleton>;
  115065. /**
  115066. * Gets the list of loaded animation groups
  115067. */
  115068. loadedAnimationGroups: Array<AnimationGroup>;
  115069. /**
  115070. * Callback called when the task is successful
  115071. */
  115072. onSuccess: (task: MeshAssetTask) => void;
  115073. /**
  115074. * Callback called when the task is successful
  115075. */
  115076. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  115077. /**
  115078. * Creates a new MeshAssetTask
  115079. * @param name defines the name of the task
  115080. * @param meshesNames defines the list of mesh's names you want to load
  115081. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  115082. * @param sceneFilename defines the filename of the scene to load from
  115083. */
  115084. constructor(
  115085. /**
  115086. * Defines the name of the task
  115087. */
  115088. name: string,
  115089. /**
  115090. * Defines the list of mesh's names you want to load
  115091. */
  115092. meshesNames: any,
  115093. /**
  115094. * Defines the root url to use as a base to load your meshes and associated resources
  115095. */
  115096. rootUrl: string,
  115097. /**
  115098. * Defines the filename of the scene to load from
  115099. */
  115100. sceneFilename: string);
  115101. /**
  115102. * Execute the current task
  115103. * @param scene defines the scene where you want your assets to be loaded
  115104. * @param onSuccess is a callback called when the task is successfully executed
  115105. * @param onError is a callback called if an error occurs
  115106. */
  115107. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115108. }
  115109. /**
  115110. * Define a task used by AssetsManager to load text content
  115111. */
  115112. export class TextFileAssetTask extends AbstractAssetTask {
  115113. /**
  115114. * Defines the name of the task
  115115. */
  115116. name: string;
  115117. /**
  115118. * Defines the location of the file to load
  115119. */
  115120. url: string;
  115121. /**
  115122. * Gets the loaded text string
  115123. */
  115124. text: string;
  115125. /**
  115126. * Callback called when the task is successful
  115127. */
  115128. onSuccess: (task: TextFileAssetTask) => void;
  115129. /**
  115130. * Callback called when the task is successful
  115131. */
  115132. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  115133. /**
  115134. * Creates a new TextFileAssetTask object
  115135. * @param name defines the name of the task
  115136. * @param url defines the location of the file to load
  115137. */
  115138. constructor(
  115139. /**
  115140. * Defines the name of the task
  115141. */
  115142. name: string,
  115143. /**
  115144. * Defines the location of the file to load
  115145. */
  115146. url: string);
  115147. /**
  115148. * Execute the current task
  115149. * @param scene defines the scene where you want your assets to be loaded
  115150. * @param onSuccess is a callback called when the task is successfully executed
  115151. * @param onError is a callback called if an error occurs
  115152. */
  115153. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115154. }
  115155. /**
  115156. * Define a task used by AssetsManager to load binary data
  115157. */
  115158. export class BinaryFileAssetTask extends AbstractAssetTask {
  115159. /**
  115160. * Defines the name of the task
  115161. */
  115162. name: string;
  115163. /**
  115164. * Defines the location of the file to load
  115165. */
  115166. url: string;
  115167. /**
  115168. * Gets the lodaded data (as an array buffer)
  115169. */
  115170. data: ArrayBuffer;
  115171. /**
  115172. * Callback called when the task is successful
  115173. */
  115174. onSuccess: (task: BinaryFileAssetTask) => void;
  115175. /**
  115176. * Callback called when the task is successful
  115177. */
  115178. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  115179. /**
  115180. * Creates a new BinaryFileAssetTask object
  115181. * @param name defines the name of the new task
  115182. * @param url defines the location of the file to load
  115183. */
  115184. constructor(
  115185. /**
  115186. * Defines the name of the task
  115187. */
  115188. name: string,
  115189. /**
  115190. * Defines the location of the file to load
  115191. */
  115192. url: string);
  115193. /**
  115194. * Execute the current task
  115195. * @param scene defines the scene where you want your assets to be loaded
  115196. * @param onSuccess is a callback called when the task is successfully executed
  115197. * @param onError is a callback called if an error occurs
  115198. */
  115199. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115200. }
  115201. /**
  115202. * Define a task used by AssetsManager to load images
  115203. */
  115204. export class ImageAssetTask extends AbstractAssetTask {
  115205. /**
  115206. * Defines the name of the task
  115207. */
  115208. name: string;
  115209. /**
  115210. * Defines the location of the image to load
  115211. */
  115212. url: string;
  115213. /**
  115214. * Gets the loaded images
  115215. */
  115216. image: HTMLImageElement;
  115217. /**
  115218. * Callback called when the task is successful
  115219. */
  115220. onSuccess: (task: ImageAssetTask) => void;
  115221. /**
  115222. * Callback called when the task is successful
  115223. */
  115224. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  115225. /**
  115226. * Creates a new ImageAssetTask
  115227. * @param name defines the name of the task
  115228. * @param url defines the location of the image to load
  115229. */
  115230. constructor(
  115231. /**
  115232. * Defines the name of the task
  115233. */
  115234. name: string,
  115235. /**
  115236. * Defines the location of the image to load
  115237. */
  115238. url: string);
  115239. /**
  115240. * Execute the current task
  115241. * @param scene defines the scene where you want your assets to be loaded
  115242. * @param onSuccess is a callback called when the task is successfully executed
  115243. * @param onError is a callback called if an error occurs
  115244. */
  115245. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115246. }
  115247. /**
  115248. * Defines the interface used by texture loading tasks
  115249. */
  115250. export interface ITextureAssetTask<TEX extends BaseTexture> {
  115251. /**
  115252. * Gets the loaded texture
  115253. */
  115254. texture: TEX;
  115255. }
  115256. /**
  115257. * Define a task used by AssetsManager to load 2D textures
  115258. */
  115259. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  115260. /**
  115261. * Defines the name of the task
  115262. */
  115263. name: string;
  115264. /**
  115265. * Defines the location of the file to load
  115266. */
  115267. url: string;
  115268. /**
  115269. * Defines if mipmap should not be generated (default is false)
  115270. */
  115271. noMipmap?: boolean | undefined;
  115272. /**
  115273. * Defines if texture must be inverted on Y axis (default is false)
  115274. */
  115275. invertY?: boolean | undefined;
  115276. /**
  115277. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115278. */
  115279. samplingMode: number;
  115280. /**
  115281. * Gets the loaded texture
  115282. */
  115283. texture: Texture;
  115284. /**
  115285. * Callback called when the task is successful
  115286. */
  115287. onSuccess: (task: TextureAssetTask) => void;
  115288. /**
  115289. * Callback called when the task is successful
  115290. */
  115291. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  115292. /**
  115293. * Creates a new TextureAssetTask object
  115294. * @param name defines the name of the task
  115295. * @param url defines the location of the file to load
  115296. * @param noMipmap defines if mipmap should not be generated (default is false)
  115297. * @param invertY defines if texture must be inverted on Y axis (default is false)
  115298. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115299. */
  115300. constructor(
  115301. /**
  115302. * Defines the name of the task
  115303. */
  115304. name: string,
  115305. /**
  115306. * Defines the location of the file to load
  115307. */
  115308. url: string,
  115309. /**
  115310. * Defines if mipmap should not be generated (default is false)
  115311. */
  115312. noMipmap?: boolean | undefined,
  115313. /**
  115314. * Defines if texture must be inverted on Y axis (default is false)
  115315. */
  115316. invertY?: boolean | undefined,
  115317. /**
  115318. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115319. */
  115320. samplingMode?: number);
  115321. /**
  115322. * Execute the current task
  115323. * @param scene defines the scene where you want your assets to be loaded
  115324. * @param onSuccess is a callback called when the task is successfully executed
  115325. * @param onError is a callback called if an error occurs
  115326. */
  115327. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115328. }
  115329. /**
  115330. * Define a task used by AssetsManager to load cube textures
  115331. */
  115332. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  115333. /**
  115334. * Defines the name of the task
  115335. */
  115336. name: string;
  115337. /**
  115338. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115339. */
  115340. url: string;
  115341. /**
  115342. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115343. */
  115344. extensions?: string[] | undefined;
  115345. /**
  115346. * Defines if mipmaps should not be generated (default is false)
  115347. */
  115348. noMipmap?: boolean | undefined;
  115349. /**
  115350. * Defines the explicit list of files (undefined by default)
  115351. */
  115352. files?: string[] | undefined;
  115353. /**
  115354. * Gets the loaded texture
  115355. */
  115356. texture: CubeTexture;
  115357. /**
  115358. * Callback called when the task is successful
  115359. */
  115360. onSuccess: (task: CubeTextureAssetTask) => void;
  115361. /**
  115362. * Callback called when the task is successful
  115363. */
  115364. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  115365. /**
  115366. * Creates a new CubeTextureAssetTask
  115367. * @param name defines the name of the task
  115368. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115369. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115370. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115371. * @param files defines the explicit list of files (undefined by default)
  115372. */
  115373. constructor(
  115374. /**
  115375. * Defines the name of the task
  115376. */
  115377. name: string,
  115378. /**
  115379. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115380. */
  115381. url: string,
  115382. /**
  115383. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115384. */
  115385. extensions?: string[] | undefined,
  115386. /**
  115387. * Defines if mipmaps should not be generated (default is false)
  115388. */
  115389. noMipmap?: boolean | undefined,
  115390. /**
  115391. * Defines the explicit list of files (undefined by default)
  115392. */
  115393. files?: string[] | undefined);
  115394. /**
  115395. * Execute the current task
  115396. * @param scene defines the scene where you want your assets to be loaded
  115397. * @param onSuccess is a callback called when the task is successfully executed
  115398. * @param onError is a callback called if an error occurs
  115399. */
  115400. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115401. }
  115402. /**
  115403. * Define a task used by AssetsManager to load HDR cube textures
  115404. */
  115405. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  115406. /**
  115407. * Defines the name of the task
  115408. */
  115409. name: string;
  115410. /**
  115411. * Defines the location of the file to load
  115412. */
  115413. url: string;
  115414. /**
  115415. * Defines the desired size (the more it increases the longer the generation will be)
  115416. */
  115417. size: number;
  115418. /**
  115419. * Defines if mipmaps should not be generated (default is false)
  115420. */
  115421. noMipmap: boolean;
  115422. /**
  115423. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115424. */
  115425. generateHarmonics: boolean;
  115426. /**
  115427. * 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)
  115428. */
  115429. gammaSpace: boolean;
  115430. /**
  115431. * Internal Use Only
  115432. */
  115433. reserved: boolean;
  115434. /**
  115435. * Gets the loaded texture
  115436. */
  115437. texture: HDRCubeTexture;
  115438. /**
  115439. * Callback called when the task is successful
  115440. */
  115441. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  115442. /**
  115443. * Callback called when the task is successful
  115444. */
  115445. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  115446. /**
  115447. * Creates a new HDRCubeTextureAssetTask object
  115448. * @param name defines the name of the task
  115449. * @param url defines the location of the file to load
  115450. * @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.
  115451. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115452. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115453. * @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)
  115454. * @param reserved Internal use only
  115455. */
  115456. constructor(
  115457. /**
  115458. * Defines the name of the task
  115459. */
  115460. name: string,
  115461. /**
  115462. * Defines the location of the file to load
  115463. */
  115464. url: string,
  115465. /**
  115466. * Defines the desired size (the more it increases the longer the generation will be)
  115467. */
  115468. size: number,
  115469. /**
  115470. * Defines if mipmaps should not be generated (default is false)
  115471. */
  115472. noMipmap?: boolean,
  115473. /**
  115474. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115475. */
  115476. generateHarmonics?: boolean,
  115477. /**
  115478. * 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)
  115479. */
  115480. gammaSpace?: boolean,
  115481. /**
  115482. * Internal Use Only
  115483. */
  115484. reserved?: boolean);
  115485. /**
  115486. * Execute the current task
  115487. * @param scene defines the scene where you want your assets to be loaded
  115488. * @param onSuccess is a callback called when the task is successfully executed
  115489. * @param onError is a callback called if an error occurs
  115490. */
  115491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115492. }
  115493. /**
  115494. * Define a task used by AssetsManager to load Equirectangular cube textures
  115495. */
  115496. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  115497. /**
  115498. * Defines the name of the task
  115499. */
  115500. name: string;
  115501. /**
  115502. * Defines the location of the file to load
  115503. */
  115504. url: string;
  115505. /**
  115506. * Defines the desired size (the more it increases the longer the generation will be)
  115507. */
  115508. size: number;
  115509. /**
  115510. * Defines if mipmaps should not be generated (default is false)
  115511. */
  115512. noMipmap: boolean;
  115513. /**
  115514. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115515. * but the standard material would require them in Gamma space) (default is true)
  115516. */
  115517. gammaSpace: boolean;
  115518. /**
  115519. * Gets the loaded texture
  115520. */
  115521. texture: EquiRectangularCubeTexture;
  115522. /**
  115523. * Callback called when the task is successful
  115524. */
  115525. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  115526. /**
  115527. * Callback called when the task is successful
  115528. */
  115529. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  115530. /**
  115531. * Creates a new EquiRectangularCubeTextureAssetTask object
  115532. * @param name defines the name of the task
  115533. * @param url defines the location of the file to load
  115534. * @param size defines the desired size (the more it increases the longer the generation will be)
  115535. * If the size is omitted this implies you are using a preprocessed cubemap.
  115536. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115537. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  115538. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  115539. * (default is true)
  115540. */
  115541. constructor(
  115542. /**
  115543. * Defines the name of the task
  115544. */
  115545. name: string,
  115546. /**
  115547. * Defines the location of the file to load
  115548. */
  115549. url: string,
  115550. /**
  115551. * Defines the desired size (the more it increases the longer the generation will be)
  115552. */
  115553. size: number,
  115554. /**
  115555. * Defines if mipmaps should not be generated (default is false)
  115556. */
  115557. noMipmap?: boolean,
  115558. /**
  115559. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115560. * but the standard material would require them in Gamma space) (default is true)
  115561. */
  115562. gammaSpace?: boolean);
  115563. /**
  115564. * Execute the current task
  115565. * @param scene defines the scene where you want your assets to be loaded
  115566. * @param onSuccess is a callback called when the task is successfully executed
  115567. * @param onError is a callback called if an error occurs
  115568. */
  115569. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115570. }
  115571. /**
  115572. * This class can be used to easily import assets into a scene
  115573. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115574. */
  115575. export class AssetsManager {
  115576. private _scene;
  115577. private _isLoading;
  115578. protected _tasks: AbstractAssetTask[];
  115579. protected _waitingTasksCount: number;
  115580. protected _totalTasksCount: number;
  115581. /**
  115582. * Callback called when all tasks are processed
  115583. */
  115584. onFinish: (tasks: AbstractAssetTask[]) => void;
  115585. /**
  115586. * Callback called when a task is successful
  115587. */
  115588. onTaskSuccess: (task: AbstractAssetTask) => void;
  115589. /**
  115590. * Callback called when a task had an error
  115591. */
  115592. onTaskError: (task: AbstractAssetTask) => void;
  115593. /**
  115594. * Callback called when a task is done (whatever the result is)
  115595. */
  115596. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115597. /**
  115598. * Observable called when all tasks are processed
  115599. */
  115600. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115601. /**
  115602. * Observable called when a task had an error
  115603. */
  115604. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115605. /**
  115606. * Observable called when all tasks were executed
  115607. */
  115608. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115609. /**
  115610. * Observable called when a task is done (whatever the result is)
  115611. */
  115612. onProgressObservable: Observable<IAssetsProgressEvent>;
  115613. /**
  115614. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115615. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115616. */
  115617. useDefaultLoadingScreen: boolean;
  115618. /**
  115619. * Creates a new AssetsManager
  115620. * @param scene defines the scene to work on
  115621. */
  115622. constructor(scene: Scene);
  115623. /**
  115624. * Add a MeshAssetTask to the list of active tasks
  115625. * @param taskName defines the name of the new task
  115626. * @param meshesNames defines the name of meshes to load
  115627. * @param rootUrl defines the root url to use to locate files
  115628. * @param sceneFilename defines the filename of the scene file
  115629. * @returns a new MeshAssetTask object
  115630. */
  115631. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115632. /**
  115633. * Add a TextFileAssetTask to the list of active tasks
  115634. * @param taskName defines the name of the new task
  115635. * @param url defines the url of the file to load
  115636. * @returns a new TextFileAssetTask object
  115637. */
  115638. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115639. /**
  115640. * Add a BinaryFileAssetTask to the list of active tasks
  115641. * @param taskName defines the name of the new task
  115642. * @param url defines the url of the file to load
  115643. * @returns a new BinaryFileAssetTask object
  115644. */
  115645. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115646. /**
  115647. * Add a ImageAssetTask to the list of active tasks
  115648. * @param taskName defines the name of the new task
  115649. * @param url defines the url of the file to load
  115650. * @returns a new ImageAssetTask object
  115651. */
  115652. addImageTask(taskName: string, url: string): ImageAssetTask;
  115653. /**
  115654. * Add a TextureAssetTask to the list of active tasks
  115655. * @param taskName defines the name of the new task
  115656. * @param url defines the url of the file to load
  115657. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115658. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115659. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115660. * @returns a new TextureAssetTask object
  115661. */
  115662. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115663. /**
  115664. * Add a CubeTextureAssetTask to the list of active tasks
  115665. * @param taskName defines the name of the new task
  115666. * @param url defines the url of the file to load
  115667. * @param extensions defines the extension to use to load the cube map (can be null)
  115668. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115669. * @param files defines the list of files to load (can be null)
  115670. * @returns a new CubeTextureAssetTask object
  115671. */
  115672. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115673. /**
  115674. *
  115675. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115676. * @param taskName defines the name of the new task
  115677. * @param url defines the url of the file to load
  115678. * @param size defines the size you want for the cubemap (can be null)
  115679. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115680. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115681. * @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)
  115682. * @param reserved Internal use only
  115683. * @returns a new HDRCubeTextureAssetTask object
  115684. */
  115685. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115686. /**
  115687. *
  115688. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115689. * @param taskName defines the name of the new task
  115690. * @param url defines the url of the file to load
  115691. * @param size defines the size you want for the cubemap (can be null)
  115692. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115693. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115694. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115695. * @returns a new EquiRectangularCubeTextureAssetTask object
  115696. */
  115697. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115698. /**
  115699. * Remove a task from the assets manager.
  115700. * @param task the task to remove
  115701. */
  115702. removeTask(task: AbstractAssetTask): void;
  115703. private _decreaseWaitingTasksCount;
  115704. private _runTask;
  115705. /**
  115706. * Reset the AssetsManager and remove all tasks
  115707. * @return the current instance of the AssetsManager
  115708. */
  115709. reset(): AssetsManager;
  115710. /**
  115711. * Start the loading process
  115712. * @return the current instance of the AssetsManager
  115713. */
  115714. load(): AssetsManager;
  115715. /**
  115716. * Start the loading process as an async operation
  115717. * @return a promise returning the list of failed tasks
  115718. */
  115719. loadAsync(): Promise<void>;
  115720. }
  115721. }
  115722. declare module BABYLON {
  115723. /**
  115724. * Wrapper class for promise with external resolve and reject.
  115725. */
  115726. export class Deferred<T> {
  115727. /**
  115728. * The promise associated with this deferred object.
  115729. */
  115730. readonly promise: Promise<T>;
  115731. private _resolve;
  115732. private _reject;
  115733. /**
  115734. * The resolve method of the promise associated with this deferred object.
  115735. */
  115736. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115737. /**
  115738. * The reject method of the promise associated with this deferred object.
  115739. */
  115740. readonly reject: (reason?: any) => void;
  115741. /**
  115742. * Constructor for this deferred object.
  115743. */
  115744. constructor();
  115745. }
  115746. }
  115747. declare module BABYLON {
  115748. /**
  115749. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115750. */
  115751. export class MeshExploder {
  115752. private _centerMesh;
  115753. private _meshes;
  115754. private _meshesOrigins;
  115755. private _toCenterVectors;
  115756. private _scaledDirection;
  115757. private _newPosition;
  115758. private _centerPosition;
  115759. /**
  115760. * Explodes meshes from a center mesh.
  115761. * @param meshes The meshes to explode.
  115762. * @param centerMesh The mesh to be center of explosion.
  115763. */
  115764. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115765. private _setCenterMesh;
  115766. /**
  115767. * Get class name
  115768. * @returns "MeshExploder"
  115769. */
  115770. getClassName(): string;
  115771. /**
  115772. * "Exploded meshes"
  115773. * @returns Array of meshes with the centerMesh at index 0.
  115774. */
  115775. getMeshes(): Array<Mesh>;
  115776. /**
  115777. * Explodes meshes giving a specific direction
  115778. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115779. */
  115780. explode(direction?: number): void;
  115781. }
  115782. }
  115783. declare module BABYLON {
  115784. /**
  115785. * Class used to help managing file picking and drag'n'drop
  115786. */
  115787. export class FilesInput {
  115788. /**
  115789. * List of files ready to be loaded
  115790. */
  115791. static readonly FilesToLoad: {
  115792. [key: string]: File;
  115793. };
  115794. /**
  115795. * Callback called when a file is processed
  115796. */
  115797. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  115798. private _engine;
  115799. private _currentScene;
  115800. private _sceneLoadedCallback;
  115801. private _progressCallback;
  115802. private _additionalRenderLoopLogicCallback;
  115803. private _textureLoadingCallback;
  115804. private _startingProcessingFilesCallback;
  115805. private _onReloadCallback;
  115806. private _errorCallback;
  115807. private _elementToMonitor;
  115808. private _sceneFileToLoad;
  115809. private _filesToLoad;
  115810. /**
  115811. * Creates a new FilesInput
  115812. * @param engine defines the rendering engine
  115813. * @param scene defines the hosting scene
  115814. * @param sceneLoadedCallback callback called when scene is loaded
  115815. * @param progressCallback callback called to track progress
  115816. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  115817. * @param textureLoadingCallback callback called when a texture is loading
  115818. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  115819. * @param onReloadCallback callback called when a reload is requested
  115820. * @param errorCallback callback call if an error occurs
  115821. */
  115822. 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);
  115823. private _dragEnterHandler;
  115824. private _dragOverHandler;
  115825. private _dropHandler;
  115826. /**
  115827. * Calls this function to listen to drag'n'drop events on a specific DOM element
  115828. * @param elementToMonitor defines the DOM element to track
  115829. */
  115830. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  115831. /**
  115832. * Release all associated resources
  115833. */
  115834. dispose(): void;
  115835. private renderFunction;
  115836. private drag;
  115837. private drop;
  115838. private _traverseFolder;
  115839. private _processFiles;
  115840. /**
  115841. * Load files from a drop event
  115842. * @param event defines the drop event to use as source
  115843. */
  115844. loadFiles(event: any): void;
  115845. private _processReload;
  115846. /**
  115847. * Reload the current scene from the loaded files
  115848. */
  115849. reload(): void;
  115850. }
  115851. }
  115852. declare module BABYLON {
  115853. /**
  115854. * Defines the root class used to create scene optimization to use with SceneOptimizer
  115855. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115856. */
  115857. export class SceneOptimization {
  115858. /**
  115859. * Defines the priority of this optimization (0 by default which means first in the list)
  115860. */
  115861. priority: number;
  115862. /**
  115863. * Gets a string describing the action executed by the current optimization
  115864. * @returns description string
  115865. */
  115866. getDescription(): string;
  115867. /**
  115868. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115869. * @param scene defines the current scene where to apply this optimization
  115870. * @param optimizer defines the current optimizer
  115871. * @returns true if everything that can be done was applied
  115872. */
  115873. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115874. /**
  115875. * Creates the SceneOptimization object
  115876. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115877. * @param desc defines the description associated with the optimization
  115878. */
  115879. constructor(
  115880. /**
  115881. * Defines the priority of this optimization (0 by default which means first in the list)
  115882. */
  115883. priority?: number);
  115884. }
  115885. /**
  115886. * Defines an optimization used to reduce the size of render target textures
  115887. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115888. */
  115889. export class TextureOptimization extends SceneOptimization {
  115890. /**
  115891. * Defines the priority of this optimization (0 by default which means first in the list)
  115892. */
  115893. priority: number;
  115894. /**
  115895. * 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
  115896. */
  115897. maximumSize: number;
  115898. /**
  115899. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115900. */
  115901. step: number;
  115902. /**
  115903. * Gets a string describing the action executed by the current optimization
  115904. * @returns description string
  115905. */
  115906. getDescription(): string;
  115907. /**
  115908. * Creates the TextureOptimization object
  115909. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115910. * @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
  115911. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115912. */
  115913. constructor(
  115914. /**
  115915. * Defines the priority of this optimization (0 by default which means first in the list)
  115916. */
  115917. priority?: number,
  115918. /**
  115919. * 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
  115920. */
  115921. maximumSize?: number,
  115922. /**
  115923. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115924. */
  115925. step?: number);
  115926. /**
  115927. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115928. * @param scene defines the current scene where to apply this optimization
  115929. * @param optimizer defines the current optimizer
  115930. * @returns true if everything that can be done was applied
  115931. */
  115932. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115933. }
  115934. /**
  115935. * Defines an optimization used to increase or decrease the rendering resolution
  115936. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115937. */
  115938. export class HardwareScalingOptimization extends SceneOptimization {
  115939. /**
  115940. * Defines the priority of this optimization (0 by default which means first in the list)
  115941. */
  115942. priority: number;
  115943. /**
  115944. * Defines the maximum scale to use (2 by default)
  115945. */
  115946. maximumScale: number;
  115947. /**
  115948. * Defines the step to use between two passes (0.5 by default)
  115949. */
  115950. step: number;
  115951. private _currentScale;
  115952. private _directionOffset;
  115953. /**
  115954. * Gets a string describing the action executed by the current optimization
  115955. * @return description string
  115956. */
  115957. getDescription(): string;
  115958. /**
  115959. * Creates the HardwareScalingOptimization object
  115960. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115961. * @param maximumScale defines the maximum scale to use (2 by default)
  115962. * @param step defines the step to use between two passes (0.5 by default)
  115963. */
  115964. constructor(
  115965. /**
  115966. * Defines the priority of this optimization (0 by default which means first in the list)
  115967. */
  115968. priority?: number,
  115969. /**
  115970. * Defines the maximum scale to use (2 by default)
  115971. */
  115972. maximumScale?: number,
  115973. /**
  115974. * Defines the step to use between two passes (0.5 by default)
  115975. */
  115976. step?: number);
  115977. /**
  115978. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115979. * @param scene defines the current scene where to apply this optimization
  115980. * @param optimizer defines the current optimizer
  115981. * @returns true if everything that can be done was applied
  115982. */
  115983. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115984. }
  115985. /**
  115986. * Defines an optimization used to remove shadows
  115987. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115988. */
  115989. export class ShadowsOptimization extends SceneOptimization {
  115990. /**
  115991. * Gets a string describing the action executed by the current optimization
  115992. * @return description string
  115993. */
  115994. getDescription(): string;
  115995. /**
  115996. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115997. * @param scene defines the current scene where to apply this optimization
  115998. * @param optimizer defines the current optimizer
  115999. * @returns true if everything that can be done was applied
  116000. */
  116001. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116002. }
  116003. /**
  116004. * Defines an optimization used to turn post-processes off
  116005. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116006. */
  116007. export class PostProcessesOptimization extends SceneOptimization {
  116008. /**
  116009. * Gets a string describing the action executed by the current optimization
  116010. * @return description string
  116011. */
  116012. getDescription(): string;
  116013. /**
  116014. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116015. * @param scene defines the current scene where to apply this optimization
  116016. * @param optimizer defines the current optimizer
  116017. * @returns true if everything that can be done was applied
  116018. */
  116019. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116020. }
  116021. /**
  116022. * Defines an optimization used to turn lens flares off
  116023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116024. */
  116025. export class LensFlaresOptimization extends SceneOptimization {
  116026. /**
  116027. * Gets a string describing the action executed by the current optimization
  116028. * @return description string
  116029. */
  116030. getDescription(): string;
  116031. /**
  116032. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116033. * @param scene defines the current scene where to apply this optimization
  116034. * @param optimizer defines the current optimizer
  116035. * @returns true if everything that can be done was applied
  116036. */
  116037. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116038. }
  116039. /**
  116040. * Defines an optimization based on user defined callback.
  116041. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116042. */
  116043. export class CustomOptimization extends SceneOptimization {
  116044. /**
  116045. * Callback called to apply the custom optimization.
  116046. */
  116047. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  116048. /**
  116049. * Callback called to get custom description
  116050. */
  116051. onGetDescription: () => string;
  116052. /**
  116053. * Gets a string describing the action executed by the current optimization
  116054. * @returns description string
  116055. */
  116056. getDescription(): string;
  116057. /**
  116058. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116059. * @param scene defines the current scene where to apply this optimization
  116060. * @param optimizer defines the current optimizer
  116061. * @returns true if everything that can be done was applied
  116062. */
  116063. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116064. }
  116065. /**
  116066. * Defines an optimization used to turn particles off
  116067. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116068. */
  116069. export class ParticlesOptimization extends SceneOptimization {
  116070. /**
  116071. * Gets a string describing the action executed by the current optimization
  116072. * @return description string
  116073. */
  116074. getDescription(): string;
  116075. /**
  116076. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116077. * @param scene defines the current scene where to apply this optimization
  116078. * @param optimizer defines the current optimizer
  116079. * @returns true if everything that can be done was applied
  116080. */
  116081. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116082. }
  116083. /**
  116084. * Defines an optimization used to turn render targets off
  116085. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116086. */
  116087. export class RenderTargetsOptimization extends SceneOptimization {
  116088. /**
  116089. * Gets a string describing the action executed by the current optimization
  116090. * @return description string
  116091. */
  116092. getDescription(): string;
  116093. /**
  116094. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116095. * @param scene defines the current scene where to apply this optimization
  116096. * @param optimizer defines the current optimizer
  116097. * @returns true if everything that can be done was applied
  116098. */
  116099. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116100. }
  116101. /**
  116102. * Defines an optimization used to merge meshes with compatible materials
  116103. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116104. */
  116105. export class MergeMeshesOptimization extends SceneOptimization {
  116106. private static _UpdateSelectionTree;
  116107. /**
  116108. * Gets or sets a boolean which defines if optimization octree has to be updated
  116109. */
  116110. /**
  116111. * Gets or sets a boolean which defines if optimization octree has to be updated
  116112. */
  116113. static UpdateSelectionTree: boolean;
  116114. /**
  116115. * Gets a string describing the action executed by the current optimization
  116116. * @return description string
  116117. */
  116118. getDescription(): string;
  116119. private _canBeMerged;
  116120. /**
  116121. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116122. * @param scene defines the current scene where to apply this optimization
  116123. * @param optimizer defines the current optimizer
  116124. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  116125. * @returns true if everything that can be done was applied
  116126. */
  116127. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  116128. }
  116129. /**
  116130. * Defines a list of options used by SceneOptimizer
  116131. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116132. */
  116133. export class SceneOptimizerOptions {
  116134. /**
  116135. * Defines the target frame rate to reach (60 by default)
  116136. */
  116137. targetFrameRate: number;
  116138. /**
  116139. * Defines the interval between two checkes (2000ms by default)
  116140. */
  116141. trackerDuration: number;
  116142. /**
  116143. * Gets the list of optimizations to apply
  116144. */
  116145. optimizations: SceneOptimization[];
  116146. /**
  116147. * Creates a new list of options used by SceneOptimizer
  116148. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  116149. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  116150. */
  116151. constructor(
  116152. /**
  116153. * Defines the target frame rate to reach (60 by default)
  116154. */
  116155. targetFrameRate?: number,
  116156. /**
  116157. * Defines the interval between two checkes (2000ms by default)
  116158. */
  116159. trackerDuration?: number);
  116160. /**
  116161. * Add a new optimization
  116162. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  116163. * @returns the current SceneOptimizerOptions
  116164. */
  116165. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  116166. /**
  116167. * Add a new custom optimization
  116168. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  116169. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  116170. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116171. * @returns the current SceneOptimizerOptions
  116172. */
  116173. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  116174. /**
  116175. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  116176. * @param targetFrameRate defines the target frame rate (60 by default)
  116177. * @returns a SceneOptimizerOptions object
  116178. */
  116179. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116180. /**
  116181. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  116182. * @param targetFrameRate defines the target frame rate (60 by default)
  116183. * @returns a SceneOptimizerOptions object
  116184. */
  116185. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116186. /**
  116187. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  116188. * @param targetFrameRate defines the target frame rate (60 by default)
  116189. * @returns a SceneOptimizerOptions object
  116190. */
  116191. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116192. }
  116193. /**
  116194. * Class used to run optimizations in order to reach a target frame rate
  116195. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116196. */
  116197. export class SceneOptimizer implements IDisposable {
  116198. private _isRunning;
  116199. private _options;
  116200. private _scene;
  116201. private _currentPriorityLevel;
  116202. private _targetFrameRate;
  116203. private _trackerDuration;
  116204. private _currentFrameRate;
  116205. private _sceneDisposeObserver;
  116206. private _improvementMode;
  116207. /**
  116208. * Defines an observable called when the optimizer reaches the target frame rate
  116209. */
  116210. onSuccessObservable: Observable<SceneOptimizer>;
  116211. /**
  116212. * Defines an observable called when the optimizer enables an optimization
  116213. */
  116214. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  116215. /**
  116216. * Defines an observable called when the optimizer is not able to reach the target frame rate
  116217. */
  116218. onFailureObservable: Observable<SceneOptimizer>;
  116219. /**
  116220. * Gets a boolean indicating if the optimizer is in improvement mode
  116221. */
  116222. readonly isInImprovementMode: boolean;
  116223. /**
  116224. * Gets the current priority level (0 at start)
  116225. */
  116226. readonly currentPriorityLevel: number;
  116227. /**
  116228. * Gets the current frame rate checked by the SceneOptimizer
  116229. */
  116230. readonly currentFrameRate: number;
  116231. /**
  116232. * Gets or sets the current target frame rate (60 by default)
  116233. */
  116234. /**
  116235. * Gets or sets the current target frame rate (60 by default)
  116236. */
  116237. targetFrameRate: number;
  116238. /**
  116239. * Gets or sets the current interval between two checks (every 2000ms by default)
  116240. */
  116241. /**
  116242. * Gets or sets the current interval between two checks (every 2000ms by default)
  116243. */
  116244. trackerDuration: number;
  116245. /**
  116246. * Gets the list of active optimizations
  116247. */
  116248. readonly optimizations: SceneOptimization[];
  116249. /**
  116250. * Creates a new SceneOptimizer
  116251. * @param scene defines the scene to work on
  116252. * @param options defines the options to use with the SceneOptimizer
  116253. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  116254. * @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)
  116255. */
  116256. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  116257. /**
  116258. * Stops the current optimizer
  116259. */
  116260. stop(): void;
  116261. /**
  116262. * Reset the optimizer to initial step (current priority level = 0)
  116263. */
  116264. reset(): void;
  116265. /**
  116266. * Start the optimizer. By default it will try to reach a specific framerate
  116267. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  116268. */
  116269. start(): void;
  116270. private _checkCurrentState;
  116271. /**
  116272. * Release all resources
  116273. */
  116274. dispose(): void;
  116275. /**
  116276. * Helper function to create a SceneOptimizer with one single line of code
  116277. * @param scene defines the scene to work on
  116278. * @param options defines the options to use with the SceneOptimizer
  116279. * @param onSuccess defines a callback to call on success
  116280. * @param onFailure defines a callback to call on failure
  116281. * @returns the new SceneOptimizer object
  116282. */
  116283. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  116284. }
  116285. }
  116286. declare module BABYLON {
  116287. /**
  116288. * Class used to serialize a scene into a string
  116289. */
  116290. export class SceneSerializer {
  116291. /**
  116292. * Clear cache used by a previous serialization
  116293. */
  116294. static ClearCache(): void;
  116295. /**
  116296. * Serialize a scene into a JSON compatible object
  116297. * @param scene defines the scene to serialize
  116298. * @returns a JSON compatible object
  116299. */
  116300. static Serialize(scene: Scene): any;
  116301. /**
  116302. * Serialize a mesh into a JSON compatible object
  116303. * @param toSerialize defines the mesh to serialize
  116304. * @param withParents defines if parents must be serialized as well
  116305. * @param withChildren defines if children must be serialized as well
  116306. * @returns a JSON compatible object
  116307. */
  116308. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  116309. }
  116310. }
  116311. declare module BABYLON {
  116312. /**
  116313. * Class used to host texture specific utilities
  116314. */
  116315. export class TextureTools {
  116316. /**
  116317. * Uses the GPU to create a copy texture rescaled at a given size
  116318. * @param texture Texture to copy from
  116319. * @param width defines the desired width
  116320. * @param height defines the desired height
  116321. * @param useBilinearMode defines if bilinear mode has to be used
  116322. * @return the generated texture
  116323. */
  116324. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  116325. }
  116326. }
  116327. declare module BABYLON {
  116328. /**
  116329. * This represents the different options avilable for the video capture.
  116330. */
  116331. export interface VideoRecorderOptions {
  116332. /** Defines the mime type of the video */
  116333. mimeType: string;
  116334. /** Defines the video the video should be recorded at */
  116335. fps: number;
  116336. /** Defines the chunk size for the recording data */
  116337. recordChunckSize: number;
  116338. /** The audio tracks to attach to the record */
  116339. audioTracks?: MediaStreamTrack[];
  116340. }
  116341. /**
  116342. * This can helps recording videos from BabylonJS.
  116343. * This is based on the available WebRTC functionalities of the browser.
  116344. *
  116345. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  116346. */
  116347. export class VideoRecorder {
  116348. private static readonly _defaultOptions;
  116349. /**
  116350. * Returns wehther or not the VideoRecorder is available in your browser.
  116351. * @param engine Defines the Babylon Engine to check the support for
  116352. * @returns true if supported otherwise false
  116353. */
  116354. static IsSupported(engine: Engine): boolean;
  116355. private readonly _options;
  116356. private _canvas;
  116357. private _mediaRecorder;
  116358. private _recordedChunks;
  116359. private _fileName;
  116360. private _resolve;
  116361. private _reject;
  116362. /**
  116363. * True wether a recording is already in progress.
  116364. */
  116365. readonly isRecording: boolean;
  116366. /**
  116367. * Create a new VideoCapture object which can help converting what you see in Babylon to
  116368. * a video file.
  116369. * @param engine Defines the BabylonJS Engine you wish to record
  116370. * @param options Defines options that can be used to customized the capture
  116371. */
  116372. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  116373. /**
  116374. * Stops the current recording before the default capture timeout passed in the startRecording
  116375. * functions.
  116376. */
  116377. stopRecording(): void;
  116378. /**
  116379. * Starts recording the canvas for a max duration specified in parameters.
  116380. * @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.
  116381. * @param maxDuration Defines the maximum recording time in seconds.
  116382. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  116383. * @return a promise callback at the end of the recording with the video data in Blob.
  116384. */
  116385. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  116386. /**
  116387. * Releases internal resources used during the recording.
  116388. */
  116389. dispose(): void;
  116390. private _handleDataAvailable;
  116391. private _handleError;
  116392. private _handleStop;
  116393. }
  116394. }
  116395. declare module BABYLON {
  116396. /**
  116397. * Class containing a set of static utilities functions for screenshots
  116398. */
  116399. export class ScreenshotTools {
  116400. /**
  116401. * Captures a screenshot of the current rendering
  116402. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116403. * @param engine defines the rendering engine
  116404. * @param camera defines the source camera
  116405. * @param size This parameter can be set to a single number or to an object with the
  116406. * following (optional) properties: precision, width, height. If a single number is passed,
  116407. * it will be used for both width and height. If an object is passed, the screenshot size
  116408. * will be derived from the parameters. The precision property is a multiplier allowing
  116409. * rendering at a higher or lower resolution
  116410. * @param successCallback defines the callback receives a single parameter which contains the
  116411. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116412. * src parameter of an <img> to display it
  116413. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116414. * Check your browser for supported MIME types
  116415. */
  116416. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  116417. /**
  116418. * Generates an image screenshot from the specified camera.
  116419. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116420. * @param engine The engine to use for rendering
  116421. * @param camera The camera to use for rendering
  116422. * @param size This parameter can be set to a single number or to an object with the
  116423. * following (optional) properties: precision, width, height. If a single number is passed,
  116424. * it will be used for both width and height. If an object is passed, the screenshot size
  116425. * will be derived from the parameters. The precision property is a multiplier allowing
  116426. * rendering at a higher or lower resolution
  116427. * @param successCallback The callback receives a single parameter which contains the
  116428. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116429. * src parameter of an <img> to display it
  116430. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116431. * Check your browser for supported MIME types
  116432. * @param samples Texture samples (default: 1)
  116433. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116434. * @param fileName A name for for the downloaded file.
  116435. */
  116436. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116437. }
  116438. }
  116439. declare module BABYLON {
  116440. /**
  116441. * A cursor which tracks a point on a path
  116442. */
  116443. export class PathCursor {
  116444. private path;
  116445. /**
  116446. * Stores path cursor callbacks for when an onchange event is triggered
  116447. */
  116448. private _onchange;
  116449. /**
  116450. * The value of the path cursor
  116451. */
  116452. value: number;
  116453. /**
  116454. * The animation array of the path cursor
  116455. */
  116456. animations: Animation[];
  116457. /**
  116458. * Initializes the path cursor
  116459. * @param path The path to track
  116460. */
  116461. constructor(path: Path2);
  116462. /**
  116463. * Gets the cursor point on the path
  116464. * @returns A point on the path cursor at the cursor location
  116465. */
  116466. getPoint(): Vector3;
  116467. /**
  116468. * Moves the cursor ahead by the step amount
  116469. * @param step The amount to move the cursor forward
  116470. * @returns This path cursor
  116471. */
  116472. moveAhead(step?: number): PathCursor;
  116473. /**
  116474. * Moves the cursor behind by the step amount
  116475. * @param step The amount to move the cursor back
  116476. * @returns This path cursor
  116477. */
  116478. moveBack(step?: number): PathCursor;
  116479. /**
  116480. * Moves the cursor by the step amount
  116481. * If the step amount is greater than one, an exception is thrown
  116482. * @param step The amount to move the cursor
  116483. * @returns This path cursor
  116484. */
  116485. move(step: number): PathCursor;
  116486. /**
  116487. * Ensures that the value is limited between zero and one
  116488. * @returns This path cursor
  116489. */
  116490. private ensureLimits;
  116491. /**
  116492. * Runs onchange callbacks on change (used by the animation engine)
  116493. * @returns This path cursor
  116494. */
  116495. private raiseOnChange;
  116496. /**
  116497. * Executes a function on change
  116498. * @param f A path cursor onchange callback
  116499. * @returns This path cursor
  116500. */
  116501. onchange(f: (cursor: PathCursor) => void): PathCursor;
  116502. }
  116503. }
  116504. declare module BABYLON {
  116505. /** @hidden */
  116506. export var blurPixelShader: {
  116507. name: string;
  116508. shader: string;
  116509. };
  116510. }
  116511. declare module BABYLON {
  116512. /** @hidden */
  116513. export var bones300Declaration: {
  116514. name: string;
  116515. shader: string;
  116516. };
  116517. }
  116518. declare module BABYLON {
  116519. /** @hidden */
  116520. export var instances300Declaration: {
  116521. name: string;
  116522. shader: string;
  116523. };
  116524. }
  116525. declare module BABYLON {
  116526. /** @hidden */
  116527. export var pointCloudVertexDeclaration: {
  116528. name: string;
  116529. shader: string;
  116530. };
  116531. }
  116532. // Mixins
  116533. interface Window {
  116534. mozIndexedDB: IDBFactory;
  116535. webkitIndexedDB: IDBFactory;
  116536. msIndexedDB: IDBFactory;
  116537. webkitURL: typeof URL;
  116538. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  116539. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  116540. WebGLRenderingContext: WebGLRenderingContext;
  116541. MSGesture: MSGesture;
  116542. CANNON: any;
  116543. AudioContext: AudioContext;
  116544. webkitAudioContext: AudioContext;
  116545. PointerEvent: any;
  116546. Math: Math;
  116547. Uint8Array: Uint8ArrayConstructor;
  116548. Float32Array: Float32ArrayConstructor;
  116549. mozURL: typeof URL;
  116550. msURL: typeof URL;
  116551. VRFrameData: any; // WebVR, from specs 1.1
  116552. DracoDecoderModule: any;
  116553. setImmediate(handler: (...args: any[]) => void): number;
  116554. }
  116555. interface HTMLCanvasElement {
  116556. requestPointerLock(): void;
  116557. msRequestPointerLock?(): void;
  116558. mozRequestPointerLock?(): void;
  116559. webkitRequestPointerLock?(): void;
  116560. /** Track wether a record is in progress */
  116561. isRecording: boolean;
  116562. /** Capture Stream method defined by some browsers */
  116563. captureStream(fps?: number): MediaStream;
  116564. }
  116565. interface CanvasRenderingContext2D {
  116566. msImageSmoothingEnabled: boolean;
  116567. }
  116568. interface MouseEvent {
  116569. mozMovementX: number;
  116570. mozMovementY: number;
  116571. webkitMovementX: number;
  116572. webkitMovementY: number;
  116573. msMovementX: number;
  116574. msMovementY: number;
  116575. }
  116576. interface Navigator {
  116577. mozGetVRDevices: (any: any) => any;
  116578. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116579. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116580. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116581. webkitGetGamepads(): Gamepad[];
  116582. msGetGamepads(): Gamepad[];
  116583. webkitGamepads(): Gamepad[];
  116584. }
  116585. interface HTMLVideoElement {
  116586. mozSrcObject: any;
  116587. }
  116588. interface Math {
  116589. fround(x: number): number;
  116590. imul(a: number, b: number): number;
  116591. }
  116592. interface WebGLRenderingContext {
  116593. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116594. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116595. vertexAttribDivisor(index: number, divisor: number): void;
  116596. createVertexArray(): any;
  116597. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116598. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116599. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116600. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116601. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116602. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116603. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116604. // Queries
  116605. createQuery(): WebGLQuery;
  116606. deleteQuery(query: WebGLQuery): void;
  116607. beginQuery(target: number, query: WebGLQuery): void;
  116608. endQuery(target: number): void;
  116609. getQueryParameter(query: WebGLQuery, pname: number): any;
  116610. getQuery(target: number, pname: number): any;
  116611. MAX_SAMPLES: number;
  116612. RGBA8: number;
  116613. READ_FRAMEBUFFER: number;
  116614. DRAW_FRAMEBUFFER: number;
  116615. UNIFORM_BUFFER: number;
  116616. HALF_FLOAT_OES: number;
  116617. RGBA16F: number;
  116618. RGBA32F: number;
  116619. R32F: number;
  116620. RG32F: number;
  116621. RGB32F: number;
  116622. R16F: number;
  116623. RG16F: number;
  116624. RGB16F: number;
  116625. RED: number;
  116626. RG: number;
  116627. R8: number;
  116628. RG8: number;
  116629. UNSIGNED_INT_24_8: number;
  116630. DEPTH24_STENCIL8: number;
  116631. /* Multiple Render Targets */
  116632. drawBuffers(buffers: number[]): void;
  116633. readBuffer(src: number): void;
  116634. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116635. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116636. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116637. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116638. // Occlusion Query
  116639. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116640. ANY_SAMPLES_PASSED: number;
  116641. QUERY_RESULT_AVAILABLE: number;
  116642. QUERY_RESULT: number;
  116643. }
  116644. interface WebGLProgram {
  116645. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116646. }
  116647. interface EXT_disjoint_timer_query {
  116648. QUERY_COUNTER_BITS_EXT: number;
  116649. TIME_ELAPSED_EXT: number;
  116650. TIMESTAMP_EXT: number;
  116651. GPU_DISJOINT_EXT: number;
  116652. QUERY_RESULT_EXT: number;
  116653. QUERY_RESULT_AVAILABLE_EXT: number;
  116654. queryCounterEXT(query: WebGLQuery, target: number): void;
  116655. createQueryEXT(): WebGLQuery;
  116656. beginQueryEXT(target: number, query: WebGLQuery): void;
  116657. endQueryEXT(target: number): void;
  116658. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116659. deleteQueryEXT(query: WebGLQuery): void;
  116660. }
  116661. interface WebGLUniformLocation {
  116662. _currentState: any;
  116663. }
  116664. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116665. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116666. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116667. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116668. interface WebGLRenderingContext {
  116669. readonly RASTERIZER_DISCARD: number;
  116670. readonly DEPTH_COMPONENT24: number;
  116671. readonly TEXTURE_3D: number;
  116672. readonly TEXTURE_2D_ARRAY: number;
  116673. readonly TEXTURE_COMPARE_FUNC: number;
  116674. readonly TEXTURE_COMPARE_MODE: number;
  116675. readonly COMPARE_REF_TO_TEXTURE: number;
  116676. readonly TEXTURE_WRAP_R: number;
  116677. readonly HALF_FLOAT: number;
  116678. readonly RGB8: number;
  116679. readonly RED_INTEGER: number;
  116680. readonly RG_INTEGER: number;
  116681. readonly RGB_INTEGER: number;
  116682. readonly RGBA_INTEGER: number;
  116683. readonly R8_SNORM: number;
  116684. readonly RG8_SNORM: number;
  116685. readonly RGB8_SNORM: number;
  116686. readonly RGBA8_SNORM: number;
  116687. readonly R8I: number;
  116688. readonly RG8I: number;
  116689. readonly RGB8I: number;
  116690. readonly RGBA8I: number;
  116691. readonly R8UI: number;
  116692. readonly RG8UI: number;
  116693. readonly RGB8UI: number;
  116694. readonly RGBA8UI: number;
  116695. readonly R16I: number;
  116696. readonly RG16I: number;
  116697. readonly RGB16I: number;
  116698. readonly RGBA16I: number;
  116699. readonly R16UI: number;
  116700. readonly RG16UI: number;
  116701. readonly RGB16UI: number;
  116702. readonly RGBA16UI: number;
  116703. readonly R32I: number;
  116704. readonly RG32I: number;
  116705. readonly RGB32I: number;
  116706. readonly RGBA32I: number;
  116707. readonly R32UI: number;
  116708. readonly RG32UI: number;
  116709. readonly RGB32UI: number;
  116710. readonly RGBA32UI: number;
  116711. readonly RGB10_A2UI: number;
  116712. readonly R11F_G11F_B10F: number;
  116713. readonly RGB9_E5: number;
  116714. readonly RGB10_A2: number;
  116715. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116716. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116717. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116718. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116719. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116720. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116721. 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;
  116722. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116723. readonly TRANSFORM_FEEDBACK: number;
  116724. readonly INTERLEAVED_ATTRIBS: number;
  116725. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116726. createTransformFeedback(): WebGLTransformFeedback;
  116727. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116728. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116729. beginTransformFeedback(primitiveMode: number): void;
  116730. endTransformFeedback(): void;
  116731. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116732. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116733. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116734. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116735. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116736. }
  116737. interface ImageBitmap {
  116738. readonly width: number;
  116739. readonly height: number;
  116740. close(): void;
  116741. }
  116742. interface WebGLQuery extends WebGLObject {
  116743. }
  116744. declare var WebGLQuery: {
  116745. prototype: WebGLQuery;
  116746. new(): WebGLQuery;
  116747. };
  116748. interface WebGLSampler extends WebGLObject {
  116749. }
  116750. declare var WebGLSampler: {
  116751. prototype: WebGLSampler;
  116752. new(): WebGLSampler;
  116753. };
  116754. interface WebGLSync extends WebGLObject {
  116755. }
  116756. declare var WebGLSync: {
  116757. prototype: WebGLSync;
  116758. new(): WebGLSync;
  116759. };
  116760. interface WebGLTransformFeedback extends WebGLObject {
  116761. }
  116762. declare var WebGLTransformFeedback: {
  116763. prototype: WebGLTransformFeedback;
  116764. new(): WebGLTransformFeedback;
  116765. };
  116766. interface WebGLVertexArrayObject extends WebGLObject {
  116767. }
  116768. declare var WebGLVertexArrayObject: {
  116769. prototype: WebGLVertexArrayObject;
  116770. new(): WebGLVertexArrayObject;
  116771. };
  116772. // Type definitions for WebVR API
  116773. // Project: https://w3c.github.io/webvr/
  116774. // Definitions by: six a <https://github.com/lostfictions>
  116775. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116776. interface VRDisplay extends EventTarget {
  116777. /**
  116778. * Dictionary of capabilities describing the VRDisplay.
  116779. */
  116780. readonly capabilities: VRDisplayCapabilities;
  116781. /**
  116782. * z-depth defining the far plane of the eye view frustum
  116783. * enables mapping of values in the render target depth
  116784. * attachment to scene coordinates. Initially set to 10000.0.
  116785. */
  116786. depthFar: number;
  116787. /**
  116788. * z-depth defining the near plane of the eye view frustum
  116789. * enables mapping of values in the render target depth
  116790. * attachment to scene coordinates. Initially set to 0.01.
  116791. */
  116792. depthNear: number;
  116793. /**
  116794. * An identifier for this distinct VRDisplay. Used as an
  116795. * association point in the Gamepad API.
  116796. */
  116797. readonly displayId: number;
  116798. /**
  116799. * A display name, a user-readable name identifying it.
  116800. */
  116801. readonly displayName: string;
  116802. readonly isConnected: boolean;
  116803. readonly isPresenting: boolean;
  116804. /**
  116805. * If this VRDisplay supports room-scale experiences, the optional
  116806. * stage attribute contains details on the room-scale parameters.
  116807. */
  116808. readonly stageParameters: VRStageParameters | null;
  116809. /**
  116810. * Passing the value returned by `requestAnimationFrame` to
  116811. * `cancelAnimationFrame` will unregister the callback.
  116812. * @param handle Define the hanle of the request to cancel
  116813. */
  116814. cancelAnimationFrame(handle: number): void;
  116815. /**
  116816. * Stops presenting to the VRDisplay.
  116817. * @returns a promise to know when it stopped
  116818. */
  116819. exitPresent(): Promise<void>;
  116820. /**
  116821. * Return the current VREyeParameters for the given eye.
  116822. * @param whichEye Define the eye we want the parameter for
  116823. * @returns the eye parameters
  116824. */
  116825. getEyeParameters(whichEye: string): VREyeParameters;
  116826. /**
  116827. * Populates the passed VRFrameData with the information required to render
  116828. * the current frame.
  116829. * @param frameData Define the data structure to populate
  116830. * @returns true if ok otherwise false
  116831. */
  116832. getFrameData(frameData: VRFrameData): boolean;
  116833. /**
  116834. * Get the layers currently being presented.
  116835. * @returns the list of VR layers
  116836. */
  116837. getLayers(): VRLayer[];
  116838. /**
  116839. * Return a VRPose containing the future predicted pose of the VRDisplay
  116840. * when the current frame will be presented. The value returned will not
  116841. * change until JavaScript has returned control to the browser.
  116842. *
  116843. * The VRPose will contain the position, orientation, velocity,
  116844. * and acceleration of each of these properties.
  116845. * @returns the pose object
  116846. */
  116847. getPose(): VRPose;
  116848. /**
  116849. * Return the current instantaneous pose of the VRDisplay, with no
  116850. * prediction applied.
  116851. * @returns the current instantaneous pose
  116852. */
  116853. getImmediatePose(): VRPose;
  116854. /**
  116855. * The callback passed to `requestAnimationFrame` will be called
  116856. * any time a new frame should be rendered. When the VRDisplay is
  116857. * presenting the callback will be called at the native refresh
  116858. * rate of the HMD. When not presenting this function acts
  116859. * identically to how window.requestAnimationFrame acts. Content should
  116860. * make no assumptions of frame rate or vsync behavior as the HMD runs
  116861. * asynchronously from other displays and at differing refresh rates.
  116862. * @param callback Define the eaction to run next frame
  116863. * @returns the request handle it
  116864. */
  116865. requestAnimationFrame(callback: FrameRequestCallback): number;
  116866. /**
  116867. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  116868. * Repeat calls while already presenting will update the VRLayers being displayed.
  116869. * @param layers Define the list of layer to present
  116870. * @returns a promise to know when the request has been fulfilled
  116871. */
  116872. requestPresent(layers: VRLayer[]): Promise<void>;
  116873. /**
  116874. * Reset the pose for this display, treating its current position and
  116875. * orientation as the "origin/zero" values. VRPose.position,
  116876. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  116877. * updated when calling resetPose(). This should be called in only
  116878. * sitting-space experiences.
  116879. */
  116880. resetPose(): void;
  116881. /**
  116882. * The VRLayer provided to the VRDisplay will be captured and presented
  116883. * in the HMD. Calling this function has the same effect on the source
  116884. * canvas as any other operation that uses its source image, and canvases
  116885. * created without preserveDrawingBuffer set to true will be cleared.
  116886. * @param pose Define the pose to submit
  116887. */
  116888. submitFrame(pose?: VRPose): void;
  116889. }
  116890. declare var VRDisplay: {
  116891. prototype: VRDisplay;
  116892. new(): VRDisplay;
  116893. };
  116894. interface VRLayer {
  116895. leftBounds?: number[] | Float32Array | null;
  116896. rightBounds?: number[] | Float32Array | null;
  116897. source?: HTMLCanvasElement | null;
  116898. }
  116899. interface VRDisplayCapabilities {
  116900. readonly canPresent: boolean;
  116901. readonly hasExternalDisplay: boolean;
  116902. readonly hasOrientation: boolean;
  116903. readonly hasPosition: boolean;
  116904. readonly maxLayers: number;
  116905. }
  116906. interface VREyeParameters {
  116907. /** @deprecated */
  116908. readonly fieldOfView: VRFieldOfView;
  116909. readonly offset: Float32Array;
  116910. readonly renderHeight: number;
  116911. readonly renderWidth: number;
  116912. }
  116913. interface VRFieldOfView {
  116914. readonly downDegrees: number;
  116915. readonly leftDegrees: number;
  116916. readonly rightDegrees: number;
  116917. readonly upDegrees: number;
  116918. }
  116919. interface VRFrameData {
  116920. readonly leftProjectionMatrix: Float32Array;
  116921. readonly leftViewMatrix: Float32Array;
  116922. readonly pose: VRPose;
  116923. readonly rightProjectionMatrix: Float32Array;
  116924. readonly rightViewMatrix: Float32Array;
  116925. readonly timestamp: number;
  116926. }
  116927. interface VRPose {
  116928. readonly angularAcceleration: Float32Array | null;
  116929. readonly angularVelocity: Float32Array | null;
  116930. readonly linearAcceleration: Float32Array | null;
  116931. readonly linearVelocity: Float32Array | null;
  116932. readonly orientation: Float32Array | null;
  116933. readonly position: Float32Array | null;
  116934. readonly timestamp: number;
  116935. }
  116936. interface VRStageParameters {
  116937. sittingToStandingTransform?: Float32Array;
  116938. sizeX?: number;
  116939. sizeY?: number;
  116940. }
  116941. interface Navigator {
  116942. getVRDisplays(): Promise<VRDisplay[]>;
  116943. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116944. }
  116945. interface Window {
  116946. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116947. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116948. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116949. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116950. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116951. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116952. }
  116953. interface Gamepad {
  116954. readonly displayId: number;
  116955. }
  116956. interface XRDevice {
  116957. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116958. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116959. }
  116960. interface XRSession {
  116961. getInputSources(): Array<any>;
  116962. baseLayer: XRWebGLLayer;
  116963. requestFrameOfReference(type: string): Promise<void>;
  116964. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116965. end(): Promise<void>;
  116966. requestAnimationFrame: Function;
  116967. addEventListener: Function;
  116968. }
  116969. interface XRSessionCreationOptions {
  116970. outputContext?: WebGLRenderingContext | null;
  116971. immersive?: boolean;
  116972. environmentIntegration?: boolean;
  116973. }
  116974. interface XRLayer {
  116975. getViewport: Function;
  116976. framebufferWidth: number;
  116977. framebufferHeight: number;
  116978. }
  116979. interface XRView {
  116980. projectionMatrix: Float32Array;
  116981. }
  116982. interface XRFrame {
  116983. getDevicePose: Function;
  116984. getInputPose: Function;
  116985. views: Array<XRView>;
  116986. baseLayer: XRLayer;
  116987. }
  116988. interface XRFrameOfReference {
  116989. }
  116990. interface XRWebGLLayer extends XRLayer {
  116991. framebuffer: WebGLFramebuffer;
  116992. }
  116993. declare var XRWebGLLayer: {
  116994. prototype: XRWebGLLayer;
  116995. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  116996. };